From 2b071f94dbae260a1dc99bd38cdd39041a8a1e05 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Tue, 14 May 2024 23:20:55 -0500 Subject: [PATCH] Fix compile errors --- .../gaming32/worldhost/mixin/MixinMinecraft.java | 2 ++ .../gaming32/worldhost/testing/MinecraftApi.java | 16 +++++++++++++++- src/main/resources/world-host.mixins.json | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinMinecraft.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinMinecraft.java index b7511e9..fdf4a74 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinMinecraft.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinMinecraft.java @@ -73,12 +73,14 @@ private void postTick(CallbackInfo ci) { WorldHost.tickHandler(); } + //#if MC >= 1.20.2 @Inject(method = "addInitialScreens", at = @At("HEAD"), cancellable = true) private void noOnboardingWhileTesting(List> output, CallbackInfo ci) { if (WorldHostTesting.ENABLED) { ci.cancel(); } } + //#endif //#if MC < 1.19.4 //$$ @Inject( diff --git a/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java b/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java index 63727a1..0a3520f 100644 --- a/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java +++ b/src/main/java/io/github/gaming32/worldhost/testing/MinecraftApi.java @@ -8,17 +8,27 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.contents.TranslatableContents; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Stream; +//#if MC >= 1.19.2 +import net.minecraft.network.chat.contents.TranslatableContents; +//#else +//$$ import net.minecraft.network.chat.TranslatableComponent; +//#endif + public class MinecraftApi { public static void click(AbstractWidget widget) { click( + //#if MC > 1.19.2 widget.getX() + widget.getWidth() / 2.0, widget.getY() + widget.getHeight() / 2.0 + //#else + //$$ widget.x + widget.getWidth() / 2.0, + //$$ widget.x + widget.getHeight() / 2.0 + //#endif ); } @@ -70,7 +80,11 @@ public static AbstractWidget findWidgetByString(Predicate messageMatcher public static AbstractWidget findWidgetByTranslation(String translation) { return findWidget( + //#if MC >= 1.19.2 c -> c.getContents() instanceof TranslatableContents translatable && translatable.getKey().equals(translation), + //#else + //$$ c -> c instanceof TranslatableComponent translatable && translatable.getKey().equals(translation), + //#endif "Could not find widget with translation key \"" + translation + "\"" ); } diff --git a/src/main/resources/world-host.mixins.json b/src/main/resources/world-host.mixins.json index 82ca843..cf08336 100644 --- a/src/main/resources/world-host.mixins.json +++ b/src/main/resources/world-host.mixins.json @@ -29,7 +29,9 @@ "MixinWorldSelectionList_WorldListEntry", "PlainTextButtonAccessor", "ServerStatusPingerAccessor", + //#if FABRIC "modmenu.MixinModMenuEventHandler" + //#endif ], "injectors": { "defaultRequire": 1