Merge remote-tracking branch 'origin/main' into recode/3.0.0

# Conflicts:
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java
#	src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen_GameModeSelection.java
This commit is contained in:
FlorianMichael 2023-11-28 00:06:15 +01:00
commit ae6e117698
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 13 additions and 11 deletions

View File

@ -51,11 +51,13 @@ public abstract class MixinGameModeSelectionScreen extends Screen {
@Inject(method = "<init>", at = @At("RETURN")) @Inject(method = "<init>", at = @At("RETURN"))
private void fixUIWidth(CallbackInfo ci) { private 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()); 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.ADVENTURE); gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
}
viaFabricPlus$unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new); viaFabricPlus$unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
UI_WIDTH = viaFabricPlus$unwrappedGameModes.length * 31 - 5; UI_WIDTH = viaFabricPlus$unwrappedGameModes.length * 31 - 5;
@ -64,7 +66,7 @@ public abstract 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;")) @Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
private GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() { private GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
return viaFabricPlus$unwrappedGameModes; return viaFabricPlus$unwrappedGameModes;
} }

View File

@ -45,18 +45,18 @@ public abstract class MixinGameModeSelectionScreen_GameModeSelection {
public static GameModeSelectionScreen.GameModeSelection CREATIVE; public static GameModeSelectionScreen.GameModeSelection CREATIVE;
@Inject(method = "next", at = @At("HEAD"), cancellable = true) @Inject(method = "next", at = @At("HEAD"), cancellable = true)
private void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) { 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) { switch ((GameModeSelectionScreen.GameModeSelection) (Object) this) {
case CREATIVE -> cir.setReturnValue(Optional.of(SURVIVAL)); case CREATIVE -> cir.setReturnValue(SURVIVAL);
case SURVIVAL -> { case SURVIVAL -> {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_2_4tor1_2_5)) { if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
cir.setReturnValue(Optional.of(CREATIVE)); cir.setReturnValue(CREATIVE);
} else { } else {
cir.setReturnValue(Optional.of(GameModeSelectionScreen.GameModeSelection.ADVENTURE)); cir.setReturnValue(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
} }
} }
case ADVENTURE -> cir.setReturnValue(Optional.of(CREATIVE)); case ADVENTURE -> cir.setReturnValue(CREATIVE);
} }
} }
} }