mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-29 13:06:00 +01:00
Fixed crash when using the F3 + F4 menu in <= 1.8
This commit is contained in:
parent
9d33bd9431
commit
ebf1075155
@ -50,8 +50,12 @@ public class MixinGameModeSelectionScreen extends Screen {
|
|||||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||||
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);
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_3_1tor1_3_2)) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
|
gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
|
||||||
|
}
|
||||||
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||||
|
gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -52,18 +52,18 @@ public class MixinGameModeSelectionScreen_GameModeSelection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "next", at = @At("HEAD"), cancellable = true)
|
||||||
public void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) {
|
private void unwrapGameModes(CallbackInfoReturnable<GameModeSelectionScreen.GameModeSelection> cir) {
|
||||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user