Skip to content

Commit 54e0c52

Browse files
committed
Fix #1: Early class loading in MI mixin plugin
1 parent 4aabe66 commit 54e0c52

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/java/net/swedz/tesseract/neoforge/TesseractMod.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ResourceLocation id(String path)
2626

2727
public TesseractMod(IEventBus bus)
2828
{
29-
if(isMILoaded())
29+
if(ModLoadedHelper.isLoaded("modern_industrialization"))
3030
{
3131
MIOnly.init(bus);
3232
}
@@ -35,11 +35,6 @@ public TesseractMod(IEventBus bus)
3535
event.getGenerator().addProvider(event.includeClient(), new LanguageDatagenProvider(event)));
3636
}
3737

38-
public static boolean isMILoaded()
39-
{
40-
return ModLoadedHelper.isLoaded("modern_industrialization");
41-
}
42-
4338
private static final class MIOnly
4439
{
4540
private static void init(IEventBus bus)

src/main/java/net/swedz/tesseract/neoforge/compat/mi/MIMixinPlugin.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
import net.neoforged.neoforgespi.language.IModInfo;
66
import net.neoforged.neoforgespi.language.ModFileScanData;
77
import net.neoforged.neoforgespi.locating.IModFile;
8-
import net.swedz.tesseract.neoforge.TesseractMod;
8+
import net.swedz.tesseract.neoforge.compat.ModLoadedHelper;
99
import net.swedz.tesseract.neoforge.compat.mi.hook.MIHookEfficiency;
1010
import net.swedz.tesseract.neoforge.compat.mi.hook.MIHookListener;
1111
import net.swedz.tesseract.neoforge.compat.mi.hook.MIHookRegistry;
1212
import net.swedz.tesseract.neoforge.compat.mi.hook.MIHooks;
1313
import net.swedz.tesseract.neoforge.compat.mi.hook.TesseractMIHookEntrypoint;
1414
import org.objectweb.asm.Type;
1515
import org.objectweb.asm.tree.ClassNode;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
1618
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
1719
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
1820

@@ -24,6 +26,8 @@
2426

2527
public final class MIMixinPlugin implements IMixinConfigPlugin
2628
{
29+
private static final Logger LOGGER = LoggerFactory.getLogger("Tesseract API/MIMixinPlugin");
30+
2731
private <H> boolean registerEntrypoint(ModFileScanData data, Class<?> entrypointClass, Class<H> hookClass, BiConsumer<String, H> register) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException
2832
{
2933
if(hookClass.isAssignableFrom(entrypointClass))
@@ -51,6 +55,7 @@ private List<ModFileScanData> getAllScanData()
5155
@Override
5256
public void onLoad(String mixinPackage)
5357
{
58+
LOGGER.info("Starting MI hook entrypoint loader");
5459
Type entrypointType = Type.getType(TesseractMIHookEntrypoint.class);
5560
for(ModFileScanData data : this.getAllScanData())
5661
{
@@ -79,16 +84,17 @@ else if(this.registerEntrypoint(data, entrypointClass, MIHookEfficiency.class, M
7984

8085
if(!registered)
8186
{
82-
TesseractMod.LOGGER.error("TesseractMIHookEntrypoint {} does not implement a valid hook entrypoint", annotation.memberName());
87+
LOGGER.error("TesseractMIHookEntrypoint {} does not implement a valid hook entrypoint", annotation.memberName());
8388
}
8489
}
8590
}
8691
catch (Throwable ex)
8792
{
88-
TesseractMod.LOGGER.error("Exception constructing entrypoint:", ex);
93+
LOGGER.error("Exception constructing entrypoint:", ex);
8994
}
9095
}
9196
}
97+
LOGGER.info("Done MI hook entrypoint loader");
9298
}
9399

94100
@Override
@@ -100,7 +106,7 @@ public String getRefMapperConfig()
100106
@Override
101107
public boolean shouldApplyMixin(String targetClassName, String mixinClassName)
102108
{
103-
return TesseractMod.isMILoaded();
109+
return ModLoadedHelper.isLoaded("modern_industrialization");
104110
}
105111

106112
@Override

0 commit comments

Comments
 (0)