Skip to content

Commit

Permalink
Prevent crashing on servers
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen committed May 11, 2024
1 parent 4509954 commit 4af4aca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
39 changes: 15 additions & 24 deletions src/main/java/net/irisshaders/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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();
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/irisshaders/iris/Oculus.java
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit 4af4aca

Please sign in to comment.