From 3d24002aac532382f664313e0d49ddd8a7899f5a Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:24:15 -0800 Subject: [PATCH] Fix display test - Improve version retrieval - Fix extra description newline --- .../java/com/jozufozu/flywheel/Flywheel.java | 37 +++++++++++-------- src/main/resources/META-INF/mods.toml | 7 ++-- 2 files changed, 24 insertions(+), 20 deletions(-) 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"