diff --git a/build.gradle.kts b/build.gradle.kts index 6918fc3..101f6b8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,9 +22,6 @@ preprocess { val forge11802 = createNode("1.18.2-forge", 1_18_02, "srg") val fabric11701 = createNode("1.17.1-fabric", 1_17_01, "yarn") val forge11701 = createNode("1.17.1-forge", 1_17_01, "srg") - val fabric11605 = createNode("1.16.5-fabric", 1_16_05, "yarn") - val forge11605 = createNode("1.16.5-forge", 1_16_05, "srg") - val fabric11601 = createNode("1.16.1-fabric", 1_16_01, "yarn") fabric12004.link(neoforge12004) neoforge12004.link(neoforge12002) @@ -39,9 +36,6 @@ preprocess { forge11802.link(fabric11802) fabric11802.link(fabric11701) fabric11701.link(forge11701) - forge11701.link(forge11605) - forge11605.link(fabric11605) - fabric11605.link(fabric11601) // subprojects { // apply(plugin = "java") diff --git a/settings.gradle.kts b/settings.gradle.kts index b7d5fc9..a6d4cf3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,9 +22,6 @@ rootProject.name = "world-host" rootProject.buildFileName = "build.gradle.kts" listOf( - "1.16.1-fabric", - "1.16.5-forge", - "1.16.5-fabric", "1.17.1-forge", "1.17.1-fabric", "1.18.2-forge", diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index aa90769..e620b53 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -123,19 +123,15 @@ //$$ import net.minecraftforge.client.ConfigScreenHandler; //#elseif MC >= 1.18.2 //$$ import net.minecraftforge.client.ConfigGuiHandler; -//#elseif MC >= 1.17.1 -//$$ import net.minecraftforge.fmlclient.ConfigGuiHandler; //#else -//$$ import net.minecraftforge.fml.ExtensionPoint; +//$$ import net.minecraftforge.fmlclient.ConfigGuiHandler; //#endif //#if NEOFORGE //$$ import net.neoforged.neoforge.resource.ResourcePackLoader; //#elseif MC > 1.17.1 //$$ import net.minecraftforge.resource.ResourcePackLoader; -//#elseif MC > 1.16.5 -//$$ import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; //#else -//$$ import net.minecraftforge.fml.packs.ResourcePackLoader; +//$$ import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; //#endif //#endif @@ -247,11 +243,7 @@ private static void init() { }) //#else //$$ ResourcePackLoader - //#if MC > 1.16.5 - //$$ .getPackFor(MOD_ID) - //#else - //$$ .getResourcePackFor(MOD_ID) - //#endif + //$$ .getPackFor(MOD_ID) //#if MC >= 1.20.4 //$$ .map(c -> c.openPrimary("worldhost")) //#endif @@ -304,19 +296,11 @@ private static void init() { ).profileCache(); //#else //$$ profileCache = new GameProfileCache( - //$$ new YggdrasilAuthenticationService( - //$$ Minecraft.getInstance().getProxy() - //#if MC <= 1.16.1 - //$$ , UUID.randomUUID().toString() - //#endif - //$$ ) - //$$ .createProfileRepository(), + //$$ new YggdrasilAuthenticationService(Minecraft.getInstance().getProxy()).createProfileRepository(), //$$ new File(CACHE_DIR, "usercache.json") //$$ ); //#endif - //#if MC > 1.16.5 profileCache.setExecutor(Util.backgroundExecutor()); - //#endif reconnect(false, true); @@ -536,10 +520,8 @@ public static ResourceLocation getSkinLocationNow(GameProfile gameProfile) { public static void getMaybeAsync(GameProfileCache cache, String name, Consumer> action) { //#if MC >= 1.20.2 cache.getAsync(name).thenAccept(action); - //#elseif MC > 1.16.5 - //$$ cache.getAsync(name, action); //#else - //$$ action.accept(Optional.ofNullable(cache.get(name))); + //$$ cache.getAsync(name, action); //#endif } @@ -563,25 +545,6 @@ public static GameProfile fetchProfile(MinecraftSessionService sessionService, G return fetchProfile(sessionService, profile.getId(), profile); } - public static void texture(ResourceLocation texture) { - //#if MC > 1.16.5 - RenderSystem.setShaderTexture(0, texture); - //#else - //$$ Minecraft.getInstance().getTextureManager().bind(texture); - //#endif - } - - //#if MC <= 1.16.5 - //$$ @SuppressWarnings("deprecation") - //#endif - public static void color(float r, float g, float b, float a) { - //#if MC > 1.16.5 - RenderSystem.setShaderColor(r, g, b, a); - //#else - //$$ RenderSystem.color4f(r, g, b, a); - //#endif - } - public static boolean isFriend(UUID user) { return CONFIG.isEnableFriends() && CONFIG.getFriends().contains(user); } @@ -611,18 +574,12 @@ public static FriendlyByteBuf createByteBuf() { @SuppressWarnings("RedundantThrows") public static ServerStatus parseServerStatus(FriendlyByteBuf buf) throws IOException { - //#if MC > 1.16.5 return new ClientboundStatusResponsePacket(buf) //#if MC >= 1.19.4 .status(); //#else //$$ .getStatus(); //#endif - //#else - //$$ final ClientboundStatusResponsePacket packet = new ClientboundStatusResponsePacket(); - //$$ packet.read(buf); - //$$ return packet.getStatus(); - //#endif } public static ServerStatus createEmptyServerStatus() { @@ -724,7 +681,6 @@ public static void join(long connectionId, @Nullable Screen parentScreen) { public static void connect(Screen parentScreen, long cid, String host, int port) { final Minecraft minecraft = Minecraft.getInstance(); - //#if MC > 1.16.5 final ServerAddress serverAddress = new ServerAddress(host, port); ConnectScreen.startConnecting( parentScreen, minecraft, serverAddress, @@ -741,10 +697,6 @@ public static void connect(Screen parentScreen, long cid, String host, int port) ), false //#endif ); - //#else - //$$ minecraft.setCurrentServer(null); - //$$ minecraft.setScreen(new ConnectScreen(parentScreen, minecraft, host, port)); - //#endif } private static int ipCommand(CommandContext ctx) { @@ -923,11 +875,9 @@ public static CompletableFuture> checkForUpdates() { //#if MC >= 1.19.2 //$$ ConfigScreenHandler.ConfigScreenFactory.class, //$$ () -> new ConfigScreenHandler.ConfigScreenFactory(screenFunction) - //#elseif MC >= 1.17.1 + //#else //$$ ConfigGuiHandler.ConfigGuiFactory.class, //$$ () -> new ConfigGuiHandler.ConfigGuiFactory(screenFunction) - //#else - //$$ ExtensionPoint.CONFIGGUIFACTORY, () -> screenFunction //#endif //$$ ); //$$ } diff --git a/src/main/java/io/github/gaming32/worldhost/compat/WorldHostModMenuCompat.java b/src/main/java/io/github/gaming32/worldhost/compat/WorldHostModMenuCompat.java index 0437761..eb9a060 100644 --- a/src/main/java/io/github/gaming32/worldhost/compat/WorldHostModMenuCompat.java +++ b/src/main/java/io/github/gaming32/worldhost/compat/WorldHostModMenuCompat.java @@ -1,15 +1,9 @@ //#if FABRIC package io.github.gaming32.worldhost.compat; -import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen; - -//#if MC > 1.16.1 import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; -//#else -//$$ import io.github.prospector.modmenu.api.ConfigScreenFactory; -//$$ import io.github.prospector.modmenu.api.ModMenuApi; -//#endif +import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen; public class WorldHostModMenuCompat implements ModMenuApi { @Override diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java index eea095e..c056c00 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/AddFriendScreen.java @@ -174,7 +174,7 @@ public void render( if (friendProfile != null) { assert minecraft != null; final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(friendProfile); - WorldHost.color(1f, 1f, 1f, 1f); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); final int size = addFriendButton.getY() - 110; final int x = width / 2 - size / 2; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java index 6afd64e..cfea256 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/FriendsScreen.java @@ -61,11 +61,9 @@ protected void init() { if (list == null) { list = new FriendsList(); - //#if MC > 1.16.1 if (minecraft != null && minecraft.level != null) { list.setRenderBackground(false); } - //#endif } setListSize(list, 32, WorldHost.BEDROCK_SUPPORT ? 80 : 64); addWidget(list); @@ -174,7 +172,6 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { public class FriendsList extends ObjectSelectionList { public FriendsList() { - //noinspection DataFlowIssue super( FriendsScreen.this.minecraft, //#if MC >= 1.20.3 @@ -240,13 +237,11 @@ public FriendsEntry(GameProfile profile) { ); } - //#if MC > 1.16.5 @NotNull @Override public Component getNarration() { return Components.immutable(getName()); } - //#endif @Override public void render( @@ -259,7 +254,7 @@ public void render( int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta ) { final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(profile); - WorldHost.color(1f, 1f, 1f, 1f); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); blit(context, skinTexture, x, y, 32, 32, 8, 8, 8, 8, 64, 64); blit(context, skinTexture, x, y, 32, 32, 40, 8, 8, 8, 64, 64); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java index 1199b1a..606951b 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/OnlineFriendsScreen.java @@ -226,7 +226,6 @@ public void friendsListUpdate(Map friends) { public class OnlineFriendsList extends ObjectSelectionList { public OnlineFriendsList() { - //noinspection DataFlowIssue super( OnlineFriendsScreen.this.minecraft, //#if MC >= 1.20.3 @@ -311,13 +310,11 @@ public OnlineFriendsListEntry(UUID friendUuid, long connectionId) { iconTextureId = new ResourceLocation("world-host", "servers/" + friendUuid + "/icon"); } - //#if MC >= 1.17.0 @NotNull @Override public Component getNarration() { return Components.translatable("narrator.select", getName()); } - //#endif @Override public void render( @@ -345,7 +342,7 @@ public void render( final int labelWidth = font.width(sideLabel); WorldHostScreen.drawString(context, font, sideLabel, x + entryWidth - labelWidth - 17, y + 1, 0x808080, false); - WorldHost.color(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); if (incompatibleVersion) { RenderSystem.enableBlend(); blit(context, GUI_ICONS_LOCATION, x + entryWidth - 15, y, 0, 216, 10, 8, 256, 256); @@ -364,7 +361,6 @@ public void render( } else { //#if MC >= 1.19.4 // Mojang did "@Nullable byte[]" instead of "byte @Nullable []" - //noinspection DataFlowIssue serverInfo.setIconBytes(null); //#else //$$ serverInfo.setIconB64(null); @@ -372,7 +368,6 @@ public void render( } } - // Since when does a value marked as @Nullable never satisfy == null? //noinspection ConstantValue if (icon == null) { final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(profile); @@ -381,7 +376,7 @@ public void render( blit(context, skinTexture, x, y, 32, 32, 40, 8, 8, 8, 64, 64); RenderSystem.disableBlend(); } else { - WorldHost.texture(iconTextureId); + RenderSystem.setShaderTexture(0, iconTextureId); RenderSystem.enableBlend(); blit(context, iconTextureId, x, y, 0, 0, 32, 32, 32, 32); RenderSystem.disableBlend(); @@ -405,7 +400,7 @@ public void render( || hovered ) { fill(context, x, y, x + 32, y + 32, 0xa0909090); - WorldHost.color(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); //#if MC >= 1.20.2 if (relX < 32 && relX > 16) { context.blitSprite(JOIN_HIGHLIGHTED_SPRITE, x, y, 32, 32); @@ -565,13 +560,11 @@ private boolean uploadServerIcon( public boolean mouseClicked(double mouseX, double mouseY, int button) { select(this); - //#if MC > 1.16.1 final double relX = mouseX - list.getRowLeft(); if (relX < 32.0 && relX > 16.0) { connect(); return true; } - //#endif if (Util.getMillis() - clickTime < 250L) { connect(); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java index 0895301..1548b33 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/screen/WorldHostScreen.java @@ -15,7 +15,7 @@ //#if MC >= 1.20.0 import net.minecraft.client.gui.GuiGraphics; //#else -//$$ import io.github.gaming32.worldhost.WorldHost; +//$$ import com.mojang.blaze3d.systems.RenderSystem; //$$ import net.minecraft.client.gui.GuiComponent; //#endif @@ -28,25 +28,14 @@ //$$ import java.util.function.Consumer; //#endif -//#if MC <= 1.16.5 -//$$ import net.minecraft.client.gui.components.AbstractWidget; -//#endif - -//#if MC <= 1.16.1 -//$$ import net.minecraft.network.chat.FormattedText; -//#else import net.minecraft.util.FormattedCharSequence; -//#endif public abstract class WorldHostScreen extends Screen { protected WorldHostScreen(Component component) { super(component); } - //#if MC > 1.16.1 - static - //#endif - public void drawRightString( + public static void drawRightString( //#if MC < 1.20.0 //$$ PoseStack context, //#else @@ -57,12 +46,7 @@ public void drawRightString( drawString(context, font, text, x - font.width(text), y, color); } - //#if MC > 1.16.1 - static - //#else - //$$ @Override - //#endif - public void drawCenteredString( + public static void drawCenteredString( @NotNull //#if MC < 1.20.0 //$$ PoseStack context, @@ -70,20 +54,13 @@ public void drawCenteredString( GuiGraphics context, //#endif Font font, - @NotNull - //#if MC > 11601 - Component text, - //#else - //$$ FormattedText text, - //#endif + @NotNull Component text, int x, int y, int color ) { //#if MC >= 1.20.0 context. - //#elseif MC > 1.16.1 - //$$ GuiComponent. //#else - //$$ super. + //$$ GuiComponent //#endif drawCenteredString( //#if MC < 1.20.0 @@ -93,12 +70,7 @@ public void drawCenteredString( ); } - //#if MC > 1.16.1 - static - //#else - //$$ @Override - //#endif - public void drawCenteredString( + public static void drawCenteredString( @NotNull //#if MC < 1.20.0 //$$ PoseStack context, @@ -109,10 +81,8 @@ public void drawCenteredString( ) { //#if MC >= 1.20.0 context. - //#elseif MC > 1.16.1 - //$$ GuiComponent. //#else - //$$ super. + //$$ GuiComponent. //#endif drawCenteredString( //#if MC < 1.20.0 @@ -122,7 +92,7 @@ public void drawCenteredString( ); } - //#if MC < 1.20.0 && MC > 1.16.1 + //#if MC < 1.20.0 //$$ @Override //#endif public void renderComponentTooltip( @@ -136,10 +106,8 @@ public void renderComponentTooltip( ) { //#if MC >= 1.20.0 context.renderComponentTooltip - //#elseif MC > 1.16.1 - //$$ super.renderComponentTooltip //#else - //$$ renderTooltip + //$$ super.renderComponentTooltip //#endif ( //#if MC < 1.20.0 @@ -151,12 +119,7 @@ public void renderComponentTooltip( ); } - //#if MC > 1.16.1 - static - //#else - //$$ @Override - //#endif - public void drawString( + public static void drawString( @NotNull //#if MC < 1.20.0 //$$ PoseStack context, @@ -164,20 +127,13 @@ public void drawString( GuiGraphics context, //#endif Font font, - @NotNull - //#if MC > 11601 - Component text, - //#else - //$$ FormattedText text, - //#endif + @NotNull Component text, int x, int y, int color ) { //#if MC >= 1.20.0 context. - //#elseif MC > 1.16.1 - //$$ GuiComponent. //#else - //$$ super. + //$$ GuiComponent. //#endif drawString( //#if MC < 1.20.0 @@ -199,7 +155,7 @@ public static void blit( //#if MC >= 1.20.0 context. //#else - //$$ WorldHost.texture(texture); + //$$ RenderSystem.setShaderTexture(0, texture); //$$ GuiComponent. //#endif blit( @@ -224,7 +180,7 @@ public static void blit( //#if MC >= 1.20.0 context. //#else - //$$ WorldHost.texture(texture); + //$$ RenderSystem.setShaderTexture(0, texture); //$$ GuiComponent. //#endif blit( @@ -246,11 +202,7 @@ public static void drawString( //#endif Font font, @NotNull - //#if MC > 1.16.1 FormattedCharSequence text, - //#else - //$$ FormattedText text, - //#endif int x, int y, int color, boolean dropShadow ) { //#if MC < 1.20.0 @@ -348,22 +300,14 @@ public static PoseStack pose( //$$ Minecraft.getInstance().screen.renderTooltip(arg2, lines, i, j); //$$ } //$$ - //#if MC > 1.16.5 - //$$ @Override - //$$ public void narrateTooltip(@NotNull Consumer contents) { - //$$ contents.accept(tooltip); - //$$ } - //#endif + //$$ @Override + //$$ public void narrateTooltip(@NotNull Consumer contents) { + //$$ contents.accept(tooltip); + //$$ } //$$ }; //$$ } //#endif - //#if MC <= 1.16.5 - //$$ protected T addRenderableWidget(T widget) { - //$$ return addButton(widget); - //$$ } - //#endif - public static ButtonBuilder button(Component message, Button.OnPress onPress) { return new ButtonBuilder(message, onPress); } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen.java index b033275..cb35299 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen.java @@ -5,6 +5,7 @@ import net.minecraft.client.gui.screens.ConnectScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.resolver.ServerAddress; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -12,16 +13,11 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC > 1.16.5 -import net.minecraft.client.multiplayer.resolver.ServerAddress; -//#endif - @Mixin(ConnectScreen.class) public class MixinConnectScreen { @Shadow @Final Screen parent; @Inject(method = "connect", at = @At("HEAD"), cancellable = true) - //#if MC > 1.16.5 private void overrideConnect( Minecraft minecraft, ServerAddress serverAddress, //#if MC > 1.19.2 @@ -31,9 +27,6 @@ private void overrideConnect( ) { final String host = serverAddress.getHost(); final int port = serverAddress.getPort(); - //#else - //$$ private void overrideConnect(String host, int port, CallbackInfo ci) { - //#endif if (WorldHost.protoClient == null || WorldHost.protoClient.getAttemptingToJoin() != null) return; final String targetBaseAddr; diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java index 2cf665e..f998195 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen_1.java @@ -3,17 +3,14 @@ import io.github.gaming32.worldhost.WorldHost; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.ConnectScreen; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.resolver.ServerAddress; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC > 1.16.5 -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.resolver.ServerAddress; -//#endif - //#if MC > 1.18.2 && MC < 1.19.4 //$$ import java.util.concurrent.CompletableFuture; //#endif @@ -29,24 +26,16 @@ public class MixinConnectScreen_1 { @Inject(method = "", at = @At("TAIL")) private void initRefs( ConnectScreen connectScreen, String string, - //#if MC > 1.16.5 ServerAddress serverAddress, Minecraft minecraft, //#if MC > 1.19.2 ServerData serverData, //#elseif MC > 1.18.2 //$$ CompletableFuture completableFuture, //#endif - //#else - //$$ String host, int port, - //#endif CallbackInfo ci ) { wh$parent = connectScreen; - //#if MC > 1.16.5 wh$host = serverAddress.getHost(); - //#else - //$$ wh$host = host; - //#endif } @Inject( diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinJoinMultiplayerScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinJoinMultiplayerScreen.java index 7b87552..615196c 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinJoinMultiplayerScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinJoinMultiplayerScreen.java @@ -17,10 +17,6 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC <= 1.16.5 -//$$ import net.minecraft.client.gui.components.AbstractWidget; -//#endif - @Mixin(JoinMultiplayerScreen.class) public class MixinJoinMultiplayerScreen extends Screen { @Shadow @@ -60,10 +56,4 @@ private int makeTopBigger(int constant) { private int moveTitleUp(int constant) { return WorldHost.CONFIG.isEnableFriends() ? 15 : constant; } - - //#if MC <= 1.16.5 - //$$ protected T addRenderableWidget(T widget) { - //$$ return addButton(widget); - //$$ } - //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinPauseScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinPauseScreen.java index 84856c8..cda9cf3 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinPauseScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinPauseScreen.java @@ -13,10 +13,6 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC <= 1.16.5 -//$$ import net.minecraft.client.gui.components.AbstractWidget; -//#endif - @Mixin(PauseScreen.class) public class MixinPauseScreen extends Screen { protected MixinPauseScreen(Component component) { @@ -57,10 +53,4 @@ private void onlineStatus(CallbackInfo ci) { font )); } - - //#if MC <= 1.16.5 - //$$ protected T addRenderableWidget(T widget) { - //$$ return addButton(widget); - //$$ } - //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java index 663ff37..42275b9 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java @@ -59,11 +59,7 @@ private int shrinkPlayButton(int constant) { method = "init()V", at = @At( value = "INVOKE", - //#if MC > 1.16.5 target = "Lnet/minecraft/client/gui/screens/worldselection/SelectWorldScreen;addRenderableWidget(Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;", - //#else - //$$ target = "Lnet/minecraft/client/gui/screens/worldselection/SelectWorldScreen;addButton(Lnet/minecraft/client/gui/components/AbstractWidget;)Lnet/minecraft/client/gui/components/AbstractWidget;", - //#endif ordinal = 0, shift = At.Shift.AFTER ) @@ -73,11 +69,7 @@ private void addShareWorldButton(CallbackInfo ci) { wh$shareButton = null; return; } - //#if MC > 1.16.5 wh$shareButton = addRenderableWidget( - //#else - //$$ wh$shareButton = addButton( - //#endif WorldHostScreen.button(Components.translatable("world-host.share_world"), b -> list.getSelectedOpt().ifPresent(worldListEntry -> { wh$shareButtonPressed = true; diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java index 265c345..8012ce3 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinShareToLanScreen.java @@ -26,12 +26,7 @@ private String changeLabelI2(String constant) { //#if MC < 1.19.4 //$$ @ModifyArg( - //$$ method = - //#if MC < 1.17.1 - //$$ {"lambda$init$0*", "func_213082_d"}, // Mixin can't find lambda$init$0 for some reason, so have an obfuscated method name :) - //#else - //$$ "lambda$init$2", - //#endif + //$$ method = "lambda$init$2", //$$ at = @At( //$$ value = "INVOKE", //$$ target = @@ -51,16 +46,7 @@ private String changeLabelI2(String constant) { //$$ } //$$ //$$ @ModifyArg( - //$$ method = - //#if MC < 1.17.1 - //#if FABRIC - //$$ "lambda$init$0", - //#else - //$$ {"lambda$init$0*", "func_213082_d"}, // Mixin can't find lambda$init$0 for some reason, so have an obfuscated method name :) - //#endif - //#else - //$$ "lambda$init$2", - //#endif + //$$ method = "lambda$init$2", //$$ at = @At( //$$ value = "INVOKE", //$$ target = diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java index c0f4400..baddc81 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java @@ -11,23 +11,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC <= 1.16.5 -//$$ import net.minecraft.client.gui.components.AbstractWidget; -//#endif - -//#if FABRIC -//#if MC <= 1.16.1 -//$$ import net.fabricmc.loader.api.FabricLoader; -//#endif -//#else +//#if FORGELIKE //#if NEOFORGE //$$ import net.neoforged.neoforge.internal.BrandingControl; //#elseif MC > 1.17.1 //$$ import net.minecraftforge.internal.BrandingControl; -//#elseif MC > 1.16.5 -//$$ import net.minecraftforge.fmllegacy.BrandingControl; //#else -//$$ import net.minecraftforge.fml.BrandingControl; +//$$ import net.minecraftforge.fmllegacy.BrandingControl; //#endif //$$ import java.util.function.BiConsumer; //#endif @@ -50,11 +40,6 @@ private void onlineStatus(CallbackInfo ci) { y += mmcLines * 12; } //#endif - //#if MC <= 1.16.1 - //$$ if (FabricLoader.getInstance().isModLoaded("modmenu")) { - //$$ y += 12; - //$$ } - //#endif //#else //$$ int[] forgeLineCount = {-1}; //$$ final BiConsumer lineConsumer = (i, s) -> forgeLineCount[0]++; @@ -72,10 +57,4 @@ private void onlineStatus(CallbackInfo ci) { 10, location == OnlineStatusLocation.RIGHT, font )); } - - //#if MC <= 1.16.5 - //$$ protected T addRenderableWidget(T widget) { - //$$ return addButton(widget); - //$$ } - //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinWorldSelectionList_WorldListEntry.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinWorldSelectionList_WorldListEntry.java index 5e9183d..a873da2 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinWorldSelectionList_WorldListEntry.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinWorldSelectionList_WorldListEntry.java @@ -12,10 +12,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -//#if MC <= 1.16.5 -//$$ import org.lwjgl.glfw.GLFW; -//#endif - @Mixin(WorldSelectionList.WorldListEntry.class) public class MixinWorldSelectionList_WorldListEntry { @Shadow @Final private Minecraft minecraft; @@ -29,12 +25,7 @@ private void shareWorldOnShift(CallbackInfo ci) { WorldHost.shareWorldOnLoad = true; } else { WorldHost.shareWorldOnLoad = InputConstants.isKeyDown( - minecraft.getWindow().getWindow(), - //#if MC > 1.16.5 - InputConstants.KEY_LSHIFT - //#else - //$$ GLFW.GLFW_KEY_LEFT_SHIFT - //#endif + minecraft.getWindow().getWindow(), InputConstants.KEY_LSHIFT ); } } else { diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/ServerConnectionListenerAccessor.java b/src/main/java/io/github/gaming32/worldhost/mixin/ServerConnectionListenerAccessor.java deleted file mode 100644 index dfe8907..0000000 --- a/src/main/java/io/github/gaming32/worldhost/mixin/ServerConnectionListenerAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.github.gaming32.worldhost.mixin; - -import net.minecraft.network.Connection; -import net.minecraft.server.network.ServerConnectionListener; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(ServerConnectionListener.class) -public interface ServerConnectionListenerAccessor { - @Accessor - List getConnections(); -} diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/modmenu/MixinModMenuEventHandler.java b/src/main/java/io/github/gaming32/worldhost/mixin/modmenu/MixinModMenuEventHandler.java index 02f4c2b..c223629 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/modmenu/MixinModMenuEventHandler.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/modmenu/MixinModMenuEventHandler.java @@ -1,4 +1,4 @@ -//#if FABRIC && MC > 1.16.1 +//#if FABRIC package io.github.gaming32.worldhost.mixin.modmenu; import com.terraformersmc.modmenu.event.ModMenuEventHandler; diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java index 99a68b9..e858040 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -273,11 +273,7 @@ public void handle(ProtocolClient client) { } minecraft.setScreen(new DisconnectedScreen( parentScreen, - //#if MC > 1.16.1 Components.translatable("world-host.connection_not_found"), - //#else - //$$ "world-host.connection_not_found", - //#endif Components.translatable("world-host.connection_not_found.desc", WorldHost.connectionIdToString(connectionId)) )); }); diff --git a/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java b/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java index 09ffa8e..25d727f 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/ToastInstance.java @@ -19,11 +19,7 @@ import net.minecraft.client.gui.GuiGraphics; //#endif -//#if MC >= 1.16.5 import net.minecraft.util.FormattedCharSequence; -//#else -//$$ import net.minecraft.network.chat.FormattedText; -//#endif class ToastInstance { private static final int TEXT_WIDTH = 200; @@ -57,11 +53,8 @@ class ToastInstance { public final int ticksTotal; public int ticksRemaining; - //#if MC >= 1.16.5 - public List formattedTitle, formattedDescription; - //#else - //$$ public List formattedTitle, formattedDescription; - //#endif + public List formattedTitle; + public List formattedDescription; public float y; diff --git a/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java b/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java index a6db631..d773235 100644 --- a/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java +++ b/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java @@ -1,20 +1,11 @@ package io.github.gaming32.worldhost.versions; import net.minecraft.client.User; -import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.EditBox; -import net.minecraft.network.chat.Component; -import java.util.List; import java.util.UUID; -//#if MC >= 1.16.5 -import net.minecraft.util.FormattedCharSequence; -//#else -//$$ import net.minecraft.network.chat.FormattedText; -//#endif - public class Patterns { @Pattern public static void setFocused(EditBox editBox, boolean focus) { @@ -34,21 +25,6 @@ public static int getY(AbstractWidget widget) { //#endif } - @Pattern - public static List< - //#if MC >= 1.16.5 - FormattedCharSequence - //#else - //$$ FormattedText - //#endif - > split(Font font, Component text, int width) { - //#if MC >= 1.16.5 - return font.split(text, width); - //#else - //$$ return font.getSplitter().splitLines(text, width, net.minecraft.network.chat.Style.EMPTY); - //#endif - } - @Pattern public static UUID getProfileId(User user) { //#if MC >= 1.19.2 diff --git a/src/main/resources/world-host.mixins.json b/src/main/resources/world-host.mixins.json index 562a2cf..0feaeac 100644 --- a/src/main/resources/world-host.mixins.json +++ b/src/main/resources/world-host.mixins.json @@ -6,8 +6,7 @@ "mixins": [ "MixinCommands", "MixinLevelSummary", - "MixinPublishCommand", - "ServerConnectionListenerAccessor" + "MixinPublishCommand" ], "client": [ "MinecraftAccessor", @@ -25,9 +24,7 @@ "MixinWorldSelectionList_WorldListEntry", "PlainTextButtonAccessor", "ServerStatusPingerAccessor", - //#if FABRIC && MC > 1.16.1 "modmenu.MixinModMenuEventHandler" - //#endif ], "injectors": { "defaultRequire": 1 diff --git a/version.gradle.kts b/version.gradle.kts index 86fa235..6d2c249 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -63,7 +63,6 @@ unimined.minecraft { mcVersion >= 1_19_00 -> "1.19.2:2022.11.27" mcVersion >= 1_18_00 -> "1.18.2:2022.11.06" mcVersion >= 1_17_00 -> "1.17.1:2021.12.12" - mcVersion >= 1_16_00 -> "1.16.5:2022.03.06" else -> null }?.let { parchment(it.substringBefore(":"), it.substringAfter(":")) @@ -73,9 +72,6 @@ unimined.minecraft { if (mcVersion <= 1_19_00) { c("net/minecraft/client/gui/chat/NarratorChatListener", "net/minecraft/client/GameNarrator") } - if (mcVersion < 1_17_00) { - c("net/minecraft/client/multiplayer/ServerAddress", "net/minecraft/client/multiplayer/resolver/ServerAddress") - } } } @@ -90,7 +86,6 @@ unimined.minecraft { 1_19_02 -> "43.2.0" 1_18_02 -> "40.2.0" 1_17_01 -> "37.1.1" - 1_16_05 -> "36.2.34" else -> throw IllegalStateException("Unknown Forge version for $mcVersionString") }) mixinConfig("world-host.mixins.json") @@ -229,14 +224,10 @@ dependencies { 1_19_02 -> "4.2.0-beta.2" 1_18_02 -> "3.2.5" 1_17_01 -> "2.0.17" - 1_16_05 -> "1.16.23" else -> null }?.let { "modImplementation"("com.terraformersmc:modmenu:$it") } - if (mcVersion == 1_16_01) { - "modImplementation"("io.github.prospector:modmenu:1.14.5+build.30") - } } when { @@ -255,8 +246,6 @@ dependencies { 1_19_02 -> "0.77.0+1.19.2" 1_18_02 -> "0.77.0+1.18.2" 1_17_01 -> "0.46.1+1.17" - 1_16_05 -> "0.42.0+1.16" - 1_16_01 -> "0.18.0+build.387-1.16.1" else -> null }?.let { fabricApi.fabricModule("fabric-resource-loader-v0", it) } ?.let { @@ -344,6 +333,8 @@ modrinth { tasks.processResources { filesMatching("pack.mcmeta") { expand("pack_format" to when { + mcVersion >= 1_20_05 -> 32 + mcVersion >= 1_20_03 -> 22 mcVersion >= 1_20_02 -> 18 mcVersion >= 1_20_00 -> 15 mcVersion >= 1_19_04 -> 13