From 52cc9efe01c0cbb37299fc305e304511095a75b6 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sat, 2 Dec 2023 14:53:28 -0800 Subject: [PATCH 1/2] Fix world leak in Redstone Torch --- dependencies.gradle | 8 ++++---- .../com/mitchej123/hodgepodge/LoadingConfig.java | 4 ++++ .../com/mitchej123/hodgepodge/mixins/Mixins.java | 4 ++++ .../early/minecraft/MixinBlockRedstoneTorch.java | 13 +++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java diff --git a/dependencies.gradle b/dependencies.gradle index 5e0350fc..24f5d6f6 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -19,28 +19,28 @@ dependencies { transformedMod("com.github.GTNewHorizons:Baubles:1.0.1.16:dev") // Transitive updates to make runClient17 work transformedMod("com.github.GTNewHorizons:ForgeMultipart:1.3.4:dev") - transformedMod("com.github.GTNewHorizons:Galacticraft:3.0.74-GTNH:dev") transformedMod("com.github.GTNewHorizons:GT5-Unofficial:5.09.44.74:dev") transformedMod("com.github.GTNewHorizons:harvestcraft:1.1.1-GTNH: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.11-GTNH:dev") - transformedMod(deobfCurse("automagy-222153:2285272")) transformedMod(deobfCurse("bibliocraft-228027:2423369")) transformedMod("curse.maven:biomes-o-plenty-220318:2499612") transformedMod("curse.maven:cofh-core-69162:2388751") transformedMod("curse.maven:extra-utilities-225561:2264384") transformedMod(deobfCurse("extratic-72728:2299292")) transformedMod(deobfCurse("journeymap-32274:4500658")) - transformedMod("curse.maven:minechem-368422:2905830") - transformedMod(deobfCurse("projecte-226410:2340786")) transformedMod("curse.maven:travellers-gear-224440:2262113") transformedMod(deobfCurse("witchery-69673:2234410")) transformedMod(deobfCurse("ztones-224369:2223720")) transformedMod("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") transformedMod("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") + transformedModCompileOnly(deobfCurse("automagy-222153:2285272")) + transformedModCompileOnly("com.github.GTNewHorizons:Galacticraft:3.0.74-GTNH:dev") + transformedModCompileOnly("curse.maven:minechem-368422:2905830") + transformedModCompileOnly(deobfCurse("projecte-226410:2340786")) transformedModCompileOnly(deobfCurse("better-hud-286066:2523840")) transformedModCompileOnly("curse.maven:immersive-engineering-231951:2299019") // Contains an outdated copy of thaumcraft api that breaks class loading at runtime diff --git a/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java b/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java index 80ec89df..c850b86f 100644 --- a/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java +++ b/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java @@ -158,6 +158,8 @@ public class LoadingConfig { public boolean replaceVoxelMapReflection; public boolean fixVoxelMapYCoord; public boolean fixVoxelMapChunkNPE; + public boolean fixRedstoneTorchWorldLeak; + // render debug public boolean renderDebug; @@ -354,6 +356,8 @@ public LoadingConfig(File file) { replaceVoxelMapReflection = config.get(Category.SPEEDUPS.toString(), "replaceVoxelMapReflection", true, "Replace reflection in VoxelMap to directly access the fields instead.").getBoolean(); fixVoxelMapYCoord = config.get(Category.FIXES.toString(), "fixVoxelMapYCoord", true, "Fix Y coordinate being off by one").getBoolean(); fixVoxelMapChunkNPE = config.get(Category.FIXES.toString(), "fixVoxelMapChunkNPE", true, "Fix some NullPointerExceptions").getBoolean(); + fixRedstoneTorchWorldLeak = config.get(Category.FIXES.toString(), "fixRedstoneTorchWorldLeak", true, "Fix redstone torch leaking world").getBoolean(); + // Pollution :nauseous: pollutionBlockRecolor = config.get(Category.POLLUTION_RECOLOR.toString(), "pollutionRecolor", true, "Changes colors of certain blocks based on pollution levels").getBoolean(); diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java index ced58514..1cc2c006 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java @@ -164,6 +164,10 @@ public enum Mixins { FIX_WORLD_SERVER_LEAKING_UNLOADED_ENTITIES(new Builder("Fix world server leaking unloaded entities") .setPhase(Phase.EARLY).setSide(Side.BOTH).addMixinClasses("minecraft.MixinWorldServerUpdateEntities") .setApplyIf(() -> Common.config.fixWorldServerLeakingUnloadedEntities).addTargetedMod(TargetedMod.VANILLA)), + + FIX_REDSTONE_TORCH_WORLD_LEAK(new Builder("Fix world leak in redstone torch").setPhase(Phase.EARLY).setSide(Side.BOTH) + .addMixinClasses("minecraft.MixinBlockRedstoneTorch").setApplyIf(() -> Common.config.fixRedstoneTorchWorldLeak) + .addTargetedMod(TargetedMod.VANILLA)), FIX_ARROW_WRONG_LIGHTING(new Builder("Fix arrow wrong lighting").setPhase(Phase.EARLY) .addMixinClasses("minecraft.MixinRendererLivingEntity").setSide(Side.CLIENT) .setApplyIf(() -> Common.config.fixGlStateBugs).addTargetedMod(TargetedMod.VANILLA)), diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java new file mode 100644 index 00000000..548eeff2 --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java @@ -0,0 +1,13 @@ +package com.mitchej123.hodgepodge.mixins.early.minecraft; + +import net.minecraft.block.BlockRedstoneTorch; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.Map; +import java.util.WeakHashMap; + +@Mixin(value = BlockRedstoneTorch.class, remap = false) +public class MixinBlockRedstoneTorch { + @Shadow private static Map field_150112_b = new WeakHashMap<>(); +} From 1498e2b8b5c755694adaa7e20d435ec9d518850a Mon Sep 17 00:00:00 2001 From: GitHub GTNH Actions Date: Sat, 2 Dec 2023 22:58:04 +0000 Subject: [PATCH 2/2] spotlessApply --- .../java/com/mitchej123/hodgepodge/LoadingConfig.java | 1 - .../java/com/mitchej123/hodgepodge/mixins/Mixins.java | 6 +++--- .../early/minecraft/MixinBlockRedstoneTorch.java | 11 +++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java b/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java index c850b86f..7c8ce1f6 100644 --- a/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java +++ b/src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java @@ -160,7 +160,6 @@ public class LoadingConfig { public boolean fixVoxelMapChunkNPE; public boolean fixRedstoneTorchWorldLeak; - // render debug public boolean renderDebug; public int renderDebugMode; diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java index 1cc2c006..eec1dbd9 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java @@ -165,9 +165,9 @@ public enum Mixins { .setPhase(Phase.EARLY).setSide(Side.BOTH).addMixinClasses("minecraft.MixinWorldServerUpdateEntities") .setApplyIf(() -> Common.config.fixWorldServerLeakingUnloadedEntities).addTargetedMod(TargetedMod.VANILLA)), - FIX_REDSTONE_TORCH_WORLD_LEAK(new Builder("Fix world leak in redstone torch").setPhase(Phase.EARLY).setSide(Side.BOTH) - .addMixinClasses("minecraft.MixinBlockRedstoneTorch").setApplyIf(() -> Common.config.fixRedstoneTorchWorldLeak) - .addTargetedMod(TargetedMod.VANILLA)), + FIX_REDSTONE_TORCH_WORLD_LEAK(new Builder("Fix world leak in redstone torch").setPhase(Phase.EARLY) + .setSide(Side.BOTH).addMixinClasses("minecraft.MixinBlockRedstoneTorch") + .setApplyIf(() -> Common.config.fixRedstoneTorchWorldLeak).addTargetedMod(TargetedMod.VANILLA)), FIX_ARROW_WRONG_LIGHTING(new Builder("Fix arrow wrong lighting").setPhase(Phase.EARLY) .addMixinClasses("minecraft.MixinRendererLivingEntity").setSide(Side.CLIENT) .setApplyIf(() -> Common.config.fixGlStateBugs).addTargetedMod(TargetedMod.VANILLA)), diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java index 548eeff2..5e5bc32c 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockRedstoneTorch.java @@ -1,13 +1,16 @@ package com.mitchej123.hodgepodge.mixins.early.minecraft; +import java.util.Map; +import java.util.WeakHashMap; + import net.minecraft.block.BlockRedstoneTorch; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import java.util.Map; -import java.util.WeakHashMap; - @Mixin(value = BlockRedstoneTorch.class, remap = false) public class MixinBlockRedstoneTorch { - @Shadow private static Map field_150112_b = new WeakHashMap<>(); + + @Shadow + private static Map field_150112_b = new WeakHashMap<>(); }