Skip to content

Commit

Permalink
3.1 - Fixes CME/SOE issue pertaining GregTechCE/GregTech#1256
Browse files Browse the repository at this point in the history
- Easy patch, but doesn't exactly fix the root of the issue
- But seems like entities loading were done in the same way...
  • Loading branch information
Rongmario committed Oct 7, 2021
1 parent 8738da5 commit d7fa000
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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<TileEntity> copiedValues(Map<BlockPos, TileEntity> map) {
return new ArrayList<>(map.values());
}

}
3 changes: 2 additions & 1 deletion src/main/java/zone/rong/loliasm/config/LoliConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/zone/rong/loliasm/core/LoliLoadingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/zone/rong/loliasm/core/LoliMixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,7 +13,9 @@
public class LoliMixinPlugin implements IMixinConfigPlugin {

static {
BakedQuadRedirectorFactory.generateRedirectorClass();
if (LoliConfig.instance.squashBakedQuads) {
BakedQuadRedirectorFactory.generateRedirectorClass();
}
}

@Override
Expand All @@ -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;
}

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/zone/rong/loliasm/core/LoliTransformer.java
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/mixins.forgefixes.json
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit d7fa000

Please sign in to comment.