From 13d310d5a96b0270eef06b6c212fbeaf64a89d2b Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Fri, 3 May 2024 14:54:38 -0500 Subject: [PATCH 01/24] Update build to 1.20.6 --- build.gradle.kts | 8 +++-- settings.gradle.kts | 2 ++ .../resources/META-INF/neoforge.mods.toml | 35 +++++++++++++++++++ src/main/resources/fabric.mod.json | 2 ++ version.gradle.kts | 22 ++++++++---- 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/META-INF/neoforge.mods.toml diff --git a/build.gradle.kts b/build.gradle.kts index 4d5f392..4282c68 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("dev.deftu.gradle.preprocess-root") version "0.4.2" - id("xyz.wagyourtail.unimined") version "1.2.0" apply false + id("xyz.wagyourtail.unimined") version "1.2.4" apply false } repositories { @@ -8,6 +8,8 @@ repositories { } preprocess { + val fabric12006 = createNode("1.20.6-fabric", 1_20_06, "yarn") + val neoforge12006 = createNode("1.20.6-neoforge", 1_20_06, "yarn") val fabric12004 = createNode("1.20.4-fabric", 1_20_04, "yarn") val neoforge12004 = createNode("1.20.4-neoforge", 1_20_04, "yarn") val fabric12001 = createNode("1.20.1-fabric", 1_20_01, "yarn") @@ -21,7 +23,9 @@ preprocess { val fabric11701 = createNode("1.17.1-fabric", 1_17_01, "yarn") val forge11701 = createNode("1.17.1-forge", 1_17_01, "srg") - fabric12004.link(neoforge12004) + fabric12006.link(neoforge12006) + neoforge12006.link(neoforge12004) + neoforge12004.link(fabric12004) fabric12004.link(fabric12001) fabric12001.link(forge12001) forge12001.link(forge11904) diff --git a/settings.gradle.kts b/settings.gradle.kts index 4a57218..fdc6bdd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -34,6 +34,8 @@ listOf( "1.20.1-fabric", "1.20.4-neoforge", "1.20.4-fabric", + "1.20.6-neoforge", + "1.20.6-fabric", ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..401189f --- /dev/null +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,35 @@ +modLoader = "javafml" +loaderVersion = "[3,)" +license = "MIT" +issueTrackerURL = "https://github.com/Gaming32/bingo/issues" + +[[mods]] +modId = "world_host" +namespace = "world-host" +version = "$version" +displayName = "World Host" +displayURL = "https://modrinth.com/mod/world-host" +logoFile = "icon.png" +authors = "Gaming32" +description = "Host your singleplayer worlds without having to run a server or setup port forwarding! In the future, we also plan to support Bedrock Edition clients through the use of Geyser." + +[[mixins]] +config = "world-host.mixins.json" + +[[dependencies.world_host]] +modId = "neoforge" +versionRange = "[20,)" +type = "required" +ordering = "NONE" +side = "BOTH" + +[[dependencies.world_host]] +modId = "minecraft" +##if MC == 1.20.6 +#?? versionRange = "[1.20.5,1.20.7)" +##else +#?? versionRange = "$mc_version" +##endif +type = "required" +ordering = "NONE" +side = "BOTH" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b19eff6..5f04028 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,6 +34,8 @@ //?? "minecraft": ">=1.20- <1.20.2", //#elseif MC == 1.20.4 "minecraft": ">=1.20.3- <1.20.5", + //#elseif MC == 1.20.6 + //?? "minecraft": ">=1.20.5- <1.20.7", //#else //?? "minecraft": "$mc_version", //#endif diff --git a/version.gradle.kts b/version.gradle.kts index a6581a0..6f98285 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -47,7 +47,7 @@ repositories { unimined.minecraft { version(mcVersionString) - if (mcVersion != 1_20_01 || !isForge) { + if ((mcVersion != 1_20_01 || !isForge) && mcVersion < 1_20_05) { side("client") } @@ -56,6 +56,7 @@ unimined.minecraft { searge() mojmap() when { + mcVersion >= 1_20_05 -> "1.20.6:2024.05.01" mcVersion >= 1_20_04 -> "1.20.4:2024.04.14" mcVersion >= 1_20_03 -> "1.20.3:2023.12.31" mcVersion >= 1_20_02 -> "1.20.2:2023.12.10" @@ -76,11 +77,13 @@ unimined.minecraft { c("net/minecraft/client/gui/chat/NarratorChatListener", "net/minecraft/client/GameNarrator") } } + + devFallbackNamespace("official") } when { isFabric -> fabric { - loader("0.14.22") + loader("0.15.1") } isForge -> minecraftForge { loader(when(mcVersion) { @@ -95,6 +98,7 @@ unimined.minecraft { } isNeoForge -> neoForged { loader(when (mcVersion) { + 1_20_06 -> "21-beta" 1_20_04 -> "69-beta" else -> throw IllegalStateException("Unknown NeoForge version for $mcVersionString") }) @@ -219,6 +223,7 @@ dependencies { if (isFabric) { when (mcVersion) { + 1_20_06 -> "10.0.0-beta.1" 1_20_04 -> "9.0.0" 1_20_01 -> "7.2.2" 1_19_04 -> "6.3.1" @@ -240,6 +245,7 @@ dependencies { if (isFabric) { when (mcVersion) { + 1_20_06 -> "0.97.5+1.20.5" 1_20_04 -> "0.91.1+1.20.3" 1_20_01 -> "0.91.0+1.20.1" 1_19_04 -> "0.87.2+1.19.4" @@ -309,12 +315,10 @@ modrinth { 1_19_04 -> "23w13a_or_b" 1_20_01 -> "1.20" 1_20_04 -> "1.20.3" + 1_20_06 -> "1.20.5" else -> null }?.let(gameVersions::add) loaders.add(loaderName) - if (isFabric) { - loaders.add("quilt") - } dependencies { if (isFabric) { optional.project("modmenu") @@ -363,6 +367,7 @@ tasks.processResources { "fabric.mod.json", "quilt.mod.json", "META-INF/mods.toml", + "META-INF/neoforge.mods.toml", "mixins.*.json", "*.mixins.json" )) { @@ -374,9 +379,14 @@ tasks.processResources { } if (isFabric) { - exclude("pack.mcmeta", "META-INF/mods.toml") + exclude("pack.mcmeta", "META-INF/mods.toml", "META-INF/neoforge.mods.toml") } else { exclude("fabric.mod.json") + if (isNeoForge && mcVersion >= 1_20_05) { + exclude("META-INF/mods.toml") + } else { + exclude("META-INF/neoforge.mods.toml") + } } doLast { From 99af5327df2adac3a330b88900d1604fa07aa619 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Fri, 3 May 2024 14:57:02 -0500 Subject: [PATCH 02/24] Explicitly compile with Java 17 --- version.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/version.gradle.kts b/version.gradle.kts index 6f98285..048ad7f 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -275,6 +275,12 @@ dependencies { java { withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +tasks.compileJava { + options.release = 17 } preprocess { From e33cfb55283eeb1d2baaf1cc9f31ed877efc3401 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sat, 4 May 2024 07:14:01 -0500 Subject: [PATCH 03/24] Run GHA with J21 --- .github/workflows/gradle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 4d04508..9eb2a30 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -18,10 +18,10 @@ jobs: ~/.gradle/caches ~/.gradle/wrapper .gradle/loom-cache - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v1 with: - java-version: 17 + java-version: 21 - name: Build with Gradle run: ./gradlew build --stacktrace - name: Capture build artifacts From cbe4dad87469d813eb285e1cf021f8be812251e5 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Wed, 8 May 2024 14:57:36 -0500 Subject: [PATCH 04/24] Disable source remapping entirely --- build.gradle.kts | 2 +- settings.gradle.kts | 5 +---- version.gradle.kts | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4282c68..b9ccd5d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("dev.deftu.gradle.preprocess-root") version "0.4.2" + id("io.github.gaming32.gradle.preprocess-root") version "0.4.4" id("xyz.wagyourtail.unimined") version "1.2.4" apply false } diff --git a/settings.gradle.kts b/settings.gradle.kts index fdc6bdd..78db8a7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,13 +9,10 @@ pluginManagement { maven("https://maven.jab125.dev/") maven("https://maven.wagyourtail.xyz/snapshots") maven("https://maven.wagyourtail.xyz/releases") + maven("https://maven.jemnetworks.com/releases") gradlePluginPortal() mavenCentral() } - - plugins { - id("dev.deftu.gradle.multiversion-root") version("1.18.0") - } } rootProject.name = "world-host" diff --git a/version.gradle.kts b/version.gradle.kts index 048ad7f..c49a9bf 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -12,7 +12,7 @@ import java.nio.file.Path plugins { java `maven-publish` - id("dev.deftu.gradle.preprocess") + id("io.github.gaming32.gradle.preprocess") id("xyz.wagyourtail.unimined") id("com.modrinth.minotaur") version "2.+" } @@ -286,6 +286,8 @@ tasks.compileJava { preprocess { fun Boolean.toInt() = if (this) 1 else 0 + disableRemapping = true + vars.putAll(mapOf( "FABRIC" to isFabric.toInt(), "FORGE" to isForge.toInt(), From f9e51686107ab968a5e9c9769b3389f8faaab24a Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Wed, 8 May 2024 18:12:48 -0500 Subject: [PATCH 05/24] Switch core version --- .../github/gaming32/worldhost/WorldHost.java | 93 ++++++++----------- .../worldhost/gui/screen/FriendsScreen.java | 14 ++- .../mixin/MixinIntegratedServer.java | 7 +- .../protocol/WorldHostC2SMessage.java | 9 +- src/main/resources/META-INF/mods.toml | 4 +- .../resources/META-INF/neoforge.mods.toml | 2 +- src/main/resources/fabric.mod.json | 4 +- versions/mainProject | 2 +- 8 files changed, 62 insertions(+), 73 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index e620b53..4f65f1b 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -117,6 +117,7 @@ //$$ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; //#endif //$$ import java.util.function.BiFunction; +//#if MC < 1.20.5 //#if NEOFORGE //$$ import net.neoforged.neoforge.client.ConfigScreenHandler; //#elseif MC >= 1.19.2 @@ -126,6 +127,7 @@ //#else //$$ import net.minecraftforge.fmlclient.ConfigGuiHandler; //#endif +//#endif //#if NEOFORGE //$$ import net.neoforged.neoforge.resource.ResourcePackLoader; //#elseif MC > 1.17.1 @@ -229,52 +231,16 @@ public void onInitializeClient() { //#endif private static void init() { - wordsForCid = - //#if FABRIC - FabricLoader.getInstance() - .getModContainer(MOD_ID) - .flatMap(c -> c.findPath("assets/world-host/16k.txt")) - .map(path -> { - try { - return Files.lines(path, StandardCharsets.US_ASCII); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - }) - //#else - //$$ ResourcePackLoader - //$$ .getPackFor(MOD_ID) - //#if MC >= 1.20.4 - //$$ .map(c -> c.openPrimary("worldhost")) - //#endif - //$$ .map(c -> { - //#if MC <= 1.19.2 - //$$ try { - //#endif - //$$ return ((PackResources)c).getResource(PackType.CLIENT_RESOURCES, new ResourceLocation("world-host", "16k.txt")); - //#if MC <= 1.19.2 - //$$ } catch (IOException e) { - //$$ throw new UncheckedIOException(e); - //$$ } - //#endif - //$$ }) - //#if MC > 1.19.2 - //$$ .map(i -> { - //$$ try { - //$$ return i.get(); - //$$ } catch (IOException e) { - //$$ throw new UncheckedIOException(e); - //$$ } - //$$ }) - //#endif - //$$ .map(is -> new InputStreamReader(is, StandardCharsets.US_ASCII)) - //$$ .map(BufferedReader::new) - //$$ .map(BufferedReader::lines) - //#endif - .orElseThrow(() -> new IllegalStateException("Unable to find 16k.txt")) - .filter(s -> !s.startsWith("//")) - .toList(); - + try (BufferedReader reader = new BufferedReader( + new InputStreamReader( + WorldHost.class.getResourceAsStream("/assets/world-host/16k.txt"), + StandardCharsets.US_ASCII + ) + )) { + wordsForCid = reader.lines().filter(s -> !s.startsWith("//")).toList(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } if (wordsForCid.size() != (1 << 14)) { throw new RuntimeException("Expected WORDS_FOR_CID to have " + (1 << 14) + " elements, but it has " + wordsForCid.size() + " elements."); } @@ -574,20 +540,36 @@ public static FriendlyByteBuf createByteBuf() { @SuppressWarnings("RedundantThrows") public static ServerStatus parseServerStatus(FriendlyByteBuf buf) throws IOException { - return new ClientboundStatusResponsePacket(buf) - //#if MC >= 1.19.4 - .status(); - //#else - //$$ .getStatus(); - //#endif + //#if MC >= 1.20.5 + return ClientboundStatusResponsePacket.STREAM_CODEC.decode(buf).status(); + //#elseif MC >= 1.19.4 + //$$ return new ClientboundStatusResponsePacket(buf).status(); + //#else + //$$ return new ClientboundStatusResponsePacket(buf).getStatus(); + //#endif + } + + public static FriendlyByteBuf writeServerStatus(ServerStatus metadata) { + if (metadata == null) { + metadata = WorldHost.createEmptyServerStatus(); + } + final FriendlyByteBuf buf = WorldHost.createByteBuf(); + //#if MC < 1.20.5 + //$$ new ClientboundStatusResponsePacket(metadata).write(buf); + //#else + ClientboundStatusResponsePacket.STREAM_CODEC.encode(buf, new ClientboundStatusResponsePacket(metadata)); + //#endif + return buf; } public static ServerStatus createEmptyServerStatus() { //#if MC >= 1.19.4 return new ServerStatus( Components.EMPTY, Optional.empty(), Optional.empty(), Optional.empty(), false - //#if FORGELIKE + //#if FORGELIKE && MC < 1.20.5 //$$ , Optional.empty() + //#elseif NEOFORGE + //$$ , false //#endif ); //#else @@ -696,6 +678,9 @@ public static void connect(Screen parentScreen, long cid, String host, int port) //#endif ), false //#endif + //#if MC >= 1.20.5 + , null + //#endif ); } @@ -863,7 +848,7 @@ public static CompletableFuture> checkForUpdates() { }); } - //#if FORGELIKE + //#if FORGELIKE && MC < 1.20.5 //$$ @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) //$$ public static class ClientModEvents { //$$ @SubscribeEvent 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 cfea256..681ff2a 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,9 +61,11 @@ protected void init() { if (list == null) { list = new FriendsList(); - if (minecraft != null && minecraft.level != null) { - list.setRenderBackground(false); - } + //#if MC < 1.20.5 + //$$ if (minecraft != null && minecraft.level != null) { + //$$ list.setRenderBackground(false); + //$$ } + //#endif } setListSize(list, 32, WorldHost.BEDROCK_SUPPORT ? 80 : 64); addWidget(list); @@ -199,8 +201,10 @@ protected void renderDecorations(@NotNull GuiGraphics graphics, int mouseX, int //$$ final int y0 = this.y0; //$$ final int y1 = this.y1; //#endif - graphics.blit(BACKGROUND_LOCATION, x0, 0, 0f, 0f, width, y0, 32, 32); - graphics.blit(BACKGROUND_LOCATION, x0, y1, 0f, y1, width, height - y1, 32, 32); + //#if MC < 1.20.5 + //$$ graphics.blit(BACKGROUND_LOCATION, x0, 0, 0f, 0f, width, y0, 32, 32); + //$$ graphics.blit(BACKGROUND_LOCATION, x0, y1, 0f, y1, width, height - y1, 32, 32); + //#endif graphics.setColor(1f, 1f, 1f, 1f); graphics.fillGradient(RenderType.guiOverlay(), x0, y0, x1, y0 + 4, 0xff000000, 0, 0); graphics.fillGradient(RenderType.guiOverlay(), x0, y1 - 4, x1, y1, 0, 0xff000000, 0); 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 0e9eaff..77c5107 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinIntegratedServer.java @@ -115,8 +115,13 @@ private void serverIsClosed(boolean waitForServer, CallbackInfo ci) { private void shareWorldOnLoad(UUID uuid, CallbackInfo ci) { if (!WorldHost.shareWorldOnLoad) return; WorldHost.shareWorldOnLoad = false; + //#if MC < 1.20.5 + //$$ final boolean allowCommands = worldData.getAllowCommands(); + //#else + final boolean allowCommands = worldData.isAllowCommands(); + //#endif final Component message; - if (publishServer(worldData.getGameType(), worldData.getAllowCommands(), HttpUtil.getAvailablePort())) { + if (publishServer(worldData.getGameType(), allowCommands, HttpUtil.getAvailablePort())) { message = wh$getOpenedMessage(); } else { message = Components.translatable("world-host.share_world.failed").withStyle(ChatFormatting.RED); diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java index c70f95c..46a6e66 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java @@ -2,7 +2,6 @@ import io.github.gaming32.worldhost.WorldHost; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket; import net.minecraft.network.protocol.status.ServerStatus; import java.io.DataOutputStream; @@ -88,9 +87,7 @@ record QueryResponse(long connectionId, ServerStatus metadata) implements WorldH public void encode(DataOutputStream dos) throws IOException { dos.writeByte(7); dos.writeLong(connectionId); - final FriendlyByteBuf buf = WorldHost.createByteBuf(); - new ClientboundStatusResponsePacket(metadata != null ? metadata : WorldHost.createEmptyServerStatus()) - .write(buf); + final FriendlyByteBuf buf = WorldHost.writeServerStatus(metadata); dos.writeInt(buf.readableBytes()); buf.readBytes(dos, buf.readableBytes()); } @@ -126,9 +123,7 @@ record NewQueryResponse(long connectionId, ServerStatus metadata) implements Wor public void encode(DataOutputStream dos) throws IOException { dos.writeByte(11); dos.writeLong(connectionId); - final FriendlyByteBuf buf = WorldHost.createByteBuf(); - new ClientboundStatusResponsePacket(metadata != null ? metadata : WorldHost.createEmptyServerStatus()) - .write(buf); + final FriendlyByteBuf buf = WorldHost.writeServerStatus(metadata); buf.readBytes(dos, buf.readableBytes()); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 07fd63a..836c1b3 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -43,9 +43,9 @@ modId = "minecraft" ##if MC == 1.20.1 #?? versionRange = "[1.20,1.20.2)" ##elseif MC == 1.20.4 -versionRange = "[1.20.3,1.20.5)" +#?? 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 401189f..796a4e5 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -26,7 +26,7 @@ side = "BOTH" [[dependencies.world_host]] modId = "minecraft" ##if MC == 1.20.6 -#?? versionRange = "[1.20.5,1.20.7)" +versionRange = "[1.20.5,1.20.7)" ##else #?? versionRange = "$mc_version" ##endif diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5f04028..0ad2861 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,9 +33,9 @@ //#elseif MC == 1.20.1 //?? "minecraft": ">=1.20- <1.20.2", //#elseif MC == 1.20.4 - "minecraft": ">=1.20.3- <1.20.5", + //?? "minecraft": ">=1.20.3- <1.20.5", //#elseif MC == 1.20.6 - //?? "minecraft": ">=1.20.5- <1.20.7", + "minecraft": ">=1.20.5- <1.20.7", //#else //?? "minecraft": "$mc_version", //#endif diff --git a/versions/mainProject b/versions/mainProject index 66d55ba..304eaac 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.20.4-fabric \ No newline at end of file +1.20.6-fabric \ No newline at end of file From 976ed9e2e9c79e14a0b3f30a96d015f379f83825 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Wed, 8 May 2024 18:36:04 -0500 Subject: [PATCH 06/24] Support NeoForge 1.20.6 --- .../github/gaming32/worldhost/WorldHost.java | 26 +++++++++---------- version.gradle.kts | 4 +++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index 4f65f1b..5e35c38 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -99,8 +99,6 @@ //#endif //#else //$$ import io.github.gaming32.worldhost.gui.screen.WorldHostConfigScreen; -//$$ import net.minecraft.server.packs.PackType; -//$$ import net.minecraft.server.packs.PackResources; //#if FORGE //$$ import net.minecraftforge.api.distmarker.Dist; //$$ import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -117,8 +115,10 @@ //$$ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; //#endif //$$ import java.util.function.BiFunction; -//#if MC < 1.20.5 -//#if NEOFORGE +//#if MC >= 1.20.5 +//$$ import net.neoforged.fml.common.EventBusSubscriber; +//$$ import net.neoforged.neoforge.client.gui.IConfigScreenFactory; +//#elseif NEOFORGE //$$ import net.neoforged.neoforge.client.ConfigScreenHandler; //#elseif MC >= 1.19.2 //$$ import net.minecraftforge.client.ConfigScreenHandler; @@ -128,14 +128,6 @@ //$$ import net.minecraftforge.fmlclient.ConfigGuiHandler; //#endif //#endif -//#if NEOFORGE -//$$ import net.neoforged.neoforge.resource.ResourcePackLoader; -//#elseif MC > 1.17.1 -//$$ import net.minecraftforge.resource.ResourcePackLoader; -//#else -//$$ import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; -//#endif -//#endif //#if FORGELIKE //$$ @Mod(WorldHost.MOD_ID) @@ -848,8 +840,12 @@ public static CompletableFuture> checkForUpdates() { }); } - //#if FORGELIKE && MC < 1.20.5 + //#if FORGELIKE + //#if MC >= 1.20.5 + //$$ @EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) + //#else //$$ @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) + //#endif //$$ public static class ClientModEvents { //$$ @SubscribeEvent //$$ public static void onClientSetup(FMLClientSetupEvent event) { @@ -857,7 +853,9 @@ public static CompletableFuture> checkForUpdates() { //$$ final BiFunction screenFunction = //$$ (mc, screen) -> new WorldHostConfigScreen(screen); //$$ ModLoadingContext.get().registerExtensionPoint( - //#if MC >= 1.19.2 + //#if MC >= 1.20.5 + //$$ IConfigScreenFactory.class, () -> screenFunction::apply + //#elseif MC >= 1.19.2 //$$ ConfigScreenHandler.ConfigScreenFactory.class, //$$ () -> new ConfigScreenHandler.ConfigScreenFactory(screenFunction) //#else diff --git a/version.gradle.kts b/version.gradle.kts index c49a9bf..9888224 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -43,6 +43,9 @@ version = "${modVersion}+${mcVersionString}-${loaderName}" repositories { mavenCentral() + maven("https://maven.fabricmc.net") + maven("https://maven.minecraftforge.net") + maven("https://maven.neoforged.net/releases") } unimined.minecraft { @@ -281,6 +284,7 @@ java { tasks.compileJava { options.release = 17 + options.compilerArgs.add("-Xlint:all") } preprocess { From 2f55a326ece57df446ce3c532bafd9c7bd1ebfe4 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 08:16:21 -0500 Subject: [PATCH 07/24] Fabric 1.20.6 runs --- .../worldhost/gui/screen/FriendsScreen.java | 31 ------------------- .../worldhost/mixin/MixinConnectScreen.java | 10 +++++- src/main/resources/world-host.mixins.json | 2 +- version.gradle.kts | 18 ++++++++--- 4 files changed, 23 insertions(+), 38 deletions(-) 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 681ff2a..34e2712 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 @@ -29,10 +29,6 @@ //$$ import com.mojang.blaze3d.vertex.PoseStack; //#endif -//#if MC >= 1.20.2 -import net.minecraft.client.renderer.RenderType; -//#endif - public class FriendsScreen extends WorldHostScreen { public static final Component ADD_FRIEND_TEXT = Components.translatable("world-host.add_friend"); private static final Component ADD_SILENTLY_TEXT = Components.translatable("world-host.friends.add_silently"); @@ -185,33 +181,6 @@ public FriendsList() { ); } - //#if MC >= 1.20.2 - @Override - protected void renderDecorations(@NotNull GuiGraphics graphics, int mouseX, int mouseY) { - super.renderDecorations(graphics, mouseX, mouseY); - graphics.setColor(0.25f, 0.25f, 0.25f, 1f); - //#if MC >= 1.20.3 - final int x0 = getX(); - final int x1 = getRight(); - final int y0 = getY(); - final int y1 = getBottom(); - //#else - //$$ final int x0 = this.x0; - //$$ final int x1 = this.x1; - //$$ final int y0 = this.y0; - //$$ final int y1 = this.y1; - //#endif - //#if MC < 1.20.5 - //$$ graphics.blit(BACKGROUND_LOCATION, x0, 0, 0f, 0f, width, y0, 32, 32); - //$$ graphics.blit(BACKGROUND_LOCATION, x0, y1, 0f, y1, width, height - y1, 32, 32); - //#endif - graphics.setColor(1f, 1f, 1f, 1f); - graphics.fillGradient(RenderType.guiOverlay(), x0, y0, x1, y0 + 4, 0xff000000, 0, 0); - graphics.fillGradient(RenderType.guiOverlay(), x0, y1 - 4, x1, y1, 0, 0xff000000, 0); - } - - //#endif - @Override public void setSelected(@Nullable FriendsEntry entry) { super.setSelected(entry); 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 cb35299..144a6e7 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinConnectScreen.java @@ -13,16 +13,24 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//#if MC >= 1.20.5 +import net.minecraft.client.multiplayer.TransferState; +//#endif + @Mixin(ConnectScreen.class) public class MixinConnectScreen { @Shadow @Final Screen parent; @Inject(method = "connect", at = @At("HEAD"), cancellable = true) private void overrideConnect( - Minecraft minecraft, ServerAddress serverAddress, + Minecraft minecraft, + ServerAddress serverAddress, //#if MC > 1.19.2 ServerData serverData, //#endif + //#if MC >= 1.20.5 + TransferState transferState, + //#endif CallbackInfo ci ) { final String host = serverAddress.getHost(); diff --git a/src/main/resources/world-host.mixins.json b/src/main/resources/world-host.mixins.json index 0feaeac..47a3ac2 100644 --- a/src/main/resources/world-host.mixins.json +++ b/src/main/resources/world-host.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.7", "package": "io.github.gaming32.worldhost.mixin", - "compatibilityLevel": "$java_version", + "compatibilityLevel": "JAVA_16", "mixins": [ "MixinCommands", "MixinLevelSummary", diff --git a/version.gradle.kts b/version.gradle.kts index 9888224..94f47b8 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -86,7 +86,7 @@ unimined.minecraft { when { isFabric -> fabric { - loader("0.15.1") + loader("0.15.6") } isForge -> minecraftForge { loader(when(mcVersion) { @@ -256,11 +256,19 @@ dependencies { 1_18_02 -> "0.77.0+1.18.2" 1_17_01 -> "0.46.1+1.17" else -> null - }?.let { fabricApi.fabricModule("fabric-resource-loader-v0", it) } - ?.let { - "modImplementation"(it) - bundle(it) + }?.let { fapiVersion -> + val resourceLoader = fabricApi.fabricModule("fabric-resource-loader-v0", fapiVersion) + "modImplementation"(resourceLoader) + bundle(resourceLoader) + + for (module in listOf( + "fabric-screen-api-v1", + "fabric-key-binding-api-v1", + "fabric-lifecycle-events-v1" + )) { + "modRuntimeOnly"(fabricApi.fabricModule(module,fapiVersion)) } + } } if (isFabric && mcVersion >= 1_18_02) { From cc45187384d925a41b3b8d7f6bc446dba4cc83bc Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 10:03:35 -0500 Subject: [PATCH 08/24] NeoForge 1.20.6 runs --- .../github/gaming32/worldhost/WorldHost.java | 33 +++++++++++++------ .../worldhost/mixin/MixinConnectScreen_1.java | 7 ++++ src/main/resources/world-host.mixins.json | 2 ++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index 5e35c38..c7004fb 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -106,6 +106,7 @@ //$$ import net.minecraftforge.fml.ModLoadingContext; //$$ import net.minecraftforge.fml.common.Mod; //$$ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +//$$ import net.minecraftforge.fml.loading.FMLPaths; //#else //$$ import net.neoforged.api.distmarker.Dist; //$$ import net.neoforged.bus.api.SubscribeEvent; @@ -113,6 +114,7 @@ //$$ import net.neoforged.fml.ModLoadingContext; //$$ import net.neoforged.fml.common.Mod; //$$ import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +//$$ import net.neoforged.fml.loading.FMLPaths; //#endif //$$ import java.util.function.BiFunction; //#if MC >= 1.20.5 @@ -173,13 +175,13 @@ public class WorldHost 300 * 20 }; - public static final File GAME_DIR = Minecraft.getInstance().gameDirectory; - public static final File CACHE_DIR = new File(GAME_DIR, ".world-host-cache"); + public static final Path GAME_DIR = getGameDir(); + public static final Path CACHE_DIR = GAME_DIR.resolve(".world-host-cache"); - public static final File CONFIG_DIR = new File(GAME_DIR, "config"); - public static final Path CONFIG_FILE = new File(CONFIG_DIR, "world-host.json5").toPath(); - public static final Path FRIENDS_FILE = new File(CONFIG_DIR, "world-host-friends.json").toPath(); - public static final Path OLD_CONFIG_FILE = new File(CONFIG_DIR, "world-host.json").toPath(); + public static final Path CONFIG_DIR = GAME_DIR.resolve("config"); + public static final Path CONFIG_FILE = CONFIG_DIR.resolve("world-host.json5"); + public static final Path FRIENDS_FILE = CONFIG_DIR.resolve("world-host-friends.json"); + public static final Path OLD_CONFIG_FILE = CONFIG_DIR.resolve("world-host.json"); public static final WorldHostConfig CONFIG = new WorldHostConfig(); private static List wordsForCid; @@ -245,17 +247,20 @@ private static void init() { loadConfig(); - //noinspection ResultOfMethodCallIgnored - CACHE_DIR.mkdirs(); + try { + Files.createDirectories(CACHE_DIR); + } catch (IOException e) { + LOGGER.error("Failed to create cache directory", e); + } //#if MC >= 1.19.2 profileCache = Services.create( ((MinecraftAccessor)Minecraft.getInstance()).getAuthenticationService(), - CACHE_DIR + CACHE_DIR.toFile() ).profileCache(); //#else //$$ profileCache = new GameProfileCache( //$$ new YggdrasilAuthenticationService(Minecraft.getInstance().getProxy()).createProfileRepository(), - //$$ new File(CACHE_DIR, "usercache.json") + //$$ CACHE_DIR.resolve("usercache.json").toFile() //$$ ); //#endif profileCache.setExecutor(Util.backgroundExecutor()); @@ -840,6 +845,14 @@ public static CompletableFuture> checkForUpdates() { }); } + private static Path getGameDir() { + //#if FABRIC + return FabricLoader.getInstance().getGameDir(); + //#else + //$$ return FMLPaths.GAMEDIR.get(); + //#endif + } + //#if FORGELIKE //#if MC >= 1.20.5 //$$ @EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) 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 f998195..7b6635c 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 @@ -15,6 +15,10 @@ //$$ import java.util.concurrent.CompletableFuture; //#endif +//#if MC >= 1.20.5 +import net.minecraft.client.multiplayer.TransferState; +//#endif + @Mixin(targets = "net.minecraft.client.gui.screens.ConnectScreen$1") public class MixinConnectScreen_1 { @Unique @@ -32,6 +36,9 @@ private void initRefs( //#elseif MC > 1.18.2 //$$ CompletableFuture completableFuture, //#endif + //#if MC >= 1.20.5 + TransferState transferState, + //#endif CallbackInfo ci ) { wh$parent = connectScreen; diff --git a/src/main/resources/world-host.mixins.json b/src/main/resources/world-host.mixins.json index 47a3ac2..015ee37 100644 --- a/src/main/resources/world-host.mixins.json +++ b/src/main/resources/world-host.mixins.json @@ -24,7 +24,9 @@ "MixinWorldSelectionList_WorldListEntry", "PlainTextButtonAccessor", "ServerStatusPingerAccessor", + //#if FABRIC "modmenu.MixinModMenuEventHandler" + //#endif ], "injectors": { "defaultRequire": 1 From c99101bcb6472f2cfdf336e2375293708ae12003 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 10:24:29 -0500 Subject: [PATCH 09/24] Fix build --- .../github/gaming32/worldhost/WorldHost.java | 7 +++- .../worldhost/gui/screen/AddFriendScreen.java | 11 +++++- .../gaming32/worldhost/versions/Pattern.java | 11 ------ .../gaming32/worldhost/versions/Patterns.java | 36 ------------------- 4 files changed, 16 insertions(+), 49 deletions(-) delete mode 100644 src/main/java/io/github/gaming32/worldhost/versions/Pattern.java delete mode 100644 src/main/java/io/github/gaming32/worldhost/versions/Patterns.java diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index c7004fb..12cf767 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -423,7 +423,12 @@ public static void reconnect(boolean successToast, boolean failureToast) { proxyProtocolClient.close(); proxyProtocolClient = null; } - final UUID uuid = Minecraft.getInstance().getUser().getProfileId(); + final var user = Minecraft.getInstance().getUser(); + //#if MC >= 1.19.2 + final UUID uuid = user.getProfileId(); + //#else + //$$ final UUID uuid = user.getGameProfile().getId(); + //#endif //noinspection ConstantValue if (uuid == null) { LOGGER.warn("Failed to get player UUID. Unable to use World Host."); 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 c056c00..b61ff96 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 @@ -78,7 +78,11 @@ protected void init() { usernameField = addWidget(new EditBox(font, width / 2 - 100, 66, 200, 20, FRIEND_USERNAME_TEXT)); usernameField.setMaxLength(36); + //#if MC >= 1.19.4 usernameField.setFocused(true); + //#else + //$$ usernameField.setFocus(true); + //#endif if (friendProfile != null) { usernameField.setValue(friendProfile.getName()); } @@ -176,7 +180,12 @@ public void render( final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(friendProfile); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); - final int size = addFriendButton.getY() - 110; + //#if MC >= 1.19.4 + final int addFriendY = addFriendButton.getY(); + //#else + //$$ final int addFriendY = addFriendButton.y; + //#endif + final int size = addFriendY - 110; final int x = width / 2 - size / 2; blit(context, skinTexture, x, 98, size, size, 8, 8, 8, 8, 64, 64); blit(context, skinTexture, x, 98, size, size, 40, 8, 8, 8, 64, 64); diff --git a/src/main/java/io/github/gaming32/worldhost/versions/Pattern.java b/src/main/java/io/github/gaming32/worldhost/versions/Pattern.java deleted file mode 100644 index d76e947..0000000 --- a/src/main/java/io/github/gaming32/worldhost/versions/Pattern.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.github.gaming32.worldhost.versions; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.METHOD) -public @interface Pattern { -} diff --git a/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java b/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java deleted file mode 100644 index d773235..0000000 --- a/src/main/java/io/github/gaming32/worldhost/versions/Patterns.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.gaming32.worldhost.versions; - -import net.minecraft.client.User; -import net.minecraft.client.gui.components.AbstractWidget; -import net.minecraft.client.gui.components.EditBox; - -import java.util.UUID; - -public class Patterns { - @Pattern - public static void setFocused(EditBox editBox, boolean focus) { - //#if MC >= 1.19.4 - editBox.setFocused(focus); - //#else - //$$ editBox.setFocus(focus); - //#endif - } - - @Pattern - public static int getY(AbstractWidget widget) { - //#if MC >= 1.19.4 - return widget.getY(); - //#else - //$$ return widget.y; - //#endif - } - - @Pattern - public static UUID getProfileId(User user) { - //#if MC >= 1.19.2 - return user.getProfileId(); - //#else - //$$ return user.getGameProfile().getId(); - //#endif - } -} From 46bbc4915b0b0b683acde72dd710dd0acf09d263 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 11:16:09 -0500 Subject: [PATCH 10/24] Use var where it saves imports --- .../gaming32/worldhost/FriendsListUpdate.java | 1 + .../gaming32/worldhost/ProxyClient.java | 3 +- .../github/gaming32/worldhost/WorldHost.java | 48 ++++++++++--------- .../worldhost/gui/screen/AddFriendScreen.java | 3 +- .../worldhost/gui/screen/FriendsScreen.java | 11 ++--- .../gui/screen/OnlineFriendsScreen.java | 10 ++-- .../worldhost/gui/screen/WorldHostScreen.java | 3 -- .../worldhost/gui/widget/FriendsButton.java | 3 +- .../mixin/MixinSelectWorldScreen.java | 6 ++- .../worldhost/protocol/ProtocolClient.java | 6 ++- .../protocol/WorldHostC2SMessage.java | 5 +- .../protocol/WorldHostS2CMessage.java | 23 ++++----- .../gaming32/worldhost/toast/WHToast.java | 5 +- 13 files changed, 64 insertions(+), 63 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java b/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java index c8a9fed..afba0f5 100644 --- a/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java +++ b/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java @@ -4,6 +4,7 @@ import java.util.UUID; public interface FriendsListUpdate { + // TODO: fastutil void friendsListUpdate(Map friends); default void friendsListUpdate() { diff --git a/src/main/java/io/github/gaming32/worldhost/ProxyClient.java b/src/main/java/io/github/gaming32/worldhost/ProxyClient.java index 822b732..4a22da5 100644 --- a/src/main/java/io/github/gaming32/worldhost/ProxyClient.java +++ b/src/main/java/io/github/gaming32/worldhost/ProxyClient.java @@ -3,7 +3,6 @@ import io.github.gaming32.worldhost.protocol.proxy.ProxyPassthrough; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; @@ -38,7 +37,7 @@ public ProxyClient( public void run() { WorldHost.LOGGER.info("Starting proxy client from {}", remoteAddress); try { - final InputStream is = socket.getInputStream(); + final var is = socket.getInputStream(); final byte[] b = new byte[0xffff]; int n; while ((n = is.read(b)) != -1) { diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index 12cf767..17572c5 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -14,7 +14,6 @@ import io.github.gaming32.worldhost.toast.WHToast; import io.github.gaming32.worldhost.upnp.Gateway; import io.github.gaming32.worldhost.upnp.GatewayFinder; -import io.github.gaming32.worldhost.upnp.UPnPErrors; import io.github.gaming32.worldhost.versions.Components; import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -27,8 +26,6 @@ import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.resolver.ServerAddress; import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.client.resources.SkinManager; -import net.minecraft.client.server.IntegratedServer; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.ClickEvent; @@ -37,9 +34,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.players.GameProfileCache; import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.impl.client.CloseableHttpClient; @@ -49,7 +43,11 @@ import org.quiltmc.parsers.json.JsonWriter; import org.semver4j.Semver; -import java.io.*; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.UncheckedIOException; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; @@ -58,7 +56,16 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.security.SecureRandom; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.TreeMap; +import java.util.UUID; +import java.util.WeakHashMap; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.function.Consumer; @@ -84,7 +91,6 @@ //#endif //#if MC >= 1.20.2 -import com.mojang.authlib.yggdrasil.ProfileResult; import net.minecraft.client.resources.PlayerSkin; //#endif @@ -93,8 +99,6 @@ import net.fabricmc.loader.api.FabricLoader; //#if MC >= 1.18.2 import dev.isxander.mainmenucredits.MainMenuCredits; -import dev.isxander.mainmenucredits.config.MMCConfig; -import dev.isxander.mainmenucredits.config.MMCConfigEntry; import io.github.gaming32.worldhost.gui.OnlineStatusLocation; //#endif //#else @@ -185,7 +189,7 @@ public class WorldHost public static final WorldHostConfig CONFIG = new WorldHostConfig(); private static List wordsForCid; - private static Map wordsForCidInverse; + private static Map wordsForCidInverse; // TODO: fastutil public static final long MAX_CONNECTION_IDS = 1L << 42; @@ -349,7 +353,7 @@ public static void tickHandler() { LOGGER.info("Finished authenticating with WH server. Requesting friends list."); ONLINE_FRIENDS.clear(); protoClient.listOnline(CONFIG.getFriends()); - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server != null && server.isPublished()) { protoClient.publishedWorld(CONFIG.getFriends()); } @@ -373,7 +377,7 @@ public static void commandRegistrationHandler(CommandDispatcher { try { final int port = ctx.getSource().getServer().getPort(); - final UPnPErrors.AddPortMappingErrors error = upnpGateway.openPort(port, 60, false); + final var error = upnpGateway.openPort(port, 60, false); if (error == null) { ctx.getSource().sendSuccess( //#if MC >= 1.20.0 @@ -457,7 +461,7 @@ public static GameProfileCache getProfileCache() { } public static CompletableFuture getInsecureSkinLocation(GameProfile gameProfile) { - final SkinManager skinManager = Minecraft.getInstance().getSkinManager(); + final var skinManager = Minecraft.getInstance().getSkinManager(); //#if MC >= 1.20.2 return skinManager.getOrLoad(gameProfile).thenApply(PlayerSkin::texture); //#elseif MC >= 1.19.2 @@ -497,7 +501,7 @@ public static GameProfile fetchProfile(MinecraftSessionService sessionService, U //#if MC < 1.20.2 //$$ return sessionService.fillProfileProperties(fallback != null ? fallback : new GameProfile(uuid, null), false); //#else - final ProfileResult result = sessionService.fetchProfile(uuid, false); + final var result = sessionService.fetchProfile(uuid, false); if (result == null) { return fallback != null ? fallback : new GameProfile(uuid, ""); } @@ -710,7 +714,7 @@ private static int ipCommand(CommandContext ctx) { } public static void proxyConnect(long connectionId, InetAddress remoteAddr, Supplier proxy) { - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server == null || !server.isPublished()) { if (protoClient != null) { protoClient.proxyDisconnect(connectionId); @@ -770,8 +774,8 @@ public static String getModVersion(String modId) { //#if FABRIC && MC >= 1.18.2 public static int getMMCLines(boolean isPause) { if (FabricLoader.getInstance().isModLoaded("isxander-main-menu-credits")) { - final MMCConfig baseConfig = MainMenuCredits.getInstance().getConfig(); - final MMCConfigEntry config = isPause ? baseConfig.PAUSE_MENU : baseConfig.MAIN_MENU; + final var baseConfig = MainMenuCredits.getInstance().getConfig(); + final var config = isPause ? baseConfig.PAUSE_MENU : baseConfig.MAIN_MENU; return (CONFIG.getOnlineStatusLocation() == OnlineStatusLocation.RIGHT ? config.getBottomRight() : config.getBottomLeft()).size(); } return 0; @@ -792,12 +796,12 @@ public static T httpGet( } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getMessage(), e); } - try (CloseableHttpResponse response = client.execute(new HttpGet(uri))) { - final StatusLine status = response.getStatusLine(); + try (var response = client.execute(new HttpGet(uri))) { + final var status = response.getStatusLine(); if (status.getStatusCode() != 200) { throw new IOException("Failed to GET " + uri + ": " + status.getStatusCode() + " " + status.getReasonPhrase()); } - final HttpEntity entity = response.getEntity(); + final var entity = response.getEntity(); if (entity == null) { throw new IOException("GET " + uri + " returned no body."); } 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 b61ff96..2c30032 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 @@ -11,7 +11,6 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.players.GameProfileCache; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFW; @@ -177,7 +176,7 @@ public void render( if (friendProfile != null) { assert minecraft != null; - final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(friendProfile); + final var skinTexture = WorldHost.getSkinLocationNow(friendProfile); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); //#if MC >= 1.19.4 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 34e2712..6204f9b 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 @@ -12,12 +12,9 @@ import net.minecraft.client.gui.components.ObjectSelectionList; import net.minecraft.client.gui.screens.ConfirmScreen; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.server.IntegratedServer; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; -import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -124,7 +121,7 @@ private void addFriendAndUpdate(GameProfile profile) { public static void addFriend(GameProfile profile) { WorldHost.CONFIG.getFriends().add(profile.getId()); WorldHost.saveConfig(); - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server != null && server.isPublished() && WorldHost.protoClient != null) { WorldHost.protoClient.publishedWorld(Collections.singleton(profile.getId())); } @@ -157,7 +154,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { if (mouseX >= textX && mouseX <= textX + textWidth) { final int textY = height - 66 - font.lineHeight / 2; if (mouseY >= textY && mouseY <= textY + font.lineHeight) { - final Style component = font.getSplitter().componentStyleAtWidth(BEDROCK_FRIENDS_TEXT, (int)Math.round(mouseX) - textX); + final var component = font.getSplitter().componentStyleAtWidth(BEDROCK_FRIENDS_TEXT, (int)Math.round(mouseX) - textX); if (component != null) { handleComponentClicked(component); return true; @@ -226,7 +223,7 @@ public void render( //#endif int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta ) { - final ResourceLocation skinTexture = WorldHost.getSkinLocationNow(profile); + final var skinTexture = WorldHost.getSkinLocationNow(profile); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); blit(context, skinTexture, x, y, 32, 32, 8, 8, 8, 8, 64, 64); @@ -247,7 +244,7 @@ public void maybeRemove() { WorldHost.CONFIG.getFriends().remove(profile.getId()); WorldHost.saveConfig(); FriendsScreen.this.list.updateEntries(); - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server != null && server.isPublished() && WorldHost.protoClient != null) { WorldHost.protoClient.closedWorld(Collections.singleton(profile.getId())); } 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 606951b..b7d5df7 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 @@ -21,14 +21,18 @@ import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.status.ServerStatus; import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; //#if MC >= 1.20.0 import net.minecraft.client.gui.GuiGraphics; @@ -419,7 +423,7 @@ public void render( private void updateServerInfo() { serverInfo.name = getName(); - final ServerStatus metadata = WorldHost.ONLINE_FRIEND_PINGS.get(profile.getId()); + final var metadata = WorldHost.ONLINE_FRIEND_PINGS.get(profile.getId()); if (metadata == null) { serverInfo.status = Components.EMPTY; serverInfo.motd = Components.EMPTY; 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 847c31a..f3eaf47 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 @@ -21,10 +21,7 @@ //#if MC < 1.19.4 //$$ import net.minecraft.client.Minecraft; -//$$ import net.minecraft.client.gui.components.Button; -//$$ import org.jetbrains.annotations.NotNull; //$$ -//$$ import java.util.List; //$$ import java.util.function.Consumer; //#endif diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java index 7efa365..9e85017 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java @@ -7,7 +7,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; -import net.minecraft.network.chat.Component; import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -35,7 +34,7 @@ public FriendsButton(int x, int y, int width, int height, OnPress onPress) { @Override public void friendsListUpdate(Map friends) { final int online = friends.size(); - final Component baseText = WorldHostComponents.FRIENDS.copy().append(" " + online + " "); + final var baseText = WorldHostComponents.FRIENDS.copy().append(" " + online + " "); setMessage(baseText); final Font textRenderer = Minecraft.getInstance().font; bgX = width / 2 - textRenderer.width(baseText) / 2 + textRenderer.width(WorldHostComponents.FRIENDS.copy().append(" ")); 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 42275b9..3bdd0b0 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinSelectWorldScreen.java @@ -14,7 +14,11 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(SelectWorldScreen.class) diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java index 8b92f8c..a4f6f77 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java @@ -9,7 +9,11 @@ import org.apache.commons.io.input.CountingInputStream; import org.jetbrains.annotations.Nullable; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.EOFException; +import java.io.IOException; import java.net.Socket; import java.net.SocketException; import java.util.Collection; diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java index 46a6e66..6481b94 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostC2SMessage.java @@ -1,7 +1,6 @@ package io.github.gaming32.worldhost.protocol; import io.github.gaming32.worldhost.WorldHost; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.status.ServerStatus; import java.io.DataOutputStream; @@ -87,7 +86,7 @@ record QueryResponse(long connectionId, ServerStatus metadata) implements WorldH public void encode(DataOutputStream dos) throws IOException { dos.writeByte(7); dos.writeLong(connectionId); - final FriendlyByteBuf buf = WorldHost.writeServerStatus(metadata); + final var buf = WorldHost.writeServerStatus(metadata); dos.writeInt(buf.readableBytes()); buf.readBytes(dos, buf.readableBytes()); } @@ -123,7 +122,7 @@ record NewQueryResponse(long connectionId, ServerStatus metadata) implements Wor public void encode(DataOutputStream dos) throws IOException { dos.writeByte(11); dos.writeLong(connectionId); - final FriendlyByteBuf buf = WorldHost.writeServerStatus(metadata); + final var buf = WorldHost.writeServerStatus(metadata); buf.readBytes(dos, buf.readableBytes()); } } 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 e858040..58ac4b2 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -7,15 +7,10 @@ import io.github.gaming32.worldhost.gui.screen.JoiningWorldHostScreen; import io.github.gaming32.worldhost.protocol.proxy.ProxyProtocolClient; import io.github.gaming32.worldhost.toast.WHToast; -import io.github.gaming32.worldhost.upnp.UPnPErrors; import io.github.gaming32.worldhost.versions.Components; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.DisconnectedScreen; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.server.IntegratedServer; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.status.ServerStatus; import java.io.DataInputStream; @@ -49,7 +44,7 @@ record IsOnlineTo(UUID user) implements WorldHostS2CMessage { @Override public void handle(ProtocolClient client) { if (WorldHost.isFriend(user)) { - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server != null && server.isPublished()) { client.publishedWorld(List.of(user)); } @@ -65,7 +60,7 @@ public void handle(ProtocolClient client) { if (attemptingToJoin == null || ownerCid != attemptingToJoin) return; final Minecraft minecraft = Minecraft.getInstance(); assert minecraft.screen != null; - Screen parentScreen = minecraft.screen; + var parentScreen = minecraft.screen; if (parentScreen instanceof JoiningWorldHostScreen joinScreen) { parentScreen = joinScreen.parent; } @@ -130,11 +125,11 @@ record RequestJoin(UUID user, long connectionId) implements WorldHostS2CMessage @Override public void handle(ProtocolClient client) { if (WorldHost.isFriend(user)) { - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server == null || !server.isPublished()) return; if (WorldHost.upnpGateway != null && !WorldHost.CONFIG.isNoUPnP()) { try { - final UPnPErrors.AddPortMappingErrors error = WorldHost.upnpGateway.openPort( + final var error = WorldHost.upnpGateway.openPort( server.getPort(), 60, false ); if (error == null) { @@ -170,7 +165,7 @@ record QueryRequest(UUID friend, long connectionId) implements WorldHostS2CMessa @Override public void handle(ProtocolClient client) { if (WorldHost.isFriend(friend)) { - final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); + final var server = Minecraft.getInstance().getSingleplayerServer(); if (server != null) { client.enqueue(new WorldHostC2SMessage.NewQueryResponse(connectionId, server.getStatus())); } @@ -244,7 +239,7 @@ record OutdatedWorldHost(String recommendedVersion) implements WorldHostS2CMessa @Override public void handle(ProtocolClient client) { final String currentVersion = WorldHost.getModVersion(WorldHost.MOD_ID); - final Component message = Components.translatable("world-host.outdated_world_host.desc", currentVersion, recommendedVersion); + final var message = Components.translatable("world-host.outdated_world_host.desc", currentVersion, recommendedVersion); WorldHost.LOGGER.info(message.getString()); if (!WorldHost.CONFIG.isShowOutdatedWorldHost()) return; WorldHost.checkForUpdates().thenAcceptAsync(version -> { @@ -267,7 +262,7 @@ public void handle(ProtocolClient client) { if (client.getAttemptingToJoin() == null || client.getAttemptingToJoin() != connectionId) return; client.setAttemptingToJoin(null); final Minecraft minecraft = Minecraft.getInstance(); - Screen parentScreen = minecraft.screen; + var parentScreen = minecraft.screen; if (parentScreen instanceof JoiningWorldHostScreen joinScreen) { parentScreen = joinScreen.parent; } @@ -312,7 +307,7 @@ static WorldHostS2CMessage decode(DataInputStream dis) throws IOException { case 7 -> new QueryRequest(readUuid(dis), dis.readLong()); case 8 -> { final UUID friend = readUuid(dis); - final FriendlyByteBuf buf = WorldHost.createByteBuf(); + final var buf = WorldHost.createByteBuf(); buf.writeBytes(dis, dis.readInt()); ServerStatus serverStatus; try { @@ -336,7 +331,7 @@ static WorldHostS2CMessage decode(DataInputStream dis) throws IOException { case 15 -> new ConnectionNotFound(dis.readLong()); case 16 -> { final UUID friend = readUuid(dis); - final FriendlyByteBuf buf = WorldHost.createByteBuf(); + final var buf = WorldHost.createByteBuf(); buf.writeBytes(dis.readAllBytes()); ServerStatus serverStatus; try { diff --git a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java index 5d06ec1..bf94334 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java @@ -1,6 +1,5 @@ package io.github.gaming32.worldhost.toast; -import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.vertex.PoseStack; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; import io.github.gaming32.worldhost.versions.Components; @@ -113,7 +112,7 @@ public static void render( poseStack.pushPose(); poseStack.translate(0f, 0f, 100f); - final Window window = Minecraft.getInstance().getWindow(); + final var window = Minecraft.getInstance().getWindow(); final int screenWidth = window.getGuiScaledWidth(); final int screenHeight = window.getGuiScaledHeight(); @@ -134,7 +133,7 @@ public static boolean click(double mouseX, double mouseY, int button) { return false; } - final Window window = Minecraft.getInstance().getWindow(); + final var window = Minecraft.getInstance().getWindow(); final int screenWidth = window.getGuiScaledWidth(); final int screenHeight = window.getGuiScaledHeight(); From cbd2aca344766695e4981d1e9f8484330c493f2a Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 11:22:45 -0500 Subject: [PATCH 11/24] Migrate some stuff to fastutil --- .../gaming32/worldhost/FriendsListUpdate.java | 6 +++--- .../io/github/gaming32/worldhost/WorldHost.java | 17 ++++++++++------- .../gui/screen/OnlineFriendsScreen.java | 4 ++-- .../worldhost/gui/widget/FriendsButton.java | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java b/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java index afba0f5..550d21b 100644 --- a/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java +++ b/src/main/java/io/github/gaming32/worldhost/FriendsListUpdate.java @@ -1,11 +1,11 @@ package io.github.gaming32.worldhost; -import java.util.Map; +import it.unimi.dsi.fastutil.objects.Object2LongMap; + import java.util.UUID; public interface FriendsListUpdate { - // TODO: fastutil - void friendsListUpdate(Map friends); + void friendsListUpdate(Object2LongMap friends); default void friendsListUpdate() { friendsListUpdate(WorldHost.ONLINE_FRIENDS); diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index 17572c5..f7c2c2f 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -18,6 +18,10 @@ import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2LongMap; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; @@ -58,12 +62,10 @@ import java.security.SecureRandom; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.TreeMap; import java.util.UUID; import java.util.WeakHashMap; import java.util.concurrent.CompletableFuture; @@ -189,11 +191,11 @@ public class WorldHost public static final WorldHostConfig CONFIG = new WorldHostConfig(); private static List wordsForCid; - private static Map wordsForCidInverse; // TODO: fastutil + private static Object2IntMap wordsForCidInverse; public static final long MAX_CONNECTION_IDS = 1L << 42; - public static final Map ONLINE_FRIENDS = new LinkedHashMap<>(); + public static final Object2LongMap ONLINE_FRIENDS = new Object2LongLinkedOpenHashMap<>(); public static final Map ONLINE_FRIEND_PINGS = new HashMap<>(); public static final Set ONLINE_FRIEND_UPDATES = Collections.newSetFromMap(new WeakHashMap<>()); @@ -242,7 +244,8 @@ private static void init() { if (wordsForCid.size() != (1 << 14)) { throw new RuntimeException("Expected WORDS_FOR_CID to have " + (1 << 14) + " elements, but it has " + wordsForCid.size() + " elements."); } - wordsForCidInverse = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + wordsForCidInverse = new Object2IntAVLTreeMap<>(String.CASE_INSENSITIVE_ORDER); + wordsForCidInverse.defaultReturnValue(-1); for (int i = 0; i < wordsForCid.size(); i++) { wordsForCidInverse.put(wordsForCid.get(i), i); } @@ -643,8 +646,8 @@ public static Long tryParseConnectionId(String str) { long result = 0L; int shift = 0; for (final String word : words) { - final Integer part = wordsForCidInverse.get(word); - if (part == null) { + final int part = wordsForCidInverse.getInt(word); + if (part == -1) { return null; } result |= (long)part << shift; 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 b7d5df7..9d3fbf1 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 @@ -9,6 +9,7 @@ import io.github.gaming32.worldhost.gui.widget.FriendsButton; import io.github.gaming32.worldhost.mixin.ServerStatusPingerAccessor; import io.github.gaming32.worldhost.versions.Components; +import it.unimi.dsi.fastutil.objects.Object2LongMap; import net.minecraft.ChatFormatting; import net.minecraft.SharedConstants; import net.minecraft.Util; @@ -31,7 +32,6 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.UUID; //#if MC >= 1.20.0 @@ -212,7 +212,7 @@ private void updateButtonActivationStates() { } @Override - public void friendsListUpdate(Map friends) { + public void friendsListUpdate(Object2LongMap friends) { final var newFriends = new LinkedHashMap<>(friends); for (int i = list.children().size() - 1; i >= 0; i--) { final UUID uuid = list.children().get(i).profile.getId(); diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java index 9e85017..d158679 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java @@ -4,12 +4,12 @@ import io.github.gaming32.worldhost.WorldHostComponents; import io.github.gaming32.worldhost.gui.screen.WorldHostScreen; import io.github.gaming32.worldhost.versions.Components; +import it.unimi.dsi.fastutil.objects.Object2LongMap; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; import org.jetbrains.annotations.NotNull; -import java.util.Map; import java.util.UUID; //#if MC >= 1.20.0 @@ -32,7 +32,7 @@ public FriendsButton(int x, int y, int width, int height, OnPress onPress) { } @Override - public void friendsListUpdate(Map friends) { + public void friendsListUpdate(Object2LongMap friends) { final int online = friends.size(); final var baseText = WorldHostComponents.FRIENDS.copy().append(" " + online + " "); setMessage(baseText); From 70fa51448db12671cc6688dbd94f34d65362e12c Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 11:31:22 -0500 Subject: [PATCH 12/24] Fix build and a deprecation --- .../gaming32/worldhost/gui/screen/OnlineFriendsScreen.java | 4 ++++ .../gaming32/worldhost/protocol/WorldHostS2CMessage.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 9d3fbf1..396355c 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 @@ -50,6 +50,10 @@ //#endif //#endif +//#if MC < 1.19.4 +//$$ import java.util.Objects; +//#endif + public class OnlineFriendsScreen extends WorldHostScreen implements FriendsListUpdate { private static final ResourceLocation GUI_ICONS_LOCATION = new ResourceLocation("textures/gui/icons.png"); //#if MC >= 1.20.2 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 58ac4b2..b2d529f 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -115,7 +115,7 @@ public void handle(ProtocolClient client) { record ClosedWorld(UUID user) implements WorldHostS2CMessage { @Override public void handle(ProtocolClient client) { - WorldHost.ONLINE_FRIENDS.remove(user); + WorldHost.ONLINE_FRIENDS.removeLong(user); WorldHost.ONLINE_FRIEND_PINGS.remove(user); WorldHost.ONLINE_FRIEND_UPDATES.forEach(FriendsListUpdate::friendsListUpdate); } From 6636c289f7e740431357f9d10bd0c91486269b3c Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 11:55:21 -0500 Subject: [PATCH 13/24] Address some warnings --- .../gaming32/worldhost/gui/widget/FriendsButton.java | 2 +- .../worldhost/gui/widget/OnlineStatusButton.java | 12 ++++++------ .../gaming32/worldhost/protocol/ProtocolClient.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java index d158679..0c04298 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/FriendsButton.java @@ -18,7 +18,7 @@ //$$ import com.mojang.blaze3d.vertex.PoseStack; //#endif -public class FriendsButton extends Button implements FriendsListUpdate { +public final class FriendsButton extends Button implements FriendsListUpdate { private int bgX, bgWidth; public FriendsButton(int x, int y, int width, int height, OnPress onPress) { 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 73f7803..27bc6ef 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 @@ -13,6 +13,7 @@ import net.minecraft.network.chat.Style; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.function.Supplier; //#if MC >= 1.20.0 @@ -27,19 +28,18 @@ //$$ import io.github.gaming32.worldhost.gui.PlainTextButton; //#endif -public class OnlineStatusButton extends PlainTextButton { +public final class OnlineStatusButton extends PlainTextButton { private static final ChatFormatting[] COLORS = { ChatFormatting.RED, ChatFormatting.GOLD, ChatFormatting.DARK_GREEN }; - @SuppressWarnings("unchecked") - private static final Supplier[] TEXTS = new Supplier[] { + private static final List> TEXTS = List.of( () -> Components.translatable("world-host.online_status.offline", WorldHost.reconnectDelay / 20 + 1), () -> Components.translatable("world-host.online_status.connecting"), () -> Components.translatable("world-host.online_status.online") - }; + ); private final int alignedX; private final boolean rightAlign; @@ -87,7 +87,7 @@ private static Component generateStatusComponent() { return Components.translatable( "world-host.online_status", Components.literal("\u25cf").withStyle(COLORS[status]), - TEXTS[status].get() + TEXTS.get(status).get() ); } @@ -110,7 +110,7 @@ private static Component generateStatusComponent() { final int status = getStatus(); if (status != currentStatus || (status == 0 && (WorldHost.reconnectDelay + 1) % 20 == 0)) { currentStatus = status; - final var accessor = (PlainTextButtonAccessor)this; + final var accessor = (PlainTextButtonAccessor)(Object)this; final Component message = generateStatusComponent(); setMessage(message); accessor.setPTBMessage(message); diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java index a4f6f77..f5fa30f 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java @@ -24,7 +24,7 @@ import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; -public class ProtocolClient implements AutoCloseable, ProxyPassthrough { +public final class ProtocolClient implements AutoCloseable, ProxyPassthrough { public static final int PROTOCOL_VERSION = 5; private final String originalHost; From 3eb1e7faf4d0555009b168128a393b833f1846e8 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 12:27:09 -0500 Subject: [PATCH 14/24] Address more warnings --- .../gaming32/worldhost/gui/screen/FriendsScreen.java | 2 +- .../gaming32/worldhost/gui/screen/OnlineFriendsScreen.java | 7 ++++--- .../gaming32/worldhost/gui/widget/CustomCycleButton.java | 7 +++++++ .../github/gaming32/worldhost/gui/widget/EnumButton.java | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) 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 6204f9b..2fb1887 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 @@ -258,7 +258,7 @@ public void maybeRemove() { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - list.setSelected(this); + FriendsScreen.this.list.setSelected(this); return false; } } 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 396355c..aab552a 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 @@ -29,7 +29,6 @@ import org.lwjgl.glfw.GLFW; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.UUID; @@ -50,7 +49,9 @@ //#endif //#endif -//#if MC < 1.19.4 +//#if MC >= 1.19.4 +import java.util.Arrays; +//#else //$$ import java.util.Objects; //#endif @@ -568,7 +569,7 @@ private boolean uploadServerIcon( public boolean mouseClicked(double mouseX, double mouseY, int button) { select(this); - final double relX = mouseX - list.getRowLeft(); + final double relX = mouseX - OnlineFriendsScreen.this.list.getRowLeft(); if (relX < 32.0 && relX > 16.0) { connect(); return true; diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java index 99cf540..45903b3 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java @@ -110,6 +110,13 @@ public Component getMessage() { return result; } + //#if MC >= 1.19.4 + @Override + public final void setTooltip(@Nullable Tooltip tooltip) { + super.setTooltip(tooltip); + } + //#endif + @NotNull public abstract Component getValueMessage(); } diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java index 18c8110..cc6dcef 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/EnumButton.java @@ -8,7 +8,7 @@ import java.util.function.Consumer; -public class EnumButton & StringRepresentable> extends CustomCycleButton> { +public final class EnumButton & StringRepresentable> extends CustomCycleButton> { private final Component[] translations; public EnumButton( From 012caf667ec60506bdf3cf70c86e58a529926739 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 13:09:41 -0500 Subject: [PATCH 15/24] I don't know what to do about this warning. Suppression time --- .../worldhost/gui/widget/CustomCycleButton.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java b/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java index 45903b3..6879af2 100644 --- a/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java +++ b/src/main/java/io/github/gaming32/worldhost/gui/widget/CustomCycleButton.java @@ -27,7 +27,7 @@ public abstract class CustomCycleButton> ex private final T[] values; private int valueIndex; - public CustomCycleButton( + protected CustomCycleButton( int x, int y, int width, int height, @Nullable Component title, @@ -36,7 +36,8 @@ public CustomCycleButton( this(x, y, width, height, title, null, onUpdate, values); } - public CustomCycleButton( + @SuppressWarnings("this-escape") + protected CustomCycleButton( int x, int y, int width, int height, @Nullable Component title, @Nullable Component tooltip, @@ -110,13 +111,6 @@ public Component getMessage() { return result; } - //#if MC >= 1.19.4 - @Override - public final void setTooltip(@Nullable Tooltip tooltip) { - super.setTooltip(tooltip); - } - //#endif - @NotNull public abstract Component getValueMessage(); } From ef24c9b580b7609d96836524e93d8d00c47cee20 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 17:31:10 -0500 Subject: [PATCH 16/24] Migrate from JavaDowngrader to JvmDowngrader --- version.gradle.kts | 76 +++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/version.gradle.kts b/version.gradle.kts index 94f47b8..59cacb9 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -1,11 +1,10 @@ import com.replaymod.gradle.preprocess.PreprocessTask import groovy.lang.GroovyObjectSupport -import net.raphimc.javadowngrader.gradle.task.DowngradeSourceSetTask import xyz.wagyourtail.unimined.api.mapping.task.ExportMappingsTask import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask import xyz.wagyourtail.unimined.internal.mapping.MappingsProvider import xyz.wagyourtail.unimined.internal.mapping.task.ExportMappingsTaskImpl -import xyz.wagyourtail.unimined.internal.minecraft.MinecraftProvider +import xyz.wagyourtail.unimined.internal.minecraft.resolver.MinecraftDownloader import xyz.wagyourtail.unimined.util.sourceSets import java.nio.file.Path @@ -15,6 +14,7 @@ plugins { id("io.github.gaming32.gradle.preprocess") id("xyz.wagyourtail.unimined") id("com.modrinth.minotaur") version "2.+" + id("xyz.wagyourtail.jvmdowngrader") version "0.0.1-SNAPSHOT" } fun Any.setGroovyProperty(name: String, value: Any) = withGroovyBuilder { metaClass }.setProperty(this, name, value) @@ -48,6 +48,17 @@ repositories { maven("https://maven.neoforged.net/releases") } +java { + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +tasks.compileJava { + options.release = 17 + options.compilerArgs.add("-Xlint:all") +} + unimined.minecraft { version(mcVersionString) if ((mcVersion != 1_20_01 || !isForge) && mcVersion < 1_20_05) { @@ -111,6 +122,23 @@ unimined.minecraft { } else -> throw IllegalStateException() } + + val mcJavaVersion = (minecraftData as MinecraftDownloader).metadata.javaVersion + + if (mcJavaVersion < java.sourceCompatibility) { + println("Classes need downgrading to Java $mcJavaVersion") + + tasks.downgradeJar { + downgradeTo = mcJavaVersion + } + tasks.shadeDowngradedApi { + downgradeTo = mcJavaVersion + } + + defaultRemapJar = false + remap(tasks.shadeDowngradedApi.get(), "remapJar") + tasks.assemble.get().dependsOn("remapJar") + } } val minecraft = unimined.minecrafts[sourceSets.main.get()] @@ -154,27 +182,13 @@ if (isForge) { mappingsConfig.setGroovyProperty("tinyMappingsWithSrg", tinyMappingsWithSrg.toPath()) } -buildscript { - repositories { - maven("https://maven.lenni0451.net/everything") - } - - dependencies { - classpath("net.raphimc.javadowngrader:gradle-plugin:1.1.1-SNAPSHOT") - } -} - repositories { maven("https://maven.quiltmc.org/repository/release/") - maven("https://maven.terraformersmc.com/releases") - maven("https://maven.isxander.dev/releases") - maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") - maven("https://repo.viaversion.com") - + maven("https://maven.wagyourtail.xyz/snapshots") maven("https://jitpack.io") } @@ -284,17 +298,6 @@ dependencies { compileOnly("com.demonwav.mcdev:annotations:2.0.0") } -java { - withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -tasks.compileJava { - options.release = 17 - options.compilerArgs.add("-Xlint:all") -} - preprocess { fun Boolean.toInt() = if (this) 1 else 0 @@ -393,8 +396,7 @@ tasks.processResources { )) { expand(mapOf( "version" to modVersion, - "mc_version" to mcVersionString, - "java_version" to "JAVA_${mcJavaVersion.majorVersion}" + "mc_version" to mcVersionString )) } @@ -434,17 +436,3 @@ tasks.withType { } from("$rootDir/LICENSE") } - -val mcJavaVersion = (minecraft as MinecraftProvider).minecraftData.metadata.javaVersion - -if (mcJavaVersion < java.sourceCompatibility) { - val targetClassVersion = mcJavaVersion.ordinal + 45 - println("Classes need downgrading to Java $mcJavaVersion ($targetClassVersion)") - - val downgradeClasses by tasks.registering(DowngradeSourceSetTask::class) { - dependsOn(tasks.classes) - sourceSet.set(sourceSets["main"]) - targetVersion.set(targetClassVersion) - } - tasks.classes.get().finalizedBy(downgradeClasses) -} From 4be1c0479e37f52237d79648a65b9e108f64dae9 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Thu, 9 May 2024 17:57:08 -0500 Subject: [PATCH 17/24] Update to Java 21 --- .../protocol/proxy/ProxyProtocolClient.java | 15 +++++++-------- .../github/gaming32/worldhost/toast/WHToast.java | 6 +++--- .../github/gaming32/worldhost/upnp/Gateway.java | 4 ++-- version.gradle.kts | 6 +++--- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java index 22fd6ef..b8858c8 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java @@ -76,14 +76,13 @@ public ProxyProtocolClient(String host, int port, long connectionId, String base final DataInputStream dis = new DataInputStream(fSocket.getInputStream()); while (!closed) { final ProxyMessage message = ProxyMessage.read(dis); - if (message instanceof ProxyMessage.Open open) { - WorldHost.proxyConnect(open.getConnectionId(), open.getAddress(), () -> WorldHost.proxyProtocolClient); - } else if (message instanceof ProxyMessage.Packet packet) { - WorldHost.proxyPacket(packet.getConnectionId(), packet.getBuffer()); - } else if (message instanceof ProxyMessage.Close close) { - WorldHost.proxyDisconnect(close.getConnectionId()); - } else { - throw new AssertionError("If..elseif for ProxyMessage should be exhaustive"); + switch (message) { + case ProxyMessage.Open open -> + WorldHost.proxyConnect(open.getConnectionId(), open.getAddress(), () -> WorldHost.proxyProtocolClient); + case ProxyMessage.Packet packet -> + WorldHost.proxyPacket(packet.getConnectionId(), packet.getBuffer()); + case ProxyMessage.Close close -> + WorldHost.proxyDisconnect(close.getConnectionId()); } } } catch (Exception e) { diff --git a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java index bf94334..393d099 100644 --- a/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java +++ b/src/main/java/io/github/gaming32/worldhost/toast/WHToast.java @@ -59,9 +59,9 @@ static void add(ToastInstance toast) { toast.calculateText(); playSound(toast.important ? IMPORTANT : REGULAR); if (!TOASTS.isEmpty()) { - if (Y_OFFSET + 2 * toast.height + GAP <= TOASTS.get(0).y) { + if (Y_OFFSET + 2 * toast.height + GAP <= TOASTS.getFirst().y) { toast.y = Y_OFFSET; - TOASTS.add(0, toast); + TOASTS.addFirst(toast); return; } for (int i = 0; i < TOASTS.size() - 1; i++) { @@ -73,7 +73,7 @@ static void add(ToastInstance toast) { return; } } - final ToastInstance lastToast = TOASTS.get(TOASTS.size() - 1); + final ToastInstance lastToast = TOASTS.getLast(); toast.y = lastToast.y + lastToast.height + GAP; } else { toast.y = Y_OFFSET; diff --git a/src/main/java/io/github/gaming32/worldhost/upnp/Gateway.java b/src/main/java/io/github/gaming32/worldhost/upnp/Gateway.java index 31f8ba4..11ac7d7 100644 --- a/src/main/java/io/github/gaming32/worldhost/upnp/Gateway.java +++ b/src/main/java/io/github/gaming32/worldhost/upnp/Gateway.java @@ -28,7 +28,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import java.net.HttpURLConnection; import java.net.InetAddress; -import java.net.URL; +import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; @@ -113,7 +113,7 @@ private Map command(String action, Map params) t } soap.append(""); byte[] req = soap.toString().getBytes(); - HttpURLConnection conn = (HttpURLConnection) new URL(controlURL).openConnection(); + HttpURLConnection conn = (HttpURLConnection) new URI(controlURL).toURL().openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "text/xml"); diff --git a/version.gradle.kts b/version.gradle.kts index 59cacb9..f8c49b3 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -50,12 +50,12 @@ repositories { java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.compileJava { - options.release = 17 + options.release = 21 options.compilerArgs.add("-Xlint:all") } From c23daaab61be63d7c323c0e72e71f2abd568d608 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Fri, 10 May 2024 12:03:48 -0500 Subject: [PATCH 18/24] Components.immutable -> Components.nullToEmpty --- .../gaming32/worldhost/gui/screen/FriendsScreen.java | 2 +- .../gaming32/worldhost/protocol/ProtocolClient.java | 6 +++--- .../gaming32/worldhost/protocol/WorldHostS2CMessage.java | 2 +- .../github/gaming32/worldhost/versions/Components.java | 9 +++++++-- 4 files changed, 12 insertions(+), 7 deletions(-) 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 2fb1887..f8bbd9c 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 @@ -210,7 +210,7 @@ public FriendsEntry(GameProfile profile) { @NotNull @Override public Component getNarration() { - return Components.immutable(getName()); + return Components.literal(getName()); } @Override diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java index f5fa30f..31f406c 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java @@ -64,7 +64,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { WorldHost.LOGGER.error("Failed to connect to {}.", target, e); if (failureToast) { WHToast.builder("world-host.wh_connect.connect_failed") - .description(Components.immutable(e.getLocalizedMessage())) + .description(Components.nullToEmpty(e.getLocalizedMessage())) .show(); } if (socket != null) { @@ -74,7 +74,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { WorldHost.LOGGER.error("Failed to close WH socket", e1); if (failureToast) { WHToast.builder("world-host.wh_connect.close_failed") - .description(Components.immutable(e1.getLocalizedMessage())) + .description(Components.nullToEmpty(e1.getLocalizedMessage())) .show(); } } @@ -170,7 +170,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { WorldHost.LOGGER.error("Failed to close WH socket.", e); if (WorldHost.CONFIG.isEnableReconnectionToasts()) { WHToast.builder("world-host.wh_connect.close_failed") - .description(Components.immutable(e.getLocalizedMessage())) + .description(Components.nullToEmpty(e.getLocalizedMessage())) .show(); } } 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 b2d529f..7c9188e 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -31,7 +31,7 @@ public Error(String message) { public void handle(ProtocolClient client) { if (critical) { WHToast.builder("world-host.protocol_error_occurred") - .description(Components.immutable(message)) + .description(Components.literal(message)) .show(); throw new RuntimeException(message); } else { diff --git a/src/main/java/io/github/gaming32/worldhost/versions/Components.java b/src/main/java/io/github/gaming32/worldhost/versions/Components.java index 25eab95..590d1a6 100644 --- a/src/main/java/io/github/gaming32/worldhost/versions/Components.java +++ b/src/main/java/io/github/gaming32/worldhost/versions/Components.java @@ -3,6 +3,7 @@ import com.demonwav.mcdev.annotations.Translatable; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; @@ -13,7 +14,11 @@ //#endif public class Components { - public static final Component EMPTY = immutable(""); + //#if MC >= 1.19.2 + public static final Component EMPTY = CommonComponents.EMPTY; + //#else + //$$ public static final Component EMPTY = TextComponent.EMPTY; + //#endif public static MutableComponent literal(String text) { //#if MC >= 1.19.1 @@ -41,7 +46,7 @@ public static MutableComponent translatable(@Translatable(foldMethod = true) Str //#endif } - public static Component immutable(String text) { + public static Component nullToEmpty(String text) { return Component.nullToEmpty(text); } From 509b2a4030d15511681a331d388f02e48faece97 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Fri, 10 May 2024 18:23:49 -0500 Subject: [PATCH 19/24] Switch to virtual threads --- .../github/gaming32/worldhost/IOFunction.java | 1 + .../github/gaming32/worldhost/ProxyClient.java | 12 ++++++++---- .../io/github/gaming32/worldhost/WorldHost.java | 1 + .../worldhost/protocol/ProtocolClient.java | 17 ++++++----------- .../protocol/proxy/ProxyProtocolClient.java | 17 ++++++----------- version.gradle.kts | 3 +++ 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/IOFunction.java b/src/main/java/io/github/gaming32/worldhost/IOFunction.java index 4877b88..c38dcad 100644 --- a/src/main/java/io/github/gaming32/worldhost/IOFunction.java +++ b/src/main/java/io/github/gaming32/worldhost/IOFunction.java @@ -2,6 +2,7 @@ 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/ProxyClient.java b/src/main/java/io/github/gaming32/worldhost/ProxyClient.java index 4a22da5..d95d10d 100644 --- a/src/main/java/io/github/gaming32/worldhost/ProxyClient.java +++ b/src/main/java/io/github/gaming32/worldhost/ProxyClient.java @@ -9,7 +9,8 @@ import java.util.Arrays; import java.util.function.Supplier; -public class ProxyClient extends Thread { +public final class ProxyClient { + private final Thread thread; private final Socket socket; private final InetAddress remoteAddress; private final long connectionId; @@ -23,7 +24,7 @@ public ProxyClient( long connectionId, Supplier proxy ) throws IOException { - super("ProxyClient for " + connectionId); + thread = Thread.ofVirtual().name("ProxyClient for " + connectionId).unstarted(this::run); socket = new Socket(InetAddress.getLoopbackAddress(), port); this.remoteAddress = remoteAddress; this.connectionId = connectionId; @@ -33,8 +34,7 @@ public ProxyClient( } } - @Override - public void run() { + private void run() { WorldHost.LOGGER.info("Starting proxy client from {}", remoteAddress); try { final var is = socket.getInputStream(); @@ -58,6 +58,10 @@ public void run() { WorldHost.LOGGER.info("Proxy client connection for {} closed", remoteAddress); } + public void start() { + thread.start(); + } + public void close() { if (closed) return; closed = true; diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index f7c2c2f..fe9d820 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -455,6 +455,7 @@ public static String getName(GameProfile profile) { } // 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; } diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java index 31f406c..e5fd6ca 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/ProtocolClient.java @@ -47,7 +47,7 @@ public final class ProtocolClient implements AutoCloseable, ProxyPassthrough { public ProtocolClient(String host, boolean successToast, boolean failureToast) { this.originalHost = host; final HostAndPort target = HostAndPort.fromString(host).withDefaultPort(9646); - final Thread connectionThread = new Thread(() -> { + Thread.ofVirtual().name("WH-ConnectionThread").start(() -> { Socket socket = null; try { socket = new Socket(target.getHost(), target.getPort()); @@ -91,7 +91,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { } final Socket fSocket = socket; - final Thread sendThread = new Thread(() -> { + final Thread sendThread = Thread.ofVirtual().name("WH-SendThread").start(() -> { try { final DataOutputStream dos = new DataOutputStream(fSocket.getOutputStream()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -111,9 +111,9 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { WorldHost.LOGGER.error("Critical error in WH send thread", e); } close(); - }, "WH-SendThread"); + }); - final Thread recvThread = new Thread(() -> { + Thread.ofVirtual().name("WH-RecvThread").start(() -> { try { final DataInputStream dis = new DataInputStream(fSocket.getInputStream()); while (!closed) { @@ -151,10 +151,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { } } close(); - }, "WH-RecvThread"); - - sendThread.start(); - recvThread.start(); + }); try { sendThread.join(); @@ -174,9 +171,7 @@ public ProtocolClient(String host, boolean successToast, boolean failureToast) { .show(); } } - }, "WH-ConnectionThread"); - connectionThread.setDaemon(true); - connectionThread.start(); + }); } public String getOriginalHost() { diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java b/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java index b8858c8..cee34f8 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/proxy/ProxyProtocolClient.java @@ -23,7 +23,7 @@ public class ProxyProtocolClient implements AutoCloseable, ProxyPassthrough { public ProxyProtocolClient(String host, int port, long connectionId, String baseAddr, int mcPort) { this.baseAddr = baseAddr; this.mcPort = mcPort; - final Thread connectionThread = new Thread(() -> { + Thread.ofVirtual().name("WHEP-ConnectThread").start(() -> { Socket socket = null; try { socket = new Socket(host, port); @@ -52,7 +52,7 @@ public ProxyProtocolClient(String host, int port, long connectionId, String base } final Socket fSocket = socket; - final Thread sendThread = new Thread(() -> { + final Thread sendThread = Thread.ofVirtual().name("WHEP-SendThread").start(() -> { try { final DataOutputStream dos = new DataOutputStream(fSocket.getOutputStream()); while (!closed) { @@ -69,9 +69,9 @@ public ProxyProtocolClient(String host, int port, long connectionId, String base WorldHost.LOGGER.error("Critical error in WHEP send thread", e); } closed = true; - }, "WHEP-SendThread"); + }); - final Thread recvThread = new Thread(() -> { + Thread.ofVirtual().name("WHEP-RecvThread").start(() -> { try { final DataInputStream dis = new DataInputStream(fSocket.getInputStream()); while (!closed) { @@ -91,10 +91,7 @@ public ProxyProtocolClient(String host, int port, long connectionId, String base } } closed = true; - }, "WHEP-RecvThread"); - - sendThread.start(); - recvThread.start(); + }); try { sendThread.join(); @@ -107,9 +104,7 @@ public ProxyProtocolClient(String host, int port, long connectionId, String base } catch (IOException e) { WorldHost.LOGGER.error("Failed to close WHEP socket.", e); } - }, "WHEP-ConnectThread"); - connectionThread.setDaemon(true); - connectionThread.start(); + }); } private void enqueue(ProxyMessage message) { diff --git a/version.gradle.kts b/version.gradle.kts index f8c49b3..e3f87b5 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -435,4 +435,7 @@ tasks.withType { } } from("$rootDir/LICENSE") + mixinRemap { + disableRefmap() + } } From baac174718f3cf0aa7348bdd89745a10922cd670 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Fri, 10 May 2024 18:45:26 -0500 Subject: [PATCH 20/24] Fix not being able to accept offline players' friend requests --- .../github/gaming32/worldhost/gui/screen/AddFriendScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2c30032..14932e7 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 @@ -83,7 +83,7 @@ protected void init() { //$$ usernameField.setFocus(true); //#endif if (friendProfile != null) { - usernameField.setValue(friendProfile.getName()); + usernameField.setValue(WorldHost.getIfBlank(friendProfile.getName(), () -> friendProfile.getId().toString())); } if (usernameResponder == null) { // Only set the responder here on first init From c101ef0fc30bde9a48a17709fd7936f39eb17528 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Fri, 10 May 2024 22:50:47 -0500 Subject: [PATCH 21/24] Avoid weird double initialization in Forge 47.1.3 --- src/main/java/io/github/gaming32/worldhost/WorldHost.java | 7 ++++++- version.gradle.kts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index fe9d820..d60cdd8 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -873,8 +873,13 @@ private static Path getGameDir() { //$$ @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) //#endif //$$ public static class ClientModEvents { + //$$ // Forge 47.1.3 can call FMLClientSetupEvent twice. + //$$ private static boolean initialized = false; + //$$ //$$ @SubscribeEvent - //$$ public static void onClientSetup(FMLClientSetupEvent event) { + //$$ public static synchronized void onClientSetup(FMLClientSetupEvent event) { + //$$ if (initialized) return; + //$$ initialized = true; //$$ init(); //$$ final BiFunction screenFunction = //$$ (mc, screen) -> new WorldHostConfigScreen(screen); diff --git a/version.gradle.kts b/version.gradle.kts index e3f87b5..d3c373f 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -139,6 +139,12 @@ unimined.minecraft { remap(tasks.shadeDowngradedApi.get(), "remapJar") tasks.assemble.get().dependsOn("remapJar") } + + runs { + config("client") { + javaVersion = JavaVersion.VERSION_21 + } + } } val minecraft = unimined.minecrafts[sourceSets.main.get()] From 8307e0dcb6a6dda864f48a832e371111742d9339 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sat, 11 May 2024 09:00:12 -0500 Subject: [PATCH 22/24] Simplify some code --- src/main/java/io/github/gaming32/worldhost/WorldHost.java | 6 +++--- .../github/gaming32/worldhost/mixin/MixinPauseScreen.java | 2 -- .../github/gaming32/worldhost/mixin/MixinTitleScreen.java | 5 +---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index d60cdd8..66584bd 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -775,16 +775,16 @@ public static String getModVersion(String modId) { //#endif } - //#if FABRIC && MC >= 1.18.2 public static int getMMCLines(boolean isPause) { + //#if FABRIC && MC >= 1.18.2 if (FabricLoader.getInstance().isModLoaded("isxander-main-menu-credits")) { final var baseConfig = MainMenuCredits.getInstance().getConfig(); final var config = isPause ? baseConfig.PAUSE_MENU : baseConfig.MAIN_MENU; return (CONFIG.getOnlineStatusLocation() == OnlineStatusLocation.RIGHT ? config.getBottomRight() : config.getBottomLeft()).size(); } + //#endif return 0; } - //#endif public static T httpGet( CloseableHttpClient client, @@ -821,7 +821,7 @@ public static CompletableFuture> checkForUpdates() { final String latestVersion = httpGet( client, "https://api.modrinth.com/v2/project/world-host/version", builder -> builder - .addParameter("game_versions", "[\"" + WorldHost.getModVersion("minecraft") + "\"]") + .addParameter("game_versions", "[\"" + getModVersion("minecraft") + "\"]") .addParameter("loaders", "[\"" + MOD_LOADER + "\"]"), input -> { try (JsonReader reader = JsonReader.json(new InputStreamReader(input, StandardCharsets.UTF_8))) { 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 cda9cf3..0bdb5c8 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinPauseScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinPauseScreen.java @@ -38,13 +38,11 @@ private void onlineStatus(CallbackInfo ci) { if (location == OnlineStatusLocation.OFF) return; int x = 7; int y = 15; - //#if FABRIC && MC >= 1.18.2 final int mmcLines = WorldHost.getMMCLines(true); if (mmcLines > 0) { x = 2; y = 10 + mmcLines * 12; } - //#endif addRenderableWidget(new OnlineStatusButton( location == OnlineStatusLocation.RIGHT ? width - x : x, height - y, 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 baddc81..c51146d 100644 --- a/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java +++ b/src/main/java/io/github/gaming32/worldhost/mixin/MixinTitleScreen.java @@ -33,14 +33,11 @@ private void onlineStatus(CallbackInfo ci) { final OnlineStatusLocation location = WorldHost.CONFIG.getOnlineStatusLocation(); if (location == OnlineStatusLocation.OFF) return; int y = 20; - //#if FABRIC - //#if MC >= 1.18.2 final int mmcLines = WorldHost.getMMCLines(false); if (mmcLines > 0) { y += mmcLines * 12; } - //#endif - //#else + //#if FORGELIKE //$$ int[] forgeLineCount = {-1}; //$$ final BiConsumer lineConsumer = (i, s) -> forgeLineCount[0]++; //$$ if (location == OnlineStatusLocation.LEFT) { From f1b3bcf7703e484ae129cd4834a1bd5be5db1dae Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sat, 11 May 2024 09:15:16 -0500 Subject: [PATCH 23/24] Bump JvmDowngrader --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index d3c373f..ba5621f 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -14,7 +14,7 @@ plugins { id("io.github.gaming32.gradle.preprocess") id("xyz.wagyourtail.unimined") id("com.modrinth.minotaur") version "2.+" - id("xyz.wagyourtail.jvmdowngrader") version "0.0.1-SNAPSHOT" + id("xyz.wagyourtail.jvmdowngrader") version "0.2.0-SNAPSHOT" } fun Any.setGroovyProperty(name: String, value: Any) = withGroovyBuilder { metaClass }.setProperty(this, name, value) From 941ca4f86c13050123d92dd98bb8e6b6958d5386 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sat, 11 May 2024 09:23:25 -0500 Subject: [PATCH 24/24] Remove refmap declaration --- src/main/resources/world-host.mixins.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/world-host.mixins.json b/src/main/resources/world-host.mixins.json index 015ee37..f15f10c 100644 --- a/src/main/resources/world-host.mixins.json +++ b/src/main/resources/world-host.mixins.json @@ -30,6 +30,5 @@ ], "injectors": { "defaultRequire": 1 - }, - "refmap": "world-host.mixins.refmap.json" + } } \ No newline at end of file