diff --git a/build.gradle b/build.gradle index b894d647..621bc62f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1692122114 +//version: 1696265388 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -89,6 +89,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output') def projectJavaVersion = JavaLanguageVersion.of(8) boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false +boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false + +final String CHECKSTYLE_CONFIG = """ + + + + + + + + + + + +""" checkPropertyExists("modName") checkPropertyExists("modId") @@ -140,6 +157,17 @@ if (!disableSpotless) { apply from: Blowdryer.file('spotless.gradle') } +if (!disableCheckstyle) { + apply plugin: 'checkstyle' + tasks.named("checkstylePatchedMc") { enabled = false } + tasks.named("checkstyleMcLauncher") { enabled = false } + tasks.named("checkstyleIdeVirtualMain") { enabled = false } + tasks.named("checkstyleInjectedTags") { enabled = false } + checkstyle { + config = resources.text.fromString(CHECKSTYLE_CONFIG) + } +} + String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" String kotlinSourceDir = "src/main/kotlin/" @@ -600,15 +628,10 @@ repositories { } maven { name = "ic2" - url = "https://maven.ic2.player.to/" - metadataSources { - mavenPom() - artifact() + url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/") + content { + includeGroup "net.industrial-craft" } - } - maven { - name = "ic2-mirror" - url = "https://maven2.ic2.player.to/" metadataSources { mavenPom() artifact() @@ -770,23 +793,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies" } dependencies { - def lwjgl3ifyVersion = '1.4.0' - def asmVersion = '9.4' + def lwjgl3ifyVersion = '1.5.0' if (modId != 'lwjgl3ify') { java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") } if (modId != 'hodgepodge') { - java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26') + java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.7') } - java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false} - java17PatchDependencies("org.ow2.asm:asm:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}") - java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}") - java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1') - java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0") java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false} } @@ -1576,6 +1590,25 @@ def getSecondaryArtifacts() { return secondaryArtifacts } +def getURL(String main, String fallback) { + return pingURL(main, 10000) ? main : fallback +} + +// credit: https://stackoverflow.com/a/3584332 +def pingURL(String url, int timeout) { + url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates. + try { + HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection() + connection.setConnectTimeout(timeout) + connection.setReadTimeout(timeout) + connection.setRequestMethod("HEAD") + int responseCode = connection.getResponseCode() + return 200 <= responseCode && responseCode <= 399 + } catch (IOException ignored) { + return false + } +} + // For easier scripting of things that require variables defined earlier in the buildscript if (file('addon.late.gradle.kts').exists()) { apply from: 'addon.late.gradle.kts' diff --git a/dependencies.gradle b/dependencies.gradle index 5fc31fc1..1dd222c3 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -15,15 +15,15 @@ configurations { dependencies { api("com.github.GTNewHorizons:GTNHLib:0.0.13:dev") - transformedMod("com.github.GTNewHorizons:NotEnoughItems:2.4.2-GTNH:dev") // force a more up-to-date NEI version + transformedMod("com.github.GTNewHorizons:NotEnoughItems:2.4.3-GTNH:dev") // force a more up-to-date NEI version transformedMod("com.github.GTNewHorizons:Baubles:1.0.1.16:dev") - transformedMod("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-254-GTNH") + transformedMod("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-259-GTNH") transformedMod("com.github.GTNewHorizons:Galacticraft:3.0.73-GTNH:dev") - transformedMod("com.github.GTNewHorizons:GT5-Unofficial:5.09.44.14:dev") + transformedMod("com.github.GTNewHorizons:GT5-Unofficial:5.09.44.30:dev") transformedMod("com.github.GTNewHorizons:HungerOverhaul:1.0.4-GTNH:dev") transformedMod("com.github.GTNewHorizons:MrTJPCore:1.1.4:dev") // Do not update, fixed afterwards transformedMod("com.github.GTNewHorizons:Railcraft:9.15.0:dev") { exclude group: "thaumcraft", module: "Thaumcraft" } - transformedMod("com.github.GTNewHorizons:TinkersConstruct:1.10.3-GTNH:dev") + transformedMod("com.github.GTNewHorizons:TinkersConstruct:1.10.5-GTNH:dev") transformedMod("curse.maven:biomes-o-plenty-220318:2499612") transformedMod("curse.maven:cofh-core-69162:2388751") transformedMod("curse.maven:extra-utilities-225561:2264384") @@ -37,6 +37,7 @@ dependencies { transformedModCompileOnly("curse.maven:immersive-engineering-231951:2299019") transformedMod("com.github.GTNewHorizons:harvestcraft:1.1.1-GTNH:dev") transformedModCompileOnly deobf('https://media.forgecdn.net/files/4091/561/LOTRMod+v36.15.jar') + transformedModCompileOnly deobf("https://mediafiles.forgecdn.net/files/2523/840/Better+HUD+by+NukeDuck+%5b1.7.10%5d%5b1.3.5%5d.jar") // Contains an outdated copy of thaumcraft api that breaks class loading at runtime transformedModCompileOnly(deobf("https://mediafiles.forgecdn.net/files/2241/397/Pam%27s+Harvest+the+Nether+1.7.10a.jar")) transformedMod(deobf("https://mediafiles.forgecdn.net/files/2340/786/ProjectE-1.7.10-PE1.10.1.jar")) diff --git a/gradle.properties b/gradle.properties index c77edb22..78c08e2b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ usesMixins = true # Adds some debug arguments like verbose output and export usesMixinDebug = true # Specify the location of your implementation of IMixinPlugin. Leave it empty otherwise. -mixinPlugin = +mixinPlugin = # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! mixinsPackage = mixins # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! diff --git a/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java b/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java index c1028357..e212dc36 100644 --- a/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java +++ b/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java @@ -31,6 +31,9 @@ public class LoadingConfig { public boolean changeSprintCategory; public boolean enlargePotionArray; + public boolean fixBetterHUDArmorDisplay; + public boolean fixBetterHUDHPDisplay; + public int betterHUDHPRenderLimit; public boolean fixBibliocraftPackets; public boolean fixBibliocraftPathSanitization; public boolean fixChatWrappedColors; @@ -69,6 +72,7 @@ public class LoadingConfig { public boolean fixJourneymapKeybinds; public boolean fixJourneymapJumpyScrolling; public boolean fixJourneymapFilePath; + public boolean fixNetHandlerLoginServerOfflineMode; public boolean fixNetHandlerPlayClientHandleSetSlot; public boolean fixNetherLeavesFaceRendering; public boolean fixNorthWestBias; @@ -123,6 +127,7 @@ public class LoadingConfig { public boolean removeUpdateChecks; public boolean speedupAnimations; public boolean speedupBOPFogHandling; + public boolean speedupGrassBlockRandomTicking; public boolean speedupChunkCoordinatesHashCode; public boolean speedupProgressBar; public boolean speedupVanillaFurnace; @@ -234,6 +239,9 @@ public LoadingConfig(File file) { fixGuiGameOver = config.get(Category.FIXES.toString(), "fixGuiGameOver", true, "Fix Game Over GUI buttons disabled if switching fullscreen").getBoolean(); fixHasteArmSwing = config.get(Category.FIXES.toString(), "fixHasteArmSwing", true, "Fix arm not swinging when having too much haste").getBoolean(); fixTimeCommandWithGC = config.get(Category.FIXES.toString(), "fixTimeCommandWithGC", true, "Fix time commands with GC").getBoolean(); + fixBetterHUDArmorDisplay = config.get(Category.FIXES.toString(), "fixBetterHUDArmorDisplay",true, "Fix BetterHUD armor bar rendering breaking with skulls").getBoolean(); + fixBetterHUDHPDisplay = config.get(Category.FIXES.toString(), "fixBetterHUDHPDisplay",true, "Fix BetterHUD freezing the game when trying to render high amounts of hp").getBoolean(); + betterHUDHPRenderLimit = config.get(Category.FIXES.toString(),"betterHUDHPRenderLimit", 5000, "Maximum hp for BetterHUD to render as hearts").getInt(); fixBibliocraftPackets = config.get(Category.FIXES.toString(), "fixBibliocraftPackets", true, "Fix Bibliocraft packet exploits").getBoolean(); fixBibliocraftPathSanitization = config.get(Category.FIXES.toString(), "fixBibliocraftPathSanitization", true, "Fix Bibliocraft path sanitization").getBoolean(); fixZTonesPackets = config.get(Category.FIXES.toString(), "fixZTonesPackets", true, "Fix ZTones packet exploits").getBoolean(); @@ -255,6 +263,7 @@ public LoadingConfig(File file) { fixJourneymapKeybinds = config.get(Category.FIXES.toString(), "fixJourneymapKeybinds", true, "Prevent unbinded keybinds from triggering when pressing certain keys").getBoolean(); fixJourneymapJumpyScrolling = config.get(Category.FIXES.toString(), "fixJourneymapJumpyScrolling", true, "Fix jumpy scrolling in the waypoint manager screen").getBoolean(); fixJourneymapFilePath = config.get(Category.FIXES.toString(), "fixJourneymapFilePath", true, "Prevents journeymap from using illegal character in file paths").getBoolean(); + fixNetHandlerLoginServerOfflineMode = config.get(Category.FIXES.toString(), "fixNetHandlerLoginServerOfflineMode", true, "Allows the server to assign the logged in UUID to the same username when online_mode is false").getBoolean(); fixNetHandlerPlayClientHandleSetSlot = config.get(Category.FIXES.toString(), "fixNetHandlerPlayClientHandleSetSlot", true, "Prevents crash if server sends itemStack with index larger than client's container").getBoolean(); fixNetherLeavesFaceRendering = config.get(Category.FIXES.toString(), "fixNetherLeavesFaceRendering", true, "If fancy graphics are enabled, Nether Leaves render sides with other Nether Leaves adjacent too").getBoolean(); fixNorthWestBias = config.get(Category.FIXES.toString(), "fixNorthWestBias", true, "Fix northwest bias on RandomPositionGenerator").getBoolean(); @@ -315,6 +324,7 @@ public LoadingConfig(File file) { renderDebugMode = config.get(Category.DEBUG.toString(), "renderDebugMode", 0, "Default GL state debug mode. 0 - off, 1 - reduced, 2 - full").setMinValue(0).setMaxValue(2).getInt(); speedupAnimations = config.get(Category.FIXES.toString(), "speedupAnimations", true, "Drastically speedup animated textures (Basically the same as with optifine animations off but animations are working)").getBoolean(); speedupBOPFogHandling = config.get(Category.SPEEDUPS.toString(), "speedupBOPFogHandling", true, "Speedup biome fog rendering in BiomesOPlenty").getBoolean(); + speedupGrassBlockRandomTicking = config.get(Category.SPEEDUPS.toString(), "speedupGrassBlockRandomTicking", true, "Speed up grass block random ticking").getBoolean(); speedupChunkCoordinatesHashCode = config.get(Category.SPEEDUPS.toString(), "speedupChunkCoordinatesHashCode", true, "Speedup ChunkCoordinates hashCode").getBoolean(); speedupProgressBar = config.get(Category.ASM.toString(), "speedupProgressBar", true, "Speedup progressbar").getBoolean(); speedupVanillaFurnace = config.get(Category.SPEEDUPS.toString(), "speedupVanillaFurnace", true, "Speedup Vanilla Furnace recipe lookup").getBoolean(); @@ -330,14 +340,14 @@ public LoadingConfig(File file) { // Disable for now as it is not compatible with anything modifying RenderBlocks pollutionAsm = config.get(Category.ASM.toString(), "pollutionAsm", false, "Enable pollution rendering ASM").getBoolean(); - + // Pollution :nauseous: furnacesPollute = config.get(Category.POLLUTION.toString(), "furnacesPollute", true, "Make furnaces Pollute").getBoolean(); rocketsPollute = config.get(Category.POLLUTION.toString(), "rocketsPollute", true, "Make rockets Pollute").getBoolean(); railcraftPollutes = config.get(Category.POLLUTION.toString(), "railcraftPollutes", true, "Make Railcraft Pollute").getBoolean(); disableAidSpawnByXUSpikes = config.get(Category.TWEAKS.toString(), "disableAidSpawnByXUSpikes", true, "Disables the spawn of zombie aid when zombie is killed by Extra Utilities Spikes, since it can spawn them too far.").getBoolean(); - + furnacePollutionAmount = config.get(Category.POLLUTION.toString(), "furnacePollution", 20, "Furnace pollution per second, min 1!", 1, Integer.MAX_VALUE).getInt(); fireboxPollutionAmount = config.get(Category.POLLUTION.toString(), "fireboxPollution", 15, "Pollution Amount for RC Firebox", 1, Integer.MAX_VALUE).getInt(); rocketPollutionAmount = config.get(Category.POLLUTION.toString(), "rocketPollution", 1000, "Pollution Amount for Rockets", 1, Integer.MAX_VALUE).getInt(); @@ -346,8 +356,8 @@ public LoadingConfig(File file) { hobbyistEnginePollutionAmount = config.get(Category.POLLUTION.toString(), "hobbyistEnginePollution", 20, "Pollution Amount for hobbyist steam engine", 1, Integer.MAX_VALUE).getInt(); tunnelBorePollutionAmount = config.get(Category.POLLUTION.toString(), "tunnelBorePollution", 2, "Pollution Amount for tunnel bore", 1, Integer.MAX_VALUE).getInt(); explosionPollutionAmount = config.get(Category.POLLUTION.toString(), "explosionPollution", 33.34, "Explosion pollution").getDouble(); - - + + // spotless:on if (config.hasChanged()) config.save(); } diff --git a/src/main/java/com/mitchej123/hodgepodge/asm/util/AbstractMethodTransformer.java b/src/main/java/com/mitchej123/hodgepodge/asm/util/AbstractMethodTransformer.java index cd460573..84214405 100644 --- a/src/main/java/com/mitchej123/hodgepodge/asm/util/AbstractMethodTransformer.java +++ b/src/main/java/com/mitchej123/hodgepodge/asm/util/AbstractMethodTransformer.java @@ -4,7 +4,14 @@ import java.io.StringWriter; import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.*; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.TypeInsnNode; +import org.objectweb.asm.tree.VarInsnNode; import org.objectweb.asm.util.Printer; import org.objectweb.asm.util.Textifier; import org.objectweb.asm.util.TraceMethodVisitor; diff --git a/src/main/java/com/mitchej123/hodgepodge/common/KeyBindingDuck.java b/src/main/java/com/mitchej123/hodgepodge/common/KeyBindingDuck.java deleted file mode 100644 index a79bbb1d..00000000 --- a/src/main/java/com/mitchej123/hodgepodge/common/KeyBindingDuck.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mitchej123.hodgepodge.common; - -public interface KeyBindingDuck { - - void hodgepodge$updateKeyStates(); -} diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java index bc4f1387..ec081240 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java @@ -34,7 +34,7 @@ public enum Mixins { FIX_NETHANDLERLOGINSERVER_OFFLINEMODE( new Builder("Allows the server to assign the logged in UUID to the same username when online_mode is false") .setPhase(Phase.EARLY).addMixinClasses("minecraft.MixinNetHandlerLoginServer_OfflineMode") - .setSide(Side.SERVER).setApplyIf(() -> true) /* no config option for this */ + .setSide(Side.SERVER).setApplyIf(() -> Common.config.fixNetHandlerLoginServerOfflineMode) .addTargetedMod(TargetedMod.VANILLA)), FIX_INVENTORY_POTION_EFFECT_NUMERALS( new Builder("Fix potion effects level not displaying properly above a certain value").setPhase(Phase.EARLY) @@ -88,6 +88,9 @@ public enum Mixins { LONGER_MESSAGES_SERVER(new Builder("Longer Messages").setPhase(Phase.EARLY) .addMixinClasses("minecraft.MixinC01PacketChatMessage_LongerMessages") .setApplyIf(() -> Common.config.longerSentMessages).addTargetedMod(TargetedMod.VANILLA).setSide(Side.BOTH)), + SPEEDUP_GRASS_BLOCK_RANDOM_TICKING(new Builder("Speed up grass block random ticking").setPhase(Phase.EARLY) + .addMixinClasses("minecraft.MixinBlockGrass").addTargetedMod(TargetedMod.VANILLA) + .setApplyIf(() -> Common.config.speedupGrassBlockRandomTicking)), CHUNK_COORDINATES_HASHCODE(new Builder("Optimize Chunk Coordinates Hashcode").setPhase(Phase.EARLY) .addMixinClasses("minecraft.MixinChunkCoordinates").addTargetedMod(TargetedMod.VANILLA) .setApplyIf(() -> Common.config.speedupChunkCoordinatesHashCode)), @@ -404,6 +407,15 @@ public enum Mixins { new Builder("Thirsty Tank Container").addMixinClasses("automagy.MixinItemBlockThirstyTank") .setApplyIf(() -> Common.config.thirstyTankContainer).addTargetedMod(TargetedMod.AUTOMAGY)), + // Better HUD + FIX_BETTERHUD_ARMOR_BAR(new Builder("Fix better HUD armor display breaking with skulls") + .addMixinClasses("betterhud.MixinSkullDurabilityDisplay") + .setApplyIf(() -> Common.config.fixBetterHUDArmorDisplay).addTargetedMod(TargetedMod.BETTERHUD)), + + FIX_BETTERHUD_HEARTS_FREEZE(new Builder("Fix better HUD freezing the game when trying to render high amounts of hp") + .addMixinClasses("betterhud.MixinHealthRender").setApplyIf(() -> Common.config.fixBetterHUDHPDisplay) + .addTargetedMod(TargetedMod.BETTERHUD)), + // ProjectE FIX_FURNACE_ITERATION(new Builder("Speedup Furnaces").addMixinClasses("projecte.MixinObjHandler") .setApplyIf(() -> Common.config.speedupVanillaFurnace).addTargetedMod(TargetedMod.PROJECTE)), diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/TargetedMod.java b/src/main/java/com/mitchej123/hodgepodge/mixins/TargetedMod.java index f40d1e50..ba50f618 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/TargetedMod.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/TargetedMod.java @@ -5,6 +5,7 @@ public enum TargetedMod { ARCHAICFIX("ArchaicFix", "org.embeddedt.archaicfix.ArchaicCore", "archaicfix"), AUTOMAGY("Automagy", null, "Automagy"), BAUBLES("Baubles", null, "Baubles"), + BETTERHUD("Better HUD", null, "hud"), BIBLIOCRAFT("Bibliocraft", null, "BiblioCraft"), BOP("BiomesOPlenty", null, "BiomesOPlenty"), BUKKIT("Bukkit/Thermos", "Bukkit", null), diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockGrass.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockGrass.java new file mode 100644 index 00000000..c6f624b5 --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockGrass.java @@ -0,0 +1,45 @@ +package com.mitchej123.hodgepodge.mixins.early.minecraft; + +import java.util.Random; + +import net.minecraft.block.BlockGrass; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(BlockGrass.class) +public class MixinBlockGrass { + + /** + * @author tth05 + * @reason Small performance improvements. Prevent chunk loading, avoid doing any work on blocks that can't turn to + * grass, remove duplicate {@link World#getBlockLightValue(int, int, int)} call. + */ + @Overwrite + public void updateTick(World worldIn, int x, int y, int z, Random random) { + if (worldIn.isRemote) return; + + int blockLightValue = worldIn.getBlockLightValue(x, y + 1, z); + if (blockLightValue < 4 && worldIn.getBlockLightOpacity(x, y + 1, z) > 2) { + worldIn.setBlock(x, y, z, Blocks.dirt); + } else if (blockLightValue >= 9) { + for (int i = 0; i < 4; ++i) { + int targetX = x + random.nextInt(3) - 1; + int targetY = y + random.nextInt(5) - 3; + int targetZ = z + random.nextInt(3) - 1; + + if (targetX == x && targetZ == z && (targetY == y || targetY == y - 1)) continue; + if (!worldIn.blockExists(targetX, targetY, targetZ)) continue; + + if (worldIn.getBlock(targetX, targetY, targetZ) == Blocks.dirt + && worldIn.getBlockMetadata(targetX, targetY, targetZ) == 0 + && worldIn.getBlockLightValue(targetX, targetY + 1, targetZ) >= 4 + && worldIn.getBlockLightOpacity(targetX, targetY + 1, targetZ) <= 2) { + worldIn.setBlock(targetX, targetY, targetZ, Blocks.grass); + } + } + } + } +} diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlock_FixXray.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlock_FixXray.java index 0235db2b..e5b244eb 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlock_FixXray.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlock_FixXray.java @@ -7,10 +7,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import com.mitchej123.hodgepodge.common.BlockInvoker_FixXray; +import com.mitchej123.hodgepodge.mixins.interfaces.BlockExt_FixXray; @Mixin(Block.class) -public abstract class MixinBlock_FixXray implements BlockInvoker_FixXray { +public abstract class MixinBlock_FixXray implements BlockExt_FixXray { @Shadow public abstract AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z); diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinKeyBinding.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinKeyBinding.java index d6fff84c..1a4232bf 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinKeyBinding.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinKeyBinding.java @@ -16,10 +16,10 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; -import com.mitchej123.hodgepodge.common.KeyBindingDuck; +import com.mitchej123.hodgepodge.mixins.interfaces.KeyBindingExt; @Mixin(KeyBinding.class) -public class MixinKeyBinding implements KeyBindingDuck { +public class MixinKeyBinding implements KeyBindingExt { @Shadow @Final diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinMinecraft_UpdateKeys.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinMinecraft_UpdateKeys.java index a1933f8b..0c93937b 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinMinecraft_UpdateKeys.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinMinecraft_UpdateKeys.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.mitchej123.hodgepodge.common.KeyBindingDuck; +import com.mitchej123.hodgepodge.mixins.interfaces.KeyBindingExt; @Mixin(Minecraft.class) public class MixinMinecraft_UpdateKeys { @@ -19,7 +19,7 @@ public class MixinMinecraft_UpdateKeys { method = "setIngameFocus", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MouseHelper;grabMouseCursor()V")) private void hodgepodge$updateKeysStates(CallbackInfo ci) { - ((KeyBindingDuck) Minecraft.getMinecraft().gameSettings.keyBindAttack).hodgepodge$updateKeyStates(); + ((KeyBindingExt) Minecraft.getMinecraft().gameSettings.keyBindAttack).hodgepodge$updateKeyStates(); } } diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinWorld_FixXray.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinWorld_FixXray.java index e8948c59..f419deb7 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinWorld_FixXray.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinWorld_FixXray.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import com.mitchej123.hodgepodge.common.BlockInvoker_FixXray; +import com.mitchej123.hodgepodge.mixins.interfaces.BlockExt_FixXray; @Mixin(World.class) public class MixinWorld_FixXray { @@ -23,7 +23,7 @@ public class MixinWorld_FixXray { value = "INVOKE", target = "Lnet/minecraft/block/Block;getCollisionBoundingBoxFromPool(Lnet/minecraft/world/World;III)Lnet/minecraft/util/AxisAlignedBB;")) private AxisAlignedBB hodgepodge$fixXray(Block block, World world, int x, int y, int z) { - if (((BlockInvoker_FixXray) block).hodgepodge$shouldRayTraceStopOnBlock(world, x, y, z)) { + if (((BlockExt_FixXray) block).hodgepodge$shouldRayTraceStopOnBlock(world, x, y, z)) { return hodgepodge$DUMMY_AABB; } return null; diff --git a/src/main/java/com/mitchej123/hodgepodge/common/ThaumcraftMixinMethods.java b/src/main/java/com/mitchej123/hodgepodge/mixins/hooks/ThaumcraftMixinMethods.java similarity index 90% rename from src/main/java/com/mitchej123/hodgepodge/common/ThaumcraftMixinMethods.java rename to src/main/java/com/mitchej123/hodgepodge/mixins/hooks/ThaumcraftMixinMethods.java index 9113863d..0cc849e5 100644 --- a/src/main/java/com/mitchej123/hodgepodge/common/ThaumcraftMixinMethods.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/hooks/ThaumcraftMixinMethods.java @@ -1,4 +1,4 @@ -package com.mitchej123.hodgepodge.common; +package com.mitchej123.hodgepodge.mixins.hooks; import java.util.ArrayList; diff --git a/src/main/java/com/mitchej123/hodgepodge/common/BlockInvoker_FixXray.java b/src/main/java/com/mitchej123/hodgepodge/mixins/interfaces/BlockExt_FixXray.java similarity index 58% rename from src/main/java/com/mitchej123/hodgepodge/common/BlockInvoker_FixXray.java rename to src/main/java/com/mitchej123/hodgepodge/mixins/interfaces/BlockExt_FixXray.java index ee2e850d..1b30ff47 100644 --- a/src/main/java/com/mitchej123/hodgepodge/common/BlockInvoker_FixXray.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/interfaces/BlockExt_FixXray.java @@ -1,8 +1,8 @@ -package com.mitchej123.hodgepodge.common; +package com.mitchej123.hodgepodge.mixins.interfaces; import net.minecraft.world.World; -public interface BlockInvoker_FixXray { +public interface BlockExt_FixXray { boolean hodgepodge$shouldRayTraceStopOnBlock(World worldIn, int x, int y, int z); } diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/interfaces/KeyBindingExt.java b/src/main/java/com/mitchej123/hodgepodge/mixins/interfaces/KeyBindingExt.java new file mode 100644 index 00000000..27c41715 --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/interfaces/KeyBindingExt.java @@ -0,0 +1,6 @@ +package com.mitchej123.hodgepodge.mixins.interfaces; + +public interface KeyBindingExt { + + void hodgepodge$updateKeyStates(); +} diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/late/betterhud/MixinHealthRender.java b/src/main/java/com/mitchej123/hodgepodge/mixins/late/betterhud/MixinHealthRender.java new file mode 100644 index 00000000..3f5a3d15 --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/late/betterhud/MixinHealthRender.java @@ -0,0 +1,52 @@ +package com.mitchej123.hodgepodge.mixins.late.betterhud; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; + +import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.mitchej123.hodgepodge.Common; + +import tk.nukeduck.hud.element.entityinfo.ExtraGuiElementMobInfo; + +@Mixin(value = ExtraGuiElementMobInfo.class, remap = false) +public abstract class MixinHealthRender { + + /** + * Prevent the game from freezing by drawing more hearts than it can chew + */ + @Inject( + method = "renderInfo(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/Minecraft;F)V", + remap = false, + at = @At( + shift = At.Shift.BEFORE, + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V"), + cancellable = true) + private void onlyRenderReasonableHP(EntityLivingBase entity, Minecraft mc, float partialTicks, CallbackInfo ci) { + if (entity.getMaxHealth() > Common.config.betterHUDHPRenderLimit) { + GL11.glPopMatrix(); + ci.cancel(); + } + } + + /** + * Only render the info background when it's actually needed + */ + @ModifyArg( + method = "renderInfo(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/Minecraft;F)V", + remap = false, + at = @At( + value = "INVOKE", + target = "Ltk/nukeduck/hud/util/RenderUtil;renderQuad(Lnet/minecraft/client/renderer/Tessellator;IIIIFFFF)V", + remap = false), + index = 4) + private int limitInfoBoxSize(int input) { + return input > Common.config.betterHUDHPRenderLimit ? 20 : input; + } +} diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/late/betterhud/MixinSkullDurabilityDisplay.java b/src/main/java/com/mitchej123/hodgepodge/mixins/late/betterhud/MixinSkullDurabilityDisplay.java new file mode 100644 index 00000000..125705ce --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/late/betterhud/MixinSkullDurabilityDisplay.java @@ -0,0 +1,44 @@ +package com.mitchej123.hodgepodge.mixins.late.betterhud; + +import net.minecraft.item.ItemSkull; +import net.minecraft.item.ItemStack; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import tk.nukeduck.hud.element.ExtraGuiElementArmorBars; + +@Mixin(value = ExtraGuiElementArmorBars.class, remap = false) +public abstract class MixinSkullDurabilityDisplay { + + /** + * Ensure the drawn damage bar doesn't display invalid values + */ + @ModifyArg( + method = "render(Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/gui/ScaledResolution;Ltk/nukeduck/hud/util/StringManager;Ltk/nukeduck/hud/util/LayoutManager;)V", + remap = false, + at = @At( + value = "INVOKE", + target = "Ltk/nukeduck/hud/util/RenderUtil;drawProgressBar(IIIIF)V", + remap = false)) + private float fixProgressCheck(float input) { + return (input < 0.0f || input > 1.0f) ? 1.0f : input; + } + + /** + * Fix text for itemSkulls displaying negative numbers + */ + @Inject( + method = "generateText(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", + remap = false, + at = @At(value = "HEAD", remap = false), + cancellable = true) + private void fixSkullText(ItemStack itemStack, CallbackInfoReturnable cir) { + if (itemStack.getItem() instanceof ItemSkull) { + cir.setReturnValue(itemStack.getDisplayName()); + } + } +} diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinEntityGolemBase.java b/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinEntityGolemBase.java index 47e928c5..9c88d004 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinEntityGolemBase.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinEntityGolemBase.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.mitchej123.hodgepodge.common.ThaumcraftMixinMethods; +import com.mitchej123.hodgepodge.mixins.hooks.ThaumcraftMixinMethods; import thaumcraft.common.entities.golems.EntityGolemBase; import thaumcraft.common.entities.golems.Marker; diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinItemGolemBell.java b/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinItemGolemBell.java index 00dd299f..ef5b05e1 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinItemGolemBell.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/late/thaumcraft/MixinItemGolemBell.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.mitchej123.hodgepodge.common.ThaumcraftMixinMethods; +import com.mitchej123.hodgepodge.mixins.hooks.ThaumcraftMixinMethods; import thaumcraft.common.entities.golems.ItemGolemBell; import thaumcraft.common.entities.golems.Marker; diff --git a/src/main/java/com/mitchej123/hodgepodge/util/NBTTagCompoundConcurrentModificationException.java b/src/main/java/com/mitchej123/hodgepodge/util/NBTTagCompoundConcurrentModificationException.java index 30056109..4c1ff089 100644 --- a/src/main/java/com/mitchej123/hodgepodge/util/NBTTagCompoundConcurrentModificationException.java +++ b/src/main/java/com/mitchej123/hodgepodge/util/NBTTagCompoundConcurrentModificationException.java @@ -1,6 +1,8 @@ package com.mitchej123.hodgepodge.util; -import java.util.*; +import java.util.ArrayDeque; +import java.util.ConcurrentModificationException; +import java.util.Deque; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/resources/mixins.hodgepodge.json b/src/main/resources/mixins.hodgepodge.json index 798fd33a..784cf4dd 100644 --- a/src/main/resources/mixins.hodgepodge.json +++ b/src/main/resources/mixins.hodgepodge.json @@ -1,7 +1,6 @@ { "required": true, "minVersion": "0.8.3-GTNH", - "package": "com.mitchej123.hodgepodge.mixins", "refmap": "mixins.hodgepodge.refmap.json", "target": "@env(DEFAULT)", "compatibilityLevel": "JAVA_8"