mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-23 16:58:30 +01:00
Automatically close GameMode selection screen in <= c0.28-c0.30
This commit is contained in:
parent
51538b6fc7
commit
54f8ad9619
@ -17,12 +17,11 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -34,7 +33,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GameModeSelectionScreen.class)
|
||||
public class MixinGameModeSelectionScreen {
|
||||
public class MixinGameModeSelectionScreen extends Screen {
|
||||
|
||||
@Mutable
|
||||
@Shadow @Final private static int UI_WIDTH;
|
||||
@ -42,6 +41,10 @@ public class MixinGameModeSelectionScreen {
|
||||
@Unique
|
||||
private GameModeSelectionScreen.GameModeSelection[] viafabricplus_unwrappedGameModes;
|
||||
|
||||
public MixinGameModeSelectionScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
public void fixUIWidth(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThan(VersionEnum.r1_8)) {
|
||||
@ -55,6 +58,13 @@ public class MixinGameModeSelectionScreen {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At("HEAD"))
|
||||
public void disableInClassic(CallbackInfo ci) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { // survival mode was added in a1.0.15
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
@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)) {
|
||||
|
@ -18,12 +18,9 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@ -66,9 +63,7 @@ public class MixinGameModeSelectionScreen_GameModeSelection {
|
||||
cir.setReturnValue(Optional.of(GameModeSelectionScreen.GameModeSelection.ADVENTURE));
|
||||
}
|
||||
}
|
||||
case ADVENTURE -> {
|
||||
cir.setReturnValue(Optional.of(CREATIVE));
|
||||
}
|
||||
case ADVENTURE -> cir.setReturnValue(Optional.of(CREATIVE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user