Cleaned code.

This commit is contained in:
FlorianMichael 2023-11-28 00:02:50 +01:00
parent ebf1075155
commit 5725345aef
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 5 additions and 7 deletions

View File

@ -47,15 +47,13 @@ public class MixinGameModeSelectionScreen extends Screen {
@Inject(method = "<init>", 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<GameModeSelectionScreen.GameModeSelection> 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();

View File

@ -53,7 +53,7 @@ public class MixinGameModeSelectionScreen_GameModeSelection {
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
private void unwrapGameModes(CallbackInfoReturnable<GameModeSelectionScreen.GameModeSelection> 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 -> {