diff --git a/build.gradle b/build.gradle index 121bc9f3..e576b635 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' apply plugin: 'org.spongepowered.mixin' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "3.0.6" +version = "3.1" group = "zone.rong.loliasm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "loliasm" diff --git a/src/main/java/zone/rong/loliasm/common/forgefixes/mixins/ChunkMixin.java b/src/main/java/zone/rong/loliasm/common/forgefixes/mixins/ChunkMixin.java new file mode 100644 index 00000000..49bb3a1a --- /dev/null +++ b/src/main/java/zone/rong/loliasm/common/forgefixes/mixins/ChunkMixin.java @@ -0,0 +1,22 @@ +package zone.rong.loliasm.common.forgefixes.mixins; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.Chunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +@Mixin(Chunk.class) +public class ChunkMixin { + + @Redirect(method = "onLoad", at = @At(value = "INVOKE", target = "Ljava/util/Map;values()Ljava/util/Collection;", remap = false)) + private Collection copiedValues(Map map) { + return new ArrayList<>(map.values()); + } + +} diff --git a/src/main/java/zone/rong/loliasm/config/LoliConfig.java b/src/main/java/zone/rong/loliasm/config/LoliConfig.java index eb5d551d..719b0951 100644 --- a/src/main/java/zone/rong/loliasm/config/LoliConfig.java +++ b/src/main/java/zone/rong/loliasm/config/LoliConfig.java @@ -69,7 +69,7 @@ public boolean shouldSkipClass(Class clazz) { public boolean quickerEnableUniversalBucketCheck, stripInstancedRandomFromSoundEventAccessor; public boolean fixBlockIEBaseArrayIndexOutOfBoundsException, cleanupChickenASMClassHierarchyManager, optimizeAmuletRelatedFunctions, labelCanonicalization, skipCraftTweakerRecalculatingSearchTrees, bwmBlastingOilOptimization; public boolean fixAmuletHolderCapability; - public boolean fixFillBucketEventNullPointerException; + public boolean fixFillBucketEventNullPointerException, fixTileEntityOnLoadCME; private void initialize() { configuration = new Configuration(new File(Launch.minecraftHome, "config" + File.separator + "loliasm.cfg")); @@ -128,6 +128,7 @@ public void load() { fixAmuletHolderCapability = getBoolean("fixAmuletHolderCapability", "capability", "Fixes Astral Sorcery applying AmuletHolderCapability to large amount of ItemStacks when it isn't needed. This option will be ignored when Astral Sorcery isn't installed", true); fixFillBucketEventNullPointerException = getBoolean("fixFillBucketEventNullPointerException", "forgefixes", "Fixes Forge's mistake of annotating FillBucketEvent#getFilledBucket as @Nonnull when the contract isn't fulfilled nor checked. First discovered here: https://github.com/Divine-Journey-2/main/issues/295", true); + fixTileEntityOnLoadCME = getBoolean("fixTileEntityOnLoadCME", "forgefixes", "Fixes a vanilla-forge code interaction bug leading to a possible ConcurrentModificationException/StackOverflowError crash. First discovered here: https://github.com/GregTechCE/GregTech/issues/1256", true); configuration.save(); } diff --git a/src/main/java/zone/rong/loliasm/core/LoliLoadingPlugin.java b/src/main/java/zone/rong/loliasm/core/LoliLoadingPlugin.java index 0fdaa54f..56784f88 100644 --- a/src/main/java/zone/rong/loliasm/core/LoliLoadingPlugin.java +++ b/src/main/java/zone/rong/loliasm/core/LoliLoadingPlugin.java @@ -19,7 +19,7 @@ @IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion) public class LoliLoadingPlugin implements IFMLLoadingPlugin { - public static final String VERSION = "3.0.6"; + public static final String VERSION = "3.1"; public static final boolean isDeobf = FMLLaunchHandler.isDeobfuscatedEnvironment(); public static final boolean isOptifineInstalled = LoliReflector.doesClassExist("optifine.OptiFineForgeTweaker"); @@ -63,7 +63,7 @@ public LoliLoadingPlugin() { if (LoliConfig.instance.quickerEnableUniversalBucketCheck) { Mixins.addConfiguration("mixins.misc_fluidregistry.json"); } - if (LoliConfig.instance.fixFillBucketEventNullPointerException) { + if (LoliConfig.instance.fixFillBucketEventNullPointerException || LoliConfig.instance.fixTileEntityOnLoadCME) { Mixins.addConfiguration("mixins.forgefixes.json"); } if (isClient) { diff --git a/src/main/java/zone/rong/loliasm/core/LoliMixinPlugin.java b/src/main/java/zone/rong/loliasm/core/LoliMixinPlugin.java index 7d71eddc..97b3ffc6 100644 --- a/src/main/java/zone/rong/loliasm/core/LoliMixinPlugin.java +++ b/src/main/java/zone/rong/loliasm/core/LoliMixinPlugin.java @@ -3,6 +3,7 @@ import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; +import zone.rong.loliasm.LoliLogger; import zone.rong.loliasm.config.LoliConfig; import zone.rong.loliasm.core.classfactories.BakedQuadRedirectorFactory; @@ -12,7 +13,9 @@ public class LoliMixinPlugin implements IMixinConfigPlugin { static { - BakedQuadRedirectorFactory.generateRedirectorClass(); + if (LoliConfig.instance.squashBakedQuads) { + BakedQuadRedirectorFactory.generateRedirectorClass(); + } } @Override @@ -25,6 +28,10 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (!LoliConfig.instance.fixTileEntityOnLoadCME && mixinClassName.equals("zone.rong.loliasm.common.forgefixes.mixins.ChunkMixin")) { + LoliLogger.instance.info("fixTileEntityOnLoadCME disabled, will not patch {}", targetClassName); + return false; + } return true; } diff --git a/src/main/java/zone/rong/loliasm/core/LoliTransformer.java b/src/main/java/zone/rong/loliasm/core/LoliTransformer.java index 71c0b87c..6bba8b57 100644 --- a/src/main/java/zone/rong/loliasm/core/LoliTransformer.java +++ b/src/main/java/zone/rong/loliasm/core/LoliTransformer.java @@ -1,13 +1,10 @@ package zone.rong.loliasm.core; -import betterwithmods.module.ModuleLoader; import betterwithmods.module.gameplay.Gameplay; import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.Launch; -import net.minecraftforge.fml.common.Loader; import org.apache.commons.lang3.ArrayUtils; import org.objectweb.asm.*; import org.objectweb.asm.tree.*; @@ -723,7 +720,6 @@ private byte[] canonicalizeSpriteNames(byte[] bytes) { } private byte[] injectBlastingOilEntityItemUpdate(byte[] bytes) { - LoliLogger.instance.info(ModuleLoader.config); if (!Gameplay.disableBlastingOilEvents) { ClassReader reader = new ClassReader(bytes); ClassNode node = new ClassNode(); diff --git a/src/main/resources/mixins.forgefixes.json b/src/main/resources/mixins.forgefixes.json index 62037b4c..8b8b75da 100644 --- a/src/main/resources/mixins.forgefixes.json +++ b/src/main/resources/mixins.forgefixes.json @@ -1,10 +1,12 @@ { "package": "zone.rong.loliasm.common.forgefixes.mixins", + "plugin": "zone.rong.loliasm.core.LoliMixinPlugin", "refmap": "mixins.loliasm.refmap.json", "target": "@env(DEFAULT)", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", "mixins": [ + "ChunkMixin", "ForgeEventFactoryMixin" ] } \ No newline at end of file