Skip to content

Commit

Permalink
feat: update to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
uku3lig committed Nov 18, 2024
1 parent c5d33b8 commit 640368e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.2
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Fabric API
fabric_version=0.102.1+1.21.1
fabric_version=0.109.0+1.21.3

# Mod Properties
mod_version=0.1.5
Expand All @@ -18,4 +18,4 @@ maven_group=com.github.getchoo

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
mod_menu_version=11.0.1
mod_menu_version=12.0.0-beta.1
27 changes: 16 additions & 11 deletions src/main/java/com/github/getchoo/smoothboot/mixin/UtilMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import com.github.getchoo.smoothboot.util.LoggingForkJoinWorkerThread;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand All @@ -26,10 +24,10 @@ public abstract class UtilMixin {
private static ExecutorService BOOTSTRAP_EXECUTOR;*/

@Shadow @Final @Mutable
private static ExecutorService MAIN_WORKER_EXECUTOR;
private static NameableExecutor MAIN_WORKER_EXECUTOR;

@Shadow @Final @Mutable
private static ExecutorService IO_WORKER_EXECUTOR;
private static NameableExecutor IO_WORKER_EXECUTOR;

@Shadow
private static void uncaughtExceptionHandler(Thread thread, Throwable throwable) {}
Expand Down Expand Up @@ -64,16 +62,17 @@ private static void onGetIoWorkerExecutor(CallbackInfoReturnable<Executor> ci) {
/**
* Replace
*/
private static ExecutorService replWorker(String name) {
@Unique
private static NameableExecutor replWorker(String name) {
if (!SmoothBoot.initConfig) {
SmoothBoot.regConfig();
SmoothBoot.initConfig = true;
}

AtomicInteger atomicInteger = new AtomicInteger(1);

return new ForkJoinPool(MathHelper.clamp(select(name, SmoothBoot.config.threadCount.bootstrap,
SmoothBoot.config.threadCount.main), 1, 0x7fff), (forkJoinPool) -> {
ExecutorService service = new ForkJoinPool(MathHelper.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);

Expand All @@ -83,15 +82,18 @@ private static ExecutorService replWorker(String name) {
forkJoinWorkerThread.setName(workerName);
return forkJoinWorkerThread;
}, UtilMixin::uncaughtExceptionHandler, true);

return new NameableExecutor(service);
}

/**
* Replace
*/
private static ExecutorService replIoWorker() {
@Unique
private static NameableExecutor replIoWorker() {
AtomicInteger atomicInteger = new AtomicInteger(1);

return Executors.newCachedThreadPool((runnable) -> {
ExecutorService service = Executors.newCachedThreadPool(runnable -> {
String workerName = "IO-Worker-" + atomicInteger.getAndIncrement();
SmoothBoot.LOGGER.debug("Initialized " + workerName);

Expand All @@ -102,8 +104,11 @@ private static ExecutorService replIoWorker() {
thread.setUncaughtExceptionHandler(UtilMixin::uncaughtExceptionHandler);
return thread;
});

return new NameableExecutor(service);
}

@Unique
private static <T> T select(String name, T bootstrap, T main) {
return Objects.equals(name, "Bootstrap") ? bootstrap : main;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"depends": {
"fabricloader": ">=0.15",
"fabric-api": "*",
"minecraft": "~1.21.1",
"minecraft": "~1.21.3",
"java": ">=21"
}
}

0 comments on commit 640368e

Please sign in to comment.