diff --git a/src/main/java/com/jozufozu/flywheel/Flywheel.java b/src/main/java/com/jozufozu/flywheel/Flywheel.java index 653aecf7d..05b0e1b02 100644 --- a/src/main/java/com/jozufozu/flywheel/Flywheel.java +++ b/src/main/java/com/jozufozu/flywheel/Flywheel.java @@ -25,11 +25,12 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.CrashReportCallables; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.IExtensionPoint; +import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forgespi.language.IModFileInfo; +import net.minecraftforge.network.NetworkConstants; @Mod(Flywheel.ID) public class Flywheel { @@ -39,29 +40,36 @@ public class Flywheel { private static ArtifactVersion version; public Flywheel() { - IModFileInfo modFileById = ModList.get() - .getModFileById(ID); + ModLoadingContext modLoadingContext = ModLoadingContext.get(); - version = modFileById.getMods() - .get(0) + version = modLoadingContext + .getActiveContainer() + .getModInfo() .getVersion(); - FMLJavaModLoadingContext.get() - .getModEventBus() - .addListener(Flywheel::setup); + IEventBus forgeEventBus = MinecraftForge.EVENT_BUS; + IEventBus modEventBus = FMLJavaModLoadingContext.get() + .getModEventBus(); + modEventBus.addListener(Flywheel::setup); FlwConfig.init(); - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Flywheel::clientInit); + modLoadingContext.registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest( + () -> NetworkConstants.IGNORESERVERONLY, + (serverVersion, isNetwork) -> isNetwork + )); + + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Flywheel.clientInit(forgeEventBus, modEventBus)); } - private static void clientInit() { + private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) { CrashReportCallables.registerCrashCallable("Flywheel Backend", Backend::getBackendDescriptor); OptifineHandler.init(); Backend.init(); - IEventBus modEventBus = FMLJavaModLoadingContext.get() - .getModEventBus(); + + forgeEventBus.addListener(FlwCommands::registerClientCommands); + forgeEventBus.addListener(ProgramCompiler::invalidateAll); modEventBus.addListener(Contexts::flwInit); modEventBus.addListener(PartialModel::onModelRegistry); @@ -69,9 +77,6 @@ public class Flywheel { modEventBus.addListener(StitchedSprite::onTextureStitchPre); modEventBus.addListener(StitchedSprite::onTextureStitchPost); - MinecraftForge.EVENT_BUS.addListener(FlwCommands::registerClientCommands); - MinecraftForge.EVENT_BUS.addListener(ProgramCompiler::invalidateAll); - VanillaInstances.init(); // https://github.com/Jozufozu/Flywheel/issues/69 diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 3ac2d980c..75ea63f15 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -7,12 +7,11 @@ license = "MIT" modId = "flywheel" version = "${file.jarVersion}" displayName = "Flywheel" -logoFile="logo.png" +logoFile = "logo.png" displayURL = "https://www.curseforge.com/minecraft/mc-mods/flywheel" -authors="Jozufozu" +authors = "Jozufozu" description = ''' -A modern engine for modded minecraft. -''' +A modern engine for modded minecraft.''' [[dependencies.flywheel]] modId = "forge"