diff --git a/build.gradle b/build.gradle index 68708ae..1806e5b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false } architectury { @@ -16,7 +16,10 @@ subprojects { dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + mappings loom.layered { + it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2") + it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version") + } } } @@ -25,8 +28,8 @@ allprojects { apply plugin: "architectury-plugin" apply plugin: "maven-publish" - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = rootProject.archives_base_name version = rootProject.mod_version @@ -65,7 +68,7 @@ allprojects { tasks.withType(JavaCompile) { options.encoding = "UTF-8" - options.release = 17 + options.release = 21 } java { diff --git a/common/build.gradle b/common/build.gradle index 95c22da..7c46d63 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -10,7 +10,7 @@ dependencies { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${rootProject.yacl_version}" + modImplementation "dev.isxander:yet-another-config-lib:${rootProject.yacl_version}-fabric" } publishing { diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/FadeScreen.java b/common/src/main/java/com/minenash/seamless_loading_screen/FadeScreen.java index ccba11c..7fbdc1e 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/FadeScreen.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/FadeScreen.java @@ -107,14 +107,14 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { loadQuad(context, color, x, y, x + w, y + h); if (w < width) { - RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE); + RenderSystem.setShaderTexture(0, 0); // 0.25f is from Screen.renderBackgroundTexture vertex colors color.set(0.25f, 0.25f, 0.25f, alpha); loadQuad(context, color, 0, 0, x, height, 0, 0, x / 32f, height / 32f); loadQuad(context, color, x + w, 0, width, height, (x + w) / 32f, 0, width / 32f, height / 32f); } } else { - RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE); + RenderSystem.setShaderTexture(0, 0); color.set(0.25f, 0.25f, 0.25f, alpha); loadQuad(context, color, 0, 0, width, height, 0, 0, width / 32f, height / 32f); } @@ -142,13 +142,12 @@ private void loadQuad(DrawContext context, Vector4f color, int x0, int y0, int x MatrixStack stack = context.getMatrices(); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); + BufferBuilder builder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); Matrix4f modelMat = stack.peek().getPositionMatrix(); - bufferBuilder.vertex(modelMat, x0, y1, 0).texture(u0, v1).color(color.x(), color.y(), color.z(), color.w()).next(); - bufferBuilder.vertex(modelMat, x1, y1, 0).texture(u1, v1).color(color.x(), color.y(), color.z(), color.w()).next(); - bufferBuilder.vertex(modelMat, x1, y0, 0).texture(u1, v0).color(color.x(), color.y(), color.z(), color.w()).next(); - bufferBuilder.vertex(modelMat, x0, y0, 0).texture(u0, v0).color(color.x(), color.y(), color.z(), color.w()).next(); - tessellator.draw(); + builder.vertex(modelMat, x0, y1, 0).texture(u0, v1).color(color.x(), color.y(), color.z(), color.w()); + builder.vertex(modelMat, x1, y1, 0).texture(u1, v1).color(color.x(), color.y(), color.z(), color.w()); + builder.vertex(modelMat, x1, y0, 0).texture(u1, v0).color(color.x(), color.y(), color.z(), color.w()); + builder.vertex(modelMat, x0, y0, 0).texture(u0, v0).color(color.x(), color.y(), color.z(), color.w()); + BufferRenderer.drawWithGlobalProgram(builder.end()); } } \ No newline at end of file diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/OnLeaveHelper.java b/common/src/main/java/com/minenash/seamless_loading_screen/OnLeaveHelper.java index 09b38e1..2c39de7 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/OnLeaveHelper.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/OnLeaveHelper.java @@ -6,6 +6,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.Perspective; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.util.ScreenshotRecorder; import net.minecraft.util.Util; @@ -77,7 +78,7 @@ public static void beginScreenshotTask(Runnable runnable) { } /** - * Inject after World Rendering within {@link GameRenderer#render(float, long, boolean)} method before {@link MinecraftClient#getWindow()} + * Inject after World Rendering within {@link GameRenderer#render(RenderTickCounter, boolean)} method before {@link MinecraftClient#getWindow()} */ public static void takeScreenShot() { var client = MinecraftClient.getInstance(); diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/ScreenshotLoader.java b/common/src/main/java/com/minenash/seamless_loading_screen/ScreenshotLoader.java index 86a3b4c..e246990 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/ScreenshotLoader.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/ScreenshotLoader.java @@ -11,9 +11,7 @@ import net.minecraft.client.gl.SimpleFramebuffer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.VertexFormats; +import net.minecraft.client.render.*; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.client.util.Window; @@ -33,7 +31,7 @@ public class ScreenshotLoader { private static final Logger LOGGER = LogUtils.getLogger(); private static final Pattern RESERVED_FILENAMES_PATTERN = Pattern.compile(".*\\.|(?:COM|CLOCK\\$|CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\\..*)?", Pattern.CASE_INSENSITIVE); - public static Identifier SCREENSHOT = new Identifier(SeamlessLoadingScreen.MODID, "screenshot"); + public static Identifier SCREENSHOT = Identifier.of(SeamlessLoadingScreen.MODID, "screenshot"); public static double imageRatio = 1; public static boolean loaded = false; public static DisplayMode displayMode = DisplayMode.ENABLED; @@ -152,19 +150,19 @@ public static int getArgb(int alpha, int red, int green, int blue) { //----- public static void renderBlur(Screen screen, DrawContext context, float size, float quality) { - var buffer = Tessellator.getInstance().getBuffer(); + Tessellator tessellator = Tessellator.getInstance(); var matrix = context.getMatrices().peek().getPositionMatrix(); - buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION); - buffer.vertex(matrix, 0, 0, 0).next(); - buffer.vertex(matrix, 0, screen.height, 0).next(); - buffer.vertex(matrix, screen.width, screen.height, 0).next(); - buffer.vertex(matrix, screen.width, 0, 0).next(); + BufferBuilder builder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION); + builder.vertex(matrix, 0, 0, 0); + builder.vertex(matrix, 0, screen.height, 0); + builder.vertex(matrix, screen.width, screen.height, 0); + builder.vertex(matrix, screen.width, 0, 0); SeamlessLoadingScreen.BLUR_PROGRAM.setParameters(16, quality, size); SeamlessLoadingScreen.BLUR_PROGRAM.use(); - Tessellator.getInstance().draw(); + BufferRenderer.drawWithGlobalProgram(builder.end()); } /** diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/config/SeamlessLoadingScreenConfig.java b/common/src/main/java/com/minenash/seamless_loading_screen/config/SeamlessLoadingScreenConfig.java index 2c5a7ec..37fe2d6 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/config/SeamlessLoadingScreenConfig.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/config/SeamlessLoadingScreenConfig.java @@ -20,7 +20,7 @@ public class SeamlessLoadingScreenConfig { private static final SafeColorTypeAdapter colorAdapter = new SafeColorTypeAdapter(() -> getDefaults().tintColor); private static final ConfigClassHandler CONFIG_CLASS_HANDLER = ConfigClassHandler .createBuilder(SeamlessLoadingScreenConfig.class) - .id(new Identifier("seamless_loading_screen", "config")) + .id(Identifier.of("seamless_loading_screen", "config")) .serializer(config -> GsonConfigSerializerBuilder.create(config) .appendGsonBuilder(builder -> builder.setPrettyPrinting() .disableHtmlEscaping() @@ -100,7 +100,7 @@ private static Text getDesc(String id) { return Text.translatable("seamless_loading_screen.config." + id + ".description"); } private static Identifier getImg(String id) { - return new Identifier("seamless_loading_screen", "textures/config/" + id + ".webp"); + return Identifier.of("seamless_loading_screen", "textures/config/" + id + ".webp"); } public static YetAnotherConfigLib getInstance() { diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientCommonNetworkHandlerMixin.java b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientCommonNetworkHandlerMixin.java index a74055f..da67600 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientCommonNetworkHandlerMixin.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientCommonNetworkHandlerMixin.java @@ -2,6 +2,8 @@ import com.minenash.seamless_loading_screen.OnLeaveHelper; import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.network.DisconnectionInfo; +import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -12,17 +14,17 @@ @Mixin(ClientCommonNetworkHandler.class) public abstract class ClientCommonNetworkHandlerMixin { - @Shadow public abstract void onDisconnected(Text reason); + @Shadow public abstract void onDisconnected(DisconnectionInfo info); @Unique private boolean seamless_loading_screen$haltDisconnect = true; @Inject(method = "onDisconnected", at = @At("HEAD"), cancellable = true) - private void onServerOrderedDisconnect(Text reason, CallbackInfo info) { + private void onServerOrderedDisconnect(DisconnectionInfo info, CallbackInfo ci) { if (seamless_loading_screen$haltDisconnect) { - OnLeaveHelper.beginScreenshotTask(() -> this.onDisconnected(reason)); + OnLeaveHelper.beginScreenshotTask(() -> this.onDisconnected(info)); - info.cancel(); + ci.cancel(); } seamless_loading_screen$haltDisconnect = !seamless_loading_screen$haltDisconnect; diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientPlayNetworkHandlerMixin.java b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientPlayNetworkHandlerMixin.java index 4312540..9df81d0 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientPlayNetworkHandlerMixin.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ClientPlayNetworkHandlerMixin.java @@ -18,7 +18,7 @@ @Mixin(ClientPlayNetworkHandler.class) public abstract class ClientPlayNetworkHandlerMixin { - @Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;joinWorld(Lnet/minecraft/client/world/ClientWorld;)V")) + @Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;joinWorld(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen$WorldEntryReason;)V")) private void setChangeWorldJoinScreen(GameJoinS2CPacket packet, CallbackInfo ci) { if (ScreenshotLoader.loaded) SeamlessLoadingScreen.changeWorldJoinScreen = true; } diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ConnectScreenMixin.java b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ConnectScreenMixin.java index 18991f8..d10c123 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ConnectScreenMixin.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ConnectScreenMixin.java @@ -4,6 +4,7 @@ import com.minenash.seamless_loading_screen.ServerInfoExtension; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; +import net.minecraft.client.network.CookieStorage; import net.minecraft.client.network.ServerAddress; import net.minecraft.client.network.ServerInfo; import org.spongepowered.asm.mixin.Mixin; @@ -14,8 +15,8 @@ @Mixin(ConnectScreen.class) public class ConnectScreenMixin { - @Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;)V", at = @At("HEAD")) - public void getImage(MinecraftClient client, ServerAddress address, ServerInfo info, CallbackInfo ci) { + @Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;Lnet/minecraft/client/network/CookieStorage;)V", at = @At("HEAD")) + public void getImage(MinecraftClient client, ServerAddress address, ServerInfo info, CookieStorage cookieStorage, CallbackInfo ci) { ScreenshotLoader.displayMode = ((ServerInfoExtension) info).getDisplayMode(); ScreenshotLoader.setScreenshot(address.getAddress(), address.getPort()); diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/GameRendererMixin.java b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/GameRendererMixin.java index d911dc1..003082b 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/GameRendererMixin.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/GameRendererMixin.java @@ -2,6 +2,7 @@ import com.minenash.seamless_loading_screen.OnLeaveHelper; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderTickCounter; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,7 +13,7 @@ public class GameRendererMixin { @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/Framebuffer;beginWrite(Z)V", shift = At.Shift.BY, by = 2)) // - private void attemptToTakeScreenshot(float tickDelta, long startTime, boolean tick, CallbackInfo ci) { + private void attemptToTakeScreenshot(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) { if (OnLeaveHelper.attemptScreenShot) OnLeaveHelper.takeScreenShot(); } diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/MinecraftClientMixin.java b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/MinecraftClientMixin.java index 36b5b29..094e1fa 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/MinecraftClientMixin.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/MinecraftClientMixin.java @@ -51,7 +51,7 @@ public abstract class MinecraftClientMixin { public abstract void setScreen(@Nullable Screen screen); @Inject(method = "joinWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;reset(Lnet/minecraft/client/gui/screen/Screen;)V")) - private void changeScreen(ClientWorld world, CallbackInfo ci) { + private void changeScreen(ClientWorld world, DownloadingTerrainScreen.WorldEntryReason worldEntryReason, CallbackInfo ci) { if (SeamlessLoadingScreen.changeWorldJoinScreen) { SeamlessLoadingScreen.changeWorldJoinScreen = false; ScreenshotLoader.inFade = true; diff --git a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ScreenMixin.java b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ScreenMixin.java index 23d1020..de58229 100644 --- a/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ScreenMixin.java +++ b/common/src/main/java/com/minenash/seamless_loading_screen/mixin/ScreenMixin.java @@ -11,7 +11,7 @@ @Mixin(value = Screen.class, priority = 900) public class ScreenMixin { - @Inject(method = "renderBackgroundTexture", at = @At("HEAD"), cancellable = true) + @Inject(method = "renderDarkening(Lnet/minecraft/client/gui/DrawContext;)V", at = @At("HEAD"), cancellable = true) private void renderScreenBackground_AfterTexture(DrawContext context, CallbackInfo ci) { if (!ScreenshotLoader.replacebg) return; diff --git a/fabric/build.gradle b/fabric/build.gradle index 338652c..161f088 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -63,7 +63,7 @@ dependencies { modCompileOnly("maven.modrinth:bedrockify:${rootProject.bedrockify_version}") - modImplementation ("dev.isxander.yacl:yet-another-config-lib-fabric:${rootProject.yacl_version}") + modImplementation ("dev.isxander:yet-another-config-lib:${rootProject.yacl_version}-fabric") //include "dev.isxander.yacl:yet-another-config-lib-fabric:${rootProject.yacl_version}" //modLocalRuntime ("maven.modrinth:fastload:3.4.0") diff --git a/fabric/src/main/java/com/minenash/seamless_loading_screen/fabric/SeamlessLoadingScreenFabric.java b/fabric/src/main/java/com/minenash/seamless_loading_screen/fabric/SeamlessLoadingScreenFabric.java index 6f47583..5ef7426 100644 --- a/fabric/src/main/java/com/minenash/seamless_loading_screen/fabric/SeamlessLoadingScreenFabric.java +++ b/fabric/src/main/java/com/minenash/seamless_loading_screen/fabric/SeamlessLoadingScreenFabric.java @@ -27,7 +27,7 @@ public void onInitializeClient() { SeamlessLoadingScreen.onInitializeClient(); CoreShaderRegistrationCallback.EVENT.register(context -> { - context.register(new Identifier(SeamlessLoadingScreen.MODID, "blur"), VertexFormats.POSITION, shaderProgram -> { + context.register(Identifier.of(SeamlessLoadingScreen.MODID, "blur"), VertexFormats.POSITION, shaderProgram -> { SeamlessLoadingScreen.BLUR_PROGRAM.load(shaderProgram); }); }); diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index bd624da..182cc37 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -34,7 +34,7 @@ "depends": { "fabricloader": "*", "fabric": "*", - "minecraft": ">=1.20.3", + "minecraft": ">=1.21", "yet_another_config_lib_v3": "*" }, "conflicts": { diff --git a/gradle.properties b/gradle.properties index 63d675d..1b620a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,25 +1,26 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx4G # Mod Properties -mod_version=2.1.1+1.20.4 +mod_version=2.2.0+1.21 maven_group=com.minenash archives_base_name=seamless-loading-screen # Common Properties -minecraft_version=1.20.4 +minecraft_version=1.21 enabled_platforms=fabric,neoforge -yarn_mappings=1.20.4+build.3 -yacl_version=3.3.1+1.20.4 +yarn_mappings=1.21+build.9 +yarn_mappings_patch_neoforge_version = 1.21+build.4 +yacl_version=3.5.0+1.21 # Fabric -fabric_loader_version=0.15.3 -fabric_api_version=0.92.0+1.20.4 +fabric_loader_version=0.16.5 +fabric_api_version=0.102.0+1.21 -modmenu_version=9.0.0 -bedrockify_version=1.9.1+mc1.20.2 +modmenu_version=11.0.2 +bedrockify_version=1.10.1+mc1.21 # NeoForge -neoforge_version=20.4.73-beta +neoforge_version=21.0.167 # Forge -forge_version=1.20.4-49.0.12 +forge_version=1.21-51.0.33 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db9a6b8..a441313 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0..0adc8e1 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,99 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd3..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 7a72883..2489e55 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -31,7 +31,7 @@ configurations { dependencies { neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" - modImplementation("dev.isxander.yacl:yet-another-config-lib-neoforge:${rootProject.yacl_version}") { + modImplementation("dev.isxander:yet-another-config-lib:${rootProject.yacl_version}-neoforge") { transitive = false } @@ -45,7 +45,7 @@ dependencies { processResources { inputs.property "version", project.version - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } } diff --git a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/ConfigScreenFactory.java b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/ConfigScreenFactory.java new file mode 100644 index 0000000..ea67cd1 --- /dev/null +++ b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/ConfigScreenFactory.java @@ -0,0 +1,14 @@ +package com.minenash.seamless_loading_screen.neoforge; + +import com.minenash.seamless_loading_screen.config.SeamlessLoadingScreenConfig; +import net.minecraft.client.gui.screen.Screen; +import net.neoforged.fml.ModContainer; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; + +public class ConfigScreenFactory implements IConfigScreenFactory { + + @Override + public Screen createScreen(ModContainer container, Screen parent) { + return SeamlessLoadingScreenConfig.getInstance().generateScreen(parent); + } +} diff --git a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenClientEvents.java b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenClientEvents.java index 31eca3f..2695e64 100644 --- a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenClientEvents.java +++ b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenClientEvents.java @@ -5,19 +5,21 @@ import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.ModList; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; -import net.neoforged.neoforge.client.ConfigScreenHandler; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; -@Mod.EventBusSubscriber(modid = SeamlessLoadingScreen.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) +import java.util.function.Supplier; + +@EventBusSubscriber(modid = SeamlessLoadingScreen.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class SeamlessLoadingScreenClientEvents { @SubscribeEvent public static void onPostInit(FMLClientSetupEvent event) { ModList.get().getModContainerById(SeamlessLoadingScreen.MODID).ifPresent(modContainer -> { modContainer.registerExtensionPoint( - ConfigScreenHandler.ConfigScreenFactory.class, - () -> new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> SeamlessLoadingScreenConfig.getInstance().generateScreen(parent)) + IConfigScreenFactory.class, + (Supplier) ConfigScreenFactory::new ); }); } diff --git a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenForge.java b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenForge.java index 96cec1c..227d672 100644 --- a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenForge.java +++ b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenForge.java @@ -13,11 +13,11 @@ public class SeamlessLoadingScreenForge { public SeamlessLoadingScreenForge(IEventBus modEventBus, Dist dist) { //Is this needed? - ModLoadingContext.get() - .registerExtensionPoint( - IExtensionPoint.DisplayTest.class, - () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (remote, server) -> true) - ); +// ModLoadingContext.get() +// .registerExtensionPoint( +// IExtensionPoint.DisplayTest.class, +// () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (remote, server) -> true) +// ); if(dist.isClient()){ SeamlessLoadingScreen.onInitializeClient(); diff --git a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenShaderInit.java b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenShaderInit.java index ed16bf1..a59f585 100644 --- a/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenShaderInit.java +++ b/neoforge/src/main/java/com/minenash/seamless_loading_screen/neoforge/SeamlessLoadingScreenShaderInit.java @@ -7,13 +7,13 @@ import net.minecraft.util.Identifier; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.client.event.RegisterShadersEvent; import org.slf4j.Logger; import java.io.IOException; -@Mod.EventBusSubscriber(modid = SeamlessLoadingScreen.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(modid = SeamlessLoadingScreen.MODID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public class SeamlessLoadingScreenShaderInit { public static Logger LOGGER = LogUtils.getLogger(); @@ -25,7 +25,7 @@ public class SeamlessLoadingScreenShaderInit { @SubscribeEvent public static void registerShaders(RegisterShadersEvent event) { try { - event.registerShader(new ShaderProgram(event.getResourceProvider(), new Identifier(SeamlessLoadingScreen.MODID, "blur"), VertexFormats.POSITION), (shaderProgram) -> { + event.registerShader(new ShaderProgram(event.getResourceProvider(), Identifier.of(SeamlessLoadingScreen.MODID, "blur"), VertexFormats.POSITION), (shaderProgram) -> { SeamlessLoadingScreen.BLUR_PROGRAM.load(shaderProgram); }); } catch (IOException e) { diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 91% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index 58b0df7..3bc0dea 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "[1,)" +loaderVersion = "[4,)" #issueTrackerURL = "https://github.com/Minenash/Seamless-Loading-Screen/issues" license = "MIT" @@ -27,20 +27,20 @@ file="META-INF/accesstransformer.cfg" [[dependencies.seamless_loading_screen]] modId = "neoforge" required = true -versionRange = "[20,)" +versionRange = "[21,)" ordering = "NONE" side = "BOTH" [[dependencies.seamless_loading_screen]] modId = "yet_another_config_lib_v3" required = true -versionRange = "[3.3.0,)" +versionRange = "[3.5.0,)" ordering = "NONE" side = "BOTH" [[dependencies.seamless_loading_screen]] modId = "minecraft" required = true -versionRange = "[1.20.2,)" +versionRange = "[1.21,)" ordering = "NONE" side = "BOTH" \ No newline at end of file