Fix display test

- Improve version retrieval
- Fix extra description newline
This commit is contained in:
PepperCode1 2022-03-12 14:24:15 -08:00
parent 0c74be53f6
commit 3d24002aac
2 changed files with 24 additions and 20 deletions

View file

@ -25,11 +25,12 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.CrashReportCallables; import net.minecraftforge.fml.CrashReportCallables;
import net.minecraftforge.fml.DistExecutor; 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.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.network.NetworkConstants;
@Mod(Flywheel.ID) @Mod(Flywheel.ID)
public class Flywheel { public class Flywheel {
@ -39,29 +40,36 @@ public class Flywheel {
private static ArtifactVersion version; private static ArtifactVersion version;
public Flywheel() { public Flywheel() {
IModFileInfo modFileById = ModList.get() ModLoadingContext modLoadingContext = ModLoadingContext.get();
.getModFileById(ID);
version = modFileById.getMods() version = modLoadingContext
.get(0) .getActiveContainer()
.getModInfo()
.getVersion(); .getVersion();
FMLJavaModLoadingContext.get() IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
.getModEventBus() IEventBus modEventBus = FMLJavaModLoadingContext.get()
.addListener(Flywheel::setup); .getModEventBus();
modEventBus.addListener(Flywheel::setup);
FlwConfig.init(); 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); CrashReportCallables.registerCrashCallable("Flywheel Backend", Backend::getBackendDescriptor);
OptifineHandler.init(); OptifineHandler.init();
Backend.init(); Backend.init();
IEventBus modEventBus = FMLJavaModLoadingContext.get()
.getModEventBus(); forgeEventBus.addListener(FlwCommands::registerClientCommands);
forgeEventBus.<ReloadRenderersEvent>addListener(ProgramCompiler::invalidateAll);
modEventBus.addListener(Contexts::flwInit); modEventBus.addListener(Contexts::flwInit);
modEventBus.addListener(PartialModel::onModelRegistry); modEventBus.addListener(PartialModel::onModelRegistry);
@ -69,9 +77,6 @@ public class Flywheel {
modEventBus.addListener(StitchedSprite::onTextureStitchPre); modEventBus.addListener(StitchedSprite::onTextureStitchPre);
modEventBus.addListener(StitchedSprite::onTextureStitchPost); modEventBus.addListener(StitchedSprite::onTextureStitchPost);
MinecraftForge.EVENT_BUS.addListener(FlwCommands::registerClientCommands);
MinecraftForge.EVENT_BUS.<ReloadRenderersEvent>addListener(ProgramCompiler::invalidateAll);
VanillaInstances.init(); VanillaInstances.init();
// https://github.com/Jozufozu/Flywheel/issues/69 // https://github.com/Jozufozu/Flywheel/issues/69

View file

@ -7,12 +7,11 @@ license = "MIT"
modId = "flywheel" modId = "flywheel"
version = "${file.jarVersion}" version = "${file.jarVersion}"
displayName = "Flywheel" displayName = "Flywheel"
logoFile="logo.png" logoFile = "logo.png"
displayURL = "https://www.curseforge.com/minecraft/mc-mods/flywheel" displayURL = "https://www.curseforge.com/minecraft/mc-mods/flywheel"
authors="Jozufozu" authors = "Jozufozu"
description = ''' description = '''
A modern engine for modded minecraft. A modern engine for modded minecraft.'''
'''
[[dependencies.flywheel]] [[dependencies.flywheel]]
modId = "forge" modId = "forge"