From 5725345aef6359c74da73947579caa1b91fad838 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Tue, 28 Nov 2023 00:02:50 +0100 Subject: [PATCH] Cleaned code. --- .../minecraft/screen/MixinGameModeSelectionScreen.java | 10 ++++------ ...MixinGameModeSelectionScreen_GameModeSelection.java | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java index 5fe4c71e..ee1de77a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java @@ -47,15 +47,13 @@ public class MixinGameModeSelectionScreen extends Screen { @Inject(method = "", at = @At("RETURN")) public void fixUIWidth(CallbackInfo ci) { - if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { final List gameModeSelections = new ArrayList<>(Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList()); - if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_3_1tor1_3_2)) { + gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) { gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE); } - if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) { - gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); - } viafabricplus_unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new); UI_WIDTH = viafabricplus_unwrappedGameModes.length * 31 - 5; @@ -71,7 +69,7 @@ public class MixinGameModeSelectionScreen extends Screen { @Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;")) public GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() { - if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { return viafabricplus_unwrappedGameModes; } return GameModeSelectionScreen.GameModeSelection.values(); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen_GameModeSelection.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen_GameModeSelection.java index 55201022..3e8b160d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen_GameModeSelection.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen_GameModeSelection.java @@ -53,7 +53,7 @@ public class MixinGameModeSelectionScreen_GameModeSelection { @Inject(method = "next", at = @At("HEAD"), cancellable = true) private void unwrapGameModes(CallbackInfoReturnable cir) { - if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) { + if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) { switch ((GameModeSelectionScreen.GameModeSelection) (Object) this) { case CREATIVE -> cir.setReturnValue(SURVIVAL); case SURVIVAL -> {