diff --git a/build.gradle b/build.gradle index 4487bba..5111bb3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.14.10' + id 'net.fabricmc.fabric-loom' version '1.17.16' } version = "${project.mod_version}+mc${project.minecraft_version}" @@ -10,15 +10,10 @@ repositories { } dependencies { - //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - - modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" + implementation "net.fabricmc:fabric-loader:${project.loader_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + implementation "com.terraformersmc:modmenu:${project.mod_menu_version}" } processResources { @@ -36,8 +31,8 @@ base { } java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 withSourcesJar() } diff --git a/gradle.properties b/gradle.properties index a648893..9c1e6dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,11 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop/ -minecraft_version=1.21.11 -yarn_mappings=1.21.11+build.4 -loader_version=0.18.4 +minecraft_version=26.2 +loader_version=0.19.3 # Fabric API -fabric_version=0.141.1+1.21.11 +fabric_version=0.155.2+26.2 # Mod Properties mod_version=0.1.8 @@ -18,4 +17,4 @@ maven_group=com.github.getchoo # Dependencies ## https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu -mod_menu_version=17.0.0-beta.2 +mod_menu_version=20.0.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60..f8e1ee3 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 bad7c24..5dd3c01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/com/github/getchoo/smoothboot/config/ConfigHandler.java b/src/main/java/com/github/getchoo/smoothboot/config/ConfigHandler.java index f846b7e..109dc8a 100644 --- a/src/main/java/com/github/getchoo/smoothboot/config/ConfigHandler.java +++ b/src/main/java/com/github/getchoo/smoothboot/config/ConfigHandler.java @@ -47,6 +47,6 @@ public static SmoothBootConfig readConfig() throws IOException { public static void openConfigFile() { String configPath = System.getProperty("user.dir") + "/config/" + SmoothBoot.MOD_ID + ".json"; - Util.getOperatingSystem().open(new File(configPath)); + Util.getPlatform().openFile(new File(configPath)); } } diff --git a/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootConfig.java b/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootConfig.java index 128e411..ebd7da3 100644 --- a/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootConfig.java +++ b/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootConfig.java @@ -1,7 +1,7 @@ package com.github.getchoo.smoothboot.config; import com.github.getchoo.smoothboot.SmoothBoot; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.Mth; public class SmoothBootConfig { public ThreadCount threadCount = new ThreadCount(); @@ -10,7 +10,7 @@ public class SmoothBootConfig { public static class ThreadCount { public int bootstrap = 1; - public int main = MathHelper.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, + public int main = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, SmoothBoot.getMaxBackgroundThreads()); } @@ -26,11 +26,11 @@ public void validate() { threadCount.bootstrap = Math.max(threadCount.bootstrap, 1); threadCount.main = Math.max(threadCount.main, 1); - threadPriority.game = MathHelper.clamp(threadPriority.game, 1, 10); - threadPriority.integratedServer = MathHelper.clamp(threadPriority.integratedServer, 1, 10); - threadPriority.bootstrap = MathHelper.clamp(threadPriority.bootstrap, 1, 10); - threadPriority.main = MathHelper.clamp(threadPriority.main, 1, 10); - threadPriority.io = MathHelper.clamp(threadPriority.io, 1, 10); + threadPriority.game = Mth.clamp(threadPriority.game, 1, 10); + threadPriority.integratedServer = Mth.clamp(threadPriority.integratedServer, 1, 10); + threadPriority.bootstrap = Mth.clamp(threadPriority.bootstrap, 1, 10); + threadPriority.main = Mth.clamp(threadPriority.main, 1, 10); + threadPriority.io = Mth.clamp(threadPriority.io, 1, 10); } } diff --git a/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootModMenu.java b/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootModMenu.java index 01653ca..9322e64 100644 --- a/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootModMenu.java +++ b/src/main/java/com/github/getchoo/smoothboot/config/SmoothBootModMenu.java @@ -2,17 +2,17 @@ import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; public class SmoothBootModMenu implements ModMenuApi { @Override public ConfigScreenFactory getModConfigScreenFactory() { - return screen -> new Screen(Text.of("")) { + return screen -> new Screen(Component.nullToEmpty("")) { @Override protected void init() { ConfigHandler.openConfigFile(); - this.client.setScreen(screen); + this.minecraft.gui.setScreen(screen); } }; } diff --git a/src/main/java/com/github/getchoo/smoothboot/mixin/UtilMixin.java b/src/main/java/com/github/getchoo/smoothboot/mixin/UtilMixin.java index 67936ea..33fa928 100644 --- a/src/main/java/com/github/getchoo/smoothboot/mixin/UtilMixin.java +++ b/src/main/java/com/github/getchoo/smoothboot/mixin/UtilMixin.java @@ -2,9 +2,9 @@ import com.github.getchoo.smoothboot.SmoothBoot; import com.github.getchoo.smoothboot.util.LoggingForkJoinWorkerThread; +import net.minecraft.TracingExecutor; +import net.minecraft.util.Mth; import net.minecraft.util.Util; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.thread.NameableExecutor; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -24,13 +24,13 @@ public abstract class UtilMixin { private static ExecutorService BOOTSTRAP_EXECUTOR;*/ @Shadow @Final @Mutable - private static NameableExecutor MAIN_WORKER_EXECUTOR; + private static TracingExecutor BACKGROUND_EXECUTOR; @Shadow @Final @Mutable - private static NameableExecutor IO_WORKER_EXECUTOR; + private static TracingExecutor IO_POOL; @Shadow - private static void uncaughtExceptionHandler(Thread thread, Throwable throwable) {} + private static void onThreadException(Thread thread, Throwable throwable) {} /*@Inject(method = "getBootstrapExecutor", at = @At("HEAD")) private static void onGetBootstrapExecutor(CallbackInfoReturnable ci) { @@ -41,19 +41,19 @@ private static void onGetBootstrapExecutor(CallbackInfoReturnable ci) } }*/ //FIXME 1.19.4 - @Inject(method = "getMainWorkerExecutor", at = @At("HEAD")) + @Inject(method = "backgroundExecutor", at = @At("HEAD")) private static void onGetMainWorkerExecutor(CallbackInfoReturnable ci) { if (!SmoothBoot.initMainWorker) { - MAIN_WORKER_EXECUTOR = replWorker("Main"); + BACKGROUND_EXECUTOR = replWorker("Main"); SmoothBoot.LOGGER.debug("Main worker replaced"); SmoothBoot.initMainWorker = true; } } - @Inject(method = "getIoWorkerExecutor", at = @At("HEAD")) + @Inject(method = "ioPool", at = @At("HEAD")) private static void onGetIoWorkerExecutor(CallbackInfoReturnable ci) { if (!SmoothBoot.initIOWorker) { - IO_WORKER_EXECUTOR = replIoWorker(); + IO_POOL = replIoWorker(); SmoothBoot.LOGGER.debug("IO worker replaced"); SmoothBoot.initIOWorker = true; } @@ -63,7 +63,7 @@ private static void onGetIoWorkerExecutor(CallbackInfoReturnable ci) { * Replace */ @Unique - private static NameableExecutor replWorker(String name) { + private static TracingExecutor replWorker(String name) { if (!SmoothBoot.initConfig) { SmoothBoot.regConfig(); SmoothBoot.initConfig = true; @@ -71,7 +71,7 @@ private static NameableExecutor replWorker(String name) { AtomicInteger atomicInteger = new AtomicInteger(1); - ExecutorService service = new ForkJoinPool(MathHelper.clamp(select(name, SmoothBoot.config.threadCount.bootstrap, + ExecutorService service = new ForkJoinPool(Mth.clamp(select(name, SmoothBoot.config.threadCount.bootstrap, SmoothBoot.config.threadCount.main), 1, 0x7fff), forkJoinPool -> { String workerName = "Worker-" + name + "-" + atomicInteger.getAndIncrement(); SmoothBoot.LOGGER.debug("Initialized {}", workerName); @@ -81,16 +81,16 @@ private static NameableExecutor replWorker(String name) { SmoothBoot.config.threadPriority.main)); forkJoinWorkerThread.setName(workerName); return forkJoinWorkerThread; - }, UtilMixin::uncaughtExceptionHandler, true); + }, UtilMixin::onThreadException, true); - return new NameableExecutor(service); + return new TracingExecutor(service); } /** * Replace */ @Unique - private static NameableExecutor replIoWorker() { + private static TracingExecutor replIoWorker() { AtomicInteger atomicInteger = new AtomicInteger(1); ExecutorService service = Executors.newCachedThreadPool(runnable -> { @@ -101,11 +101,11 @@ private static NameableExecutor replIoWorker() { thread.setName(workerName); thread.setDaemon(true); thread.setPriority(SmoothBoot.config.threadPriority.io); - thread.setUncaughtExceptionHandler(UtilMixin::uncaughtExceptionHandler); + thread.setUncaughtExceptionHandler(UtilMixin::onThreadException); return thread; }); - return new NameableExecutor(service); + return new TracingExecutor(service); } @Unique diff --git a/src/main/java/com/github/getchoo/smoothboot/mixin/client/IntegratedServerMixin.java b/src/main/java/com/github/getchoo/smoothboot/mixin/client/IntegratedServerMixin.java index f71cb7a..35d7a67 100644 --- a/src/main/java/com/github/getchoo/smoothboot/mixin/client/IntegratedServerMixin.java +++ b/src/main/java/com/github/getchoo/smoothboot/mixin/client/IntegratedServerMixin.java @@ -1,22 +1,24 @@ package com.github.getchoo.smoothboot.mixin.client; import com.github.getchoo.smoothboot.SmoothBoot; -import net.minecraft.client.MinecraftClient; -import net.minecraft.resource.ResourcePackManager; -import net.minecraft.server.SaveLoader; -import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.util.ApiServices; -import net.minecraft.world.chunk.ChunkLoadProgress; -import net.minecraft.world.level.storage.LevelStorage; +import net.minecraft.client.Minecraft; +import net.minecraft.client.server.IntegratedServer; +import net.minecraft.server.Services; +import net.minecraft.server.WorldStem; +import net.minecraft.server.level.progress.LevelLoadListener; +import net.minecraft.server.packs.repository.PackRepository; +import net.minecraft.world.level.storage.LevelStorageSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.Optional; + @Mixin(IntegratedServer.class) public class IntegratedServerMixin { @Inject(method = "", at = @At("RETURN")) - public void onInit(Thread serverThread, MinecraftClient client, LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, ApiServices apiServices, ChunkLoadProgress chunkLoadProgress, CallbackInfo ci) { + public void onInit(Thread serverThread, Minecraft client, LevelStorageSource.LevelStorageAccess session, PackRepository dataPackManager, WorldStem saveLoader, Optional optional, Services apiServices, LevelLoadListener chunkLoadProgress, CallbackInfo ci) { serverThread.setPriority(SmoothBoot.config.threadPriority.integratedServer); SmoothBoot.LOGGER.debug("Initialized integrated server thread"); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3ebe579..ba25cb6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,7 +23,7 @@ "depends": { "fabricloader": ">=0.17", "fabric-api": "*", - "minecraft": ">=1.21.9", - "java": ">=21" + "minecraft": ">=26.2", + "java": ">=25" } } diff --git a/src/main/resources/smoothboot.mixins.json b/src/main/resources/smoothboot.mixins.json index 8602138..fa38d4c 100644 --- a/src/main/resources/smoothboot.mixins.json +++ b/src/main/resources/smoothboot.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "com.github.getchoo.smoothboot.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_25", "mixins": ["UtilMixin"], "client": ["client.MainMixin", "client.IntegratedServerMixin"], "server": ["server.MainMixin"],