diff --git a/src/main/java/com/mitchej123/hodgepodge/config/FixesConfig.java b/src/main/java/com/mitchej123/hodgepodge/config/FixesConfig.java index ea9b0bf1..05234e4c 100644 --- a/src/main/java/com/mitchej123/hodgepodge/config/FixesConfig.java +++ b/src/main/java/com/mitchej123/hodgepodge/config/FixesConfig.java @@ -419,6 +419,13 @@ public class FixesConfig { @Config.RequiresMcRestart public static boolean fixCandycraftBlockSugarNPE; + // Cofh + + @Config.Comment("Fix NPE in COFH's oredict") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean fixCofhOreDictNPE; + // Extra TiC @Config.Comment("Disable ExtraTic's Integration with Metallurgy 3 Precious Materials Module: (Brass, Silver, Electrum & Platinum)") diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java index 1562611a..41401a2c 100644 --- a/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java @@ -579,6 +579,9 @@ public enum Mixins { .addMixinClasses("thermalexpansion.MixinTileInventoryTileLightFalse") .addTargetedMod(TargetedMod.THERMALEXPANSION).setApplyIf(() -> ASMConfig.cofhWorldTransformer) .setPhase(Phase.LATE).setSide(Side.BOTH)), + FIX_ORE_DICT_NPE(new Builder("Fix NPE in OreDictionaryArbiter") + .addMixinClasses("cofhcore.MixinOreDictionaryArbiter").setPhase(Phase.EARLY).setSide(Side.BOTH) + .addTargetedMod(TargetedMod.COFH_CORE).setApplyIf(() -> FixesConfig.fixCofhOreDictNPE)), // Immersive engineering JAVA12_IMMERSIVE_ENGINERRING(new Builder("Immersive Engineering Java-12 safe potion array resizing") diff --git a/src/main/java/com/mitchej123/hodgepodge/mixins/early/cofhcore/MixinOreDictionaryArbiter.java b/src/main/java/com/mitchej123/hodgepodge/mixins/early/cofhcore/MixinOreDictionaryArbiter.java new file mode 100644 index 00000000..000c7a88 --- /dev/null +++ b/src/main/java/com/mitchej123/hodgepodge/mixins/early/cofhcore/MixinOreDictionaryArbiter.java @@ -0,0 +1,22 @@ +package com.mitchej123.hodgepodge.mixins.early.cofhcore; + +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.callback.CallbackInfo; + +import cofh.core.util.oredict.OreDictionaryArbiter; + +@Mixin(OreDictionaryArbiter.class) +public class MixinOreDictionaryArbiter { + + @Inject(method = "registerOreDictionaryEntry", at = @At("HEAD"), cancellable = true, remap = false) + private static void hodgepodge$fixNPE(ItemStack stack, String s, CallbackInfo ci) { + if (stack == null) { + ci.cancel(); + } + } + +}