From 8759d82fd9fe8650f4b61fb89d6b8928d2e0f043 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Wed, 12 Jun 2024 09:43:27 -0400 Subject: [PATCH] Drop support for 1.17.1 --- build.gradle.kts | 21 ---------- settings.gradle.kts | 2 - .../github/gaming32/worldhost/IOFunction.java | 9 ----- .../github/gaming32/worldhost/WorldHost.java | 38 +++++-------------- .../worldhost/gui/PlainTextButton.java | 32 ---------------- .../gui/screen/OnlineFriendsScreen.java | 1 - .../gui/widget/OnlineStatusButton.java | 14 +------ .../mixin/MixinIntegratedServer.java | 28 ++------------ .../worldhost/mixin/MixinMouseHandler.java | 5 +-- .../worldhost/mixin/MixinTitleScreen.java | 4 +- .../mixin/PlainTextButtonAccessor.java | 7 +--- src/main/resources/META-INF/mods.toml | 6 +-- .../resources/META-INF/neoforge.mods.toml | 4 +- version.gradle.kts | 11 +----- 14 files changed, 24 insertions(+), 158 deletions(-) delete mode 100644 src/main/java/io/github/gaming32/worldhost/IOFunction.java delete mode 100644 src/main/java/io/github/gaming32/worldhost/gui/PlainTextButton.java diff --git a/build.gradle.kts b/build.gradle.kts index b9ccd5d..7d53604 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,8 +20,6 @@ preprocess { val forge11902 = createNode("1.19.2-forge", 1_19_02, "srg") val fabric11802 = createNode("1.18.2-fabric", 1_18_02, "yarn") 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") fabric12006.link(neoforge12006) neoforge12006.link(neoforge12004) @@ -34,23 +32,4 @@ preprocess { fabric11902.link(forge11902) forge11902.link(forge11802) forge11802.link(fabric11802) - fabric11802.link(fabric11701) - fabric11701.link(forge11701) - -// subprojects { -// apply(plugin = "java") -// if (name == "1.20.1-fabric") { -// sourceSets.main { -// java { -// srcDir("$rootDir/src/main/java") -// } -// } -// } -// } } - -//gradle.projectsEvaluated { -// subprojects.asSequence().zipWithNext().forEach { (left, right) -> -// right.tasks.named("modrinth").get().mustRunAfter(left.tasks.named("modrinth")) -// } -//} diff --git a/settings.gradle.kts b/settings.gradle.kts index 78db8a7..5abe3d4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,8 +19,6 @@ rootProject.name = "world-host" rootProject.buildFileName = "build.gradle.kts" listOf( - "1.17.1-forge", - "1.17.1-fabric", "1.18.2-forge", "1.18.2-fabric", "1.19.2-forge", diff --git a/src/main/java/io/github/gaming32/worldhost/IOFunction.java b/src/main/java/io/github/gaming32/worldhost/IOFunction.java deleted file mode 100644 index c38dcad..0000000 --- a/src/main/java/io/github/gaming32/worldhost/IOFunction.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.gaming32.worldhost; - -import java.io.IOException; - -// TODO: Remove when 1.18.2 is minimum -@FunctionalInterface -public interface IOFunction { - R apply(T t) throws IOException; -} diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index 38125d8..d9d6916 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -6,6 +6,7 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; +import com.mojang.logging.LogUtils; import io.github.gaming32.worldhost.config.WorldHostConfig; import io.github.gaming32.worldhost.gui.screen.JoiningWorldHostScreen; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; @@ -44,6 +45,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.network.ServerConnectionListener; import net.minecraft.server.players.GameProfileCache; +import org.apache.commons.io.function.IOFunction; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; @@ -53,6 +55,7 @@ import org.quiltmc.parsers.json.JsonReader; import org.quiltmc.parsers.json.JsonWriter; import org.semver4j.Semver; +import org.slf4j.Logger; import java.io.BufferedReader; import java.io.InputStream; @@ -84,14 +87,6 @@ import static net.minecraft.commands.Commands.literal; -//#if MC >= 1.18.0 -import com.mojang.logging.LogUtils; -import org.slf4j.Logger; -//#else -//$$ import org.apache.logging.log4j.LogManager; -//$$ import org.apache.logging.log4j.Logger; -//#endif - //#if MC >= 1.19.2 import io.github.gaming32.worldhost.mixin.MinecraftAccessor; //#else @@ -105,12 +100,10 @@ //#endif //#if FABRIC -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.loader.api.FabricLoader; -//#if MC >= 1.18.2 import dev.isxander.mainmenucredits.MainMenuCredits; import io.github.gaming32.worldhost.gui.OnlineStatusLocation; -//#endif +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.loader.api.FabricLoader; //#else //$$ import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen; //#if FORGE @@ -138,10 +131,8 @@ //$$ import net.neoforged.neoforge.client.ConfigScreenHandler; //#elseif MC >= 1.19.2 //$$ import net.minecraftforge.client.ConfigScreenHandler; -//#elseif MC >= 1.18.2 -//$$ import net.minecraftforge.client.ConfigGuiHandler; //#else -//$$ import net.minecraftforge.fmlclient.ConfigGuiHandler; +//$$ import net.minecraftforge.client.ConfigGuiHandler; //#endif //#endif @@ -160,12 +151,7 @@ public class WorldHost "world-host"; //#endif - public static final Logger LOGGER = - //#if MC >= 1.18.0 - LogUtils.getLogger(); - //#else - //$$ LogManager.getLogger(); - //#endif + public static final Logger LOGGER = LogUtils.getLogger(); public static final Loader MOD_LOADER = //#if NEOFORGE @@ -464,13 +450,7 @@ public static void reconnect(boolean successToast, boolean failureToast) { } public static String getName(GameProfile profile) { - return getIfBlank(profile.getName(), () -> profile.getId().toString()); - } - - // From Apache Commons Lang StringUtils 3.10+ - // TODO: Remove when 1.18.2 is minimum - public static T getIfBlank(final T str, final Supplier defaultSupplier) { - return StringUtils.isBlank(str) ? defaultSupplier == null ? null : defaultSupplier.get() : str; + return StringUtils.getIfBlank(profile.getName(), () -> profile.getId().toString()); } public static GameProfileCache getProfileCache() { @@ -795,7 +775,7 @@ public static String getModVersion(String modId) { } public static int getMMCLines(boolean isPause) { - //#if FABRIC && MC >= 1.18.2 + //#if FABRIC if (FabricLoader.getInstance().isModLoaded("isxander-main-menu-credits")) { final var baseConfig = MainMenuCredits.getInstance().getConfig(); final var config = isPause ? baseConfig.PAUSE_MENU : baseConfig.MAIN_MENU; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/PlainTextButton.java b/src/main/java/io/github/gaming32/worldhost/gui/PlainTextButton.java deleted file mode 100644 index e0831b3..0000000 --- a/src/main/java/io/github/gaming32/worldhost/gui/PlainTextButton.java +++ /dev/null @@ -1,32 +0,0 @@ -//#if MC <= 1.17.1 -//$$ package io.github.gaming32.worldhost.gui; -//$$ -//$$ import com.mojang.blaze3d.vertex.PoseStack; -//$$ import net.minecraft.ChatFormatting; -//$$ import net.minecraft.client.gui.Font; -//$$ import net.minecraft.client.gui.components.Button; -//$$ import net.minecraft.network.chat.Component; -//$$ import net.minecraft.network.chat.ComponentUtils; -//$$ import net.minecraft.network.chat.Style; -//$$ import net.minecraft.util.Mth; -//$$ import org.jetbrains.annotations.NotNull; -//$$ -//$$ public class PlainTextButton extends Button { -//$$ private final Font font; -//$$ private final Component message; -//$$ private final Component underlinedMessage; -//$$ -//$$ public PlainTextButton(int x, int y, int width, int height, Component component, Button.OnPress onPress, Font font) { -//$$ super(x, y, width, height, component, onPress); -//$$ this.font = font; -//$$ this.message = component; -//$$ this.underlinedMessage = ComponentUtils.mergeStyles(component.copy(), Style.EMPTY.applyFormat(ChatFormatting.UNDERLINE)); -//$$ } -//$$ -//$$ @Override -//$$ public void renderButton(@NotNull PoseStack poseStack, int i, int j, float f) { -//$$ Component component = this.isHovered() ? this.underlinedMessage : this.message; -//$$ drawString(poseStack, this.font, component, this.x, this.y, 0xffffff | Mth.ceil(this.alpha * 255.0F) << 24); -//$$ } -//$$ } -//#endif 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 792a1d8..5a9bf4a 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 @@ -375,7 +375,6 @@ public void render( iconData = icon; } else { //#if MC >= 1.19.4 - // Mojang did "@Nullable byte[]" instead of "byte @Nullable []" serverInfo.setIconBytes(null); //#else //$$ serverInfo.setIconB64(null); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java index 27bc6ef..c155c33 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/OnlineStatusButton.java @@ -7,6 +7,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.components.PlainTextButton; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentUtils; @@ -22,12 +23,6 @@ //$$ import com.mojang.blaze3d.vertex.PoseStack; //#endif -//#if MC > 1.17.1 -import net.minecraft.client.gui.components.PlainTextButton; -//#else -//$$ import io.github.gaming32.worldhost.gui.PlainTextButton; -//#endif - public final class OnlineStatusButton extends PlainTextButton { private static final ChatFormatting[] COLORS = { ChatFormatting.RED, @@ -127,15 +122,8 @@ private static Component generateStatusComponent() { (context, i, j, f); } - //#if MC >= 1.18.0 @Override public boolean isHoveredOrFocused() { return currentStatus != 1 && super.isHoveredOrFocused(); } - //#else - //$$ @Override - //$$ public boolean isHovered() { - //$$ return currentStatus != 1 && super.isHovered(); - //$$ } - //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java index fe3b733..914af03 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java @@ -10,6 +10,7 @@ import net.minecraft.client.server.IntegratedServer; import net.minecraft.network.chat.Component; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.WorldStem; import net.minecraft.server.level.progress.ChunkProgressListenerFactory; import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.util.HttpUtil; @@ -35,14 +36,6 @@ //$$ import net.minecraft.server.players.GameProfileCache; //#endif -//#if MC < 1.18.2 -//$$ import net.minecraft.core.RegistryAccess; -//$$ import net.minecraft.server.ServerResources; -//$$ import net.minecraft.world.level.storage.WorldData; -//#else -import net.minecraft.server.WorldStem; -//#endif - @Mixin(IntegratedServer.class) public abstract class MixinIntegratedServer extends MinecraftServer { public MixinIntegratedServer( @@ -55,26 +48,13 @@ public MixinIntegratedServer( DataFixer dataFixer, Services services, ChunkProgressListenerFactory chunkProgressListenerFactory - //#elseif MC > 1.17.1 - //$$ Thread thread, - //$$ LevelStorageSource.LevelStorageAccess levelStorageAccess, - //$$ PackRepository packRepository, - //$$ WorldStem worldStem, - //$$ Proxy proxy, - //$$ DataFixer dataFixer, - //$$ MinecraftSessionService minecraftSessionService, - //$$ GameProfileRepository gameProfileRepository, - //$$ GameProfileCache gameProfileCache, - //$$ ChunkProgressListenerFactory chunkProgressListenerFactory //#else //$$ Thread thread, - //$$ RegistryAccess.RegistryHolder registryHolder, //$$ LevelStorageSource.LevelStorageAccess levelStorageAccess, - //$$ WorldData worldData, //$$ PackRepository packRepository, + //$$ WorldStem worldStem, //$$ Proxy proxy, //$$ DataFixer dataFixer, - //$$ ServerResources serverResources, //$$ MinecraftSessionService minecraftSessionService, //$$ GameProfileRepository gameProfileRepository, //$$ GameProfileCache gameProfileCache, @@ -83,10 +63,8 @@ public MixinIntegratedServer( ) { //#if MC > 1.18.2 super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, services, chunkProgressListenerFactory); - //#elseif MC > 1.17.1 - //$$ super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory); //#else - //$$ super(thread, registryHolder, levelStorageAccess, worldData, packRepository, proxy, dataFixer, serverResources, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory); + //$$ super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, minecraftSessionService, gameProfileRepository, gameProfileCache, chunkProgressListenerFactory); //#endif } diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/MixinMouseHandler.java b/src/main/java/io/github/gaming32/worldhost/mixin/MixinMouseHandler.java index f099f61..cc7fd69 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinMouseHandler.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinMouseHandler.java @@ -1,5 +1,6 @@ package io.github.gaming32.worldhost.mixin; +import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.platform.Window; import io.github.gaming32.worldhost.toast.WHToast; import net.minecraft.client.Minecraft; @@ -11,8 +12,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static org.lwjgl.glfw.GLFW.GLFW_PRESS; - @Mixin(MouseHandler.class) public class MixinMouseHandler { @Shadow @Final private Minecraft minecraft; @@ -31,7 +30,7 @@ public class MixinMouseHandler { cancellable = true ) private void toastClick(long windowPointer, int button, int action, int modifiers, CallbackInfo ci) { - if (action != GLFW_PRESS) return; + if (action != InputConstants.PRESS) return; final Window window = minecraft.getWindow(); if (WHToast.click( xpos * window.getGuiScaledWidth() / window.getScreenWidth(), 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 c51146d..ad17e9d 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java @@ -14,10 +14,8 @@ //#if FORGELIKE //#if NEOFORGE //$$ import net.neoforged.neoforge.internal.BrandingControl; -//#elseif MC > 1.17.1 -//$$ import net.minecraftforge.internal.BrandingControl; //#else -//$$ import net.minecraftforge.fmllegacy.BrandingControl; +//$$ import net.minecraftforge.internal.BrandingControl; //#endif //$$ import java.util.function.BiConsumer; //#endif diff --git a/src/main/java/io/github/gaming32/worldhost/mixin/PlainTextButtonAccessor.java b/src/main/java/io/github/gaming32/worldhost/mixin/PlainTextButtonAccessor.java index 1eade83..3695407 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/PlainTextButtonAccessor.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/PlainTextButtonAccessor.java @@ -1,16 +1,11 @@ package io.github.gaming32.worldhost.mixin; +import net.minecraft.client.gui.components.PlainTextButton; import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -//#if MC > 1.17.1 -import net.minecraft.client.gui.components.PlainTextButton; -//#else -//$$ import io.github.gaming32.worldhost.gui.PlainTextButton; -//#endif - @Mixin(PlainTextButton.class) public interface PlainTextButtonAccessor { @Mutable diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 4f606b8..5853a1f 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -26,10 +26,10 @@ description = "Host your singleplayer worlds without having to run a server or s [[dependencies.world_host]] ##if FORGE #?? modId = "forge" -#?? versionRange = "[32,)" +#?? versionRange = "[32,48)" ##else modId = "neoforge" -versionRange = "[20,)" +versionRange = "[20,20.5)" ##endif ##if MC < 1.20.4 #?? mandatory = true @@ -46,7 +46,7 @@ modId = "minecraft" ##elseif MC == 1.20.4 #?? versionRange = "[1.20.3,1.20.5)" ##else -versionRange = "$mc_version" +versionRange = "[$mc_version]" ##endif ##if MC < 1.20.4 #?? mandatory = true diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 17a86ac..0a3cb7c 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -19,7 +19,7 @@ config = "world-host.mixins.json" [[dependencies.world_host]] modId = "neoforge" -versionRange = "[20,)" +versionRange = "[20.5,)" type = "required" ordering = "NONE" side = "BOTH" @@ -29,7 +29,7 @@ modId = "minecraft" ##if MC == 1.20.6 versionRange = "[1.20.5,1.20.7)" ##else -#?? versionRange = "$mc_version" +#?? versionRange = "[$mc_version]" ##endif type = "required" ordering = "NONE" diff --git a/version.gradle.kts b/version.gradle.kts index eaf0b6b..bd96f2d 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -109,7 +109,6 @@ unimined.minecraft { 1_19_04 -> "45.1.0" 1_19_02 -> "43.2.0" 1_18_02 -> "40.2.0" - 1_17_01 -> "37.1.1" else -> throw IllegalStateException("Unknown Forge version for $mcVersionString") }) mixinConfig("world-host.mixins.json") @@ -244,11 +243,7 @@ minecraft.apply { dependencies { fun bundle(dependency: Any) { - if (isFabric || mcVersion >= 1_18_00) { - "include"(dependency) - } else { - forgeJarJar(dependency) - } + "include"(dependency) } fun bundleImplementation(dependency: Any) { @@ -270,7 +265,6 @@ dependencies { 1_19_04 -> "6.3.1" 1_19_02 -> "4.2.0-beta.2" 1_18_02 -> "3.2.5" - 1_17_01 -> "2.0.17" else -> null }?.let { "modImplementation"("com.terraformersmc:modmenu:$it") @@ -292,7 +286,6 @@ dependencies { 1_19_04 -> "0.87.2+1.19.4" 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" else -> null }?.let { fapiVersion -> val resourceLoader = fabricApi.fabricModule("fabric-resource-loader-v0", fapiVersion) @@ -309,7 +302,7 @@ dependencies { } } - if (isFabric && mcVersion >= 1_18_02) { + if (isFabric) { modCompileOnly("dev.isxander:main-menu-credits:1.1.2") }