Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into recode/3.0.0
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
FlorianMichael committed Nov 27, 2023
2 parents 371065a + 5725345 commit ae6e117
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public MixinGameModeSelectionScreen(Text title) {

@Inject(method = "<init>", at = @At("RETURN"))
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());

if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_3_1tor1_3_2)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR);
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);
UI_WIDTH = viaFabricPlus$unwrappedGameModes.length * 31 - 5;
Expand All @@ -64,7 +66,7 @@ private void fixUIWidth(CallbackInfo ci) {

@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() {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
return viaFabricPlus$unwrappedGameModes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public abstract class MixinGameModeSelectionScreen_GameModeSelection {
public static GameModeSelectionScreen.GameModeSelection CREATIVE;

@Inject(method = "next", at = @At("HEAD"), cancellable = true)
private void unwrapGameModes(CallbackInfoReturnable<Optional<GameModeSelectionScreen.GameModeSelection>> cir) {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
private void unwrapGameModes(CallbackInfoReturnable<GameModeSelectionScreen.GameModeSelection> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_7_6tor1_7_10)) {
switch ((GameModeSelectionScreen.GameModeSelection) (Object) this) {
case CREATIVE -> cir.setReturnValue(Optional.of(SURVIVAL));
case CREATIVE -> cir.setReturnValue(SURVIVAL);
case SURVIVAL -> {
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_2_4tor1_2_5)) {
cir.setReturnValue(Optional.of(CREATIVE));
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_2_4tor1_2_5)) {
cir.setReturnValue(CREATIVE);
} 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);
}
}
}
Expand Down

0 comments on commit ae6e117

Please sign in to comment.