diff --git a/src/main/java/net/irisshaders/iris/Iris.java b/src/main/java/net/irisshaders/iris/Iris.java index 324184b3d5..94a615bcb8 100644 --- a/src/main/java/net/irisshaders/iris/Iris.java +++ b/src/main/java/net/irisshaders/iris/Iris.java @@ -3,7 +3,6 @@ import com.google.common.base.Throwables; import com.mojang.blaze3d.platform.GlDebug; import com.mojang.blaze3d.platform.InputConstants; -import com.sun.jna.platform.unix.LibC; import net.irisshaders.iris.compat.dh.DHCompat; import net.irisshaders.iris.config.IrisConfig; import net.irisshaders.iris.gl.GLDebug; @@ -28,27 +27,26 @@ import net.irisshaders.iris.texture.pbr.PBRTextureManager; import net.minecraft.ChatFormatting; import net.minecraft.SharedConstants; -import net.minecraft.Util; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.ConfigScreenHandler; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.IExtensionPoint; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.fml.loading.FMLPaths; -import net.minecraftforge.network.NetworkConstants; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFW; -import org.lwjgl.system.Configuration; import java.io.IOException; import java.io.InputStream; @@ -68,10 +66,8 @@ import java.util.zip.ZipError; import java.util.zip.ZipException; -@Mod(Iris.MODID) +@EventBusSubscriber(bus = Bus.MOD, modid = Oculus.MODID, value = Dist.CLIENT) public class Iris { - public static final String MODID = "oculus"; - /** * The user-facing name of the mod. Moved into a constant to facilitate * easy branding changes (for forks). You'll still need to change this @@ -106,26 +102,21 @@ public class Iris { private static String IRIS_VERSION; private static boolean fallback; - public Iris() { - try { - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onKeyRegister); - MinecraftForge.EVENT_BUS.addListener(this::onKeyInput); - - IRIS_VERSION = ModList.get().getModContainerById(MODID).get().getModInfo().getVersion().toString(); - - ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((mc, screen) -> new ShaderPackScreen(screen))); - ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true)); - }catch (Exception ignored) { - } + @SubscribeEvent + public static void onInitializeClient(FMLClientSetupEvent event) { + IRIS_VERSION = ModList.get().getModContainerById(Oculus.MODID).get().getModInfo().getVersion().toString(); + ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((mc, screen) -> new ShaderPackScreen(screen))); + MinecraftForge.EVENT_BUS.addListener(Iris::onKeyInput); } - public void onKeyRegister(RegisterKeyMappingsEvent event) { + @SubscribeEvent + public static void onKeyRegister(RegisterKeyMappingsEvent event) { event.register(reloadKeybind); event.register(toggleShadersKeybind); event.register(shaderpackScreenKeybind); } - public void onKeyInput(InputEvent.Key event) { + public static void onKeyInput(InputEvent.Key event) { handleKeybinds(Minecraft.getInstance()); } @@ -743,7 +734,7 @@ public static void onEarlyInitialize() { logger.warn("", e); } - irisConfig = new IrisConfig(FMLPaths.CONFIGDIR.get().resolve(MODID + ".properties")); + irisConfig = new IrisConfig(FMLPaths.CONFIGDIR.get().resolve(Oculus.MODID + ".properties")); try { irisConfig.initialize(); diff --git a/src/main/java/net/irisshaders/iris/Oculus.java b/src/main/java/net/irisshaders/iris/Oculus.java new file mode 100644 index 0000000000..30dddccc50 --- /dev/null +++ b/src/main/java/net/irisshaders/iris/Oculus.java @@ -0,0 +1,15 @@ +package net.irisshaders.iris; + +import net.minecraftforge.fml.IExtensionPoint; +import net.minecraftforge.fml.ModLoadingContext; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.network.NetworkConstants; + +@Mod(Oculus.MODID) +public class Oculus { + public static final String MODID = "oculus"; + + public Oculus() { + ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true)); + } +}