Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed May 15, 2024
1 parent 4f73237 commit 2b071f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Function<Runnable, Screen>> output, CallbackInfo ci) {
if (WorldHostTesting.ENABLED) {
ci.cancel();
}
}
//#endif

//#if MC < 1.19.4
//$$ @Inject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down Expand Up @@ -70,7 +80,11 @@ public static AbstractWidget findWidgetByString(Predicate<String> 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 + "\""
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/world-host.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"MixinWorldSelectionList_WorldListEntry",
"PlainTextButtonAccessor",
"ServerStatusPingerAccessor",
//#if FABRIC
"modmenu.MixinModMenuEventHandler"
//#endif
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 2b071f9

Please sign in to comment.