Skip to content

Commit

Permalink
fix race condition in COFH's oredict initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts committed Jan 3, 2025
1 parent c811df4 commit 303126f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ public class FixesConfig {
@Config.DefaultBoolean(true)
public static boolean fixCofhOreDictNPE;

@Config.Comment("Fix race condition in COFH's oredict")
@Config.DefaultBoolean(true)
public static boolean fixCofhOreDictCME;

// Extra TiC

@Config.Comment("Disable ExtraTic's Integration with Metallurgy 3 Precious Materials Module: (Brass, Silver, Electrum & Platinum)")
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ public enum Mixins {
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)),
FIX_ORE_DICT_CME(new Builder("Fix race condition in CoFH oredict").addMixinClasses("cofhcore.MixinFMLEventHandler")
.setPhase(Phase.EARLY).setSide(Side.CLIENT).addTargetedMod(TargetedMod.COFH_CORE)
.setApplyIf(() -> FixesConfig.fixCofhOreDictCME)),

// Minefactory Reloaded
DISARM_SACRED_TREE(new Builder("Prevents Sacred Rubber Tree Generation")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.mitchej123.hodgepodge.mixins.early.cofhcore;

import net.minecraft.client.Minecraft;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;

import cofh.core.util.FMLEventHandler;

@Mixin(value = FMLEventHandler.class, remap = false)
public abstract class MixinFMLEventHandler {

@WrapWithCondition(
method = "handleIdMappingEvent",
at = @At(value = "INVOKE", target = "Lcofh/core/util/oredict/OreDictionaryArbiter;initialize()V"))
private boolean hodgepodge$fixNPE() {
return !Minecraft.getMinecraft().isSingleplayer();
}
}

0 comments on commit 303126f

Please sign in to comment.