fix: NeoForge 1.21.5 compat

Why tf does NeoForge change the MinecraftClient instance...
This commit is contained in:
Martin Prokoph
2025-03-29 15:02:39 +01:00
parent eac8b24617
commit 16f5c08011
4 changed files with 9 additions and 8 deletions

View File

@@ -21,10 +21,9 @@ public class PuzzleGui {
public static void init() {
MidnightLib.hiddenMods.add("puzzle");
MinecraftClient client = MinecraftClient.getInstance();
PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.of("\uD83E\uDDE9 Puzzle")));
PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.translatable("puzzle.midnightconfig.title"), (button) -> button.setMessage(Text.of("OPEN")), (button) -> {
client.setScreen(PuzzleConfig.getScreen(client.currentScreen, "puzzle"));
MinecraftClient.getInstance().setScreen(PuzzleConfig.getScreen(MinecraftClient.getInstance().currentScreen, "puzzle"));
}));
PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.of("\uD83E\uDDE9 Puzzle")));
PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.resourcepack_splash_screen"), (button) -> button.setMessage(PuzzleConfig.resourcepackSplashScreen ? YES : NO), (button) -> {

View File

@@ -33,7 +33,7 @@ public class PuzzleSplashScreen {
public static File CONFIG_PATH = new File(String.valueOf(PlatformFunctions.getConfigDirectory().resolve(".puzzle_cache")));
public static Path LOGO_TEXTURE = Paths.get(CONFIG_PATH + "/mojangstudios.png");
public static Path BACKGROUND_TEXTURE = Paths.get(CONFIG_PATH + "/splash_background.png");
private static final MinecraftClient client = MinecraftClient.getInstance();
private static MinecraftClient client = MinecraftClient.getInstance();
private static boolean keepBackground = false;
public static void init() {
@@ -55,6 +55,7 @@ public class PuzzleSplashScreen {
@Override
public void reload(ResourceManager manager) {
client = MinecraftClient.getInstance();
if (PuzzleConfig.resourcepackSplashScreen) {
PuzzleSplashScreen.resetColors();
client.getTextureManager().registerTexture(LOGO, new LogoTexture(LOGO));

View File

@@ -7,7 +7,7 @@ yarn_mappings=1.21.5+build.1
enabled_platforms=fabric,neoforge
# Mod Properties
mod_version = 2.0.5
mod_version = 2.0.6
maven_group = net.puzzlemc
archives_base_name = puzzle
release_type=release
@@ -18,7 +18,7 @@ modrinth_id=3IuO68q1
fabric_loader_version=0.16.10
fabric_api_version=0.119.5+1.21.5
neoforge_version=21.5.0-beta
neoforge_version=21.5.3-beta
yarn_mappings_patch_neoforge_version = 1.21+build.4
# Libraries

View File

@@ -1,11 +1,12 @@
package net.puzzlemc.neoforge;
import net.minecraft.util.Identifier;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.puzzlemc.core.PuzzleCore;
import net.puzzlemc.gui.screen.PuzzleOptionsScreen;
@@ -23,8 +24,8 @@ public class PuzzleNeoForge {
@EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class MidnightLibBusEvents {
@SubscribeEvent
public static void onResourceReload(RegisterClientReloadListenersEvent event) {
event.registerReloadListener(PuzzleSplashScreen.ReloadListener.INSTANCE);
public static void onResourceReload(AddClientReloadListenersEvent event) {
event.addListener(Identifier.of(MOD_ID, "splash_screen"), PuzzleSplashScreen.ReloadListener.INSTANCE);
}
}
}