Skip to content

Commit

Permalink
Propagate context classloader to default forkjoin thread factory
Browse files Browse the repository at this point in the history
Patch mixin conflicts related to Slight GUI Modifications

Fixes #269
  • Loading branch information
Su5eD committed Oct 31, 2023
1 parent d1e7731 commit 893dd5e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dev.su5ed.sinytra.connector.service;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;

public class ConnectorForkJoinThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
thread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
return thread;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void initialize(IEnvironment environment) {
FMLLoader.progressWindowTick = original;
original.run();
};
System.setProperty("java.util.concurrent.ForkJoinPool.common.threadFactory", ConnectorForkJoinThreadFactory.class.getName());
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public class MixinPatchTransformer implements Transformer {
.targetInjectionPoint("Lnet/fabricmc/loader/impl/game/minecraft/Hooks;startServer(Ljava/io/File;Ljava/lang/Object;)V")
.modifyInjectionPoint("Lnet/minecraftforge/server/loading/ServerModLoader;load()V")
.build(),
Patch.builder()
.targetClass("net/minecraft/client/gui/screens/TitleScreen")
.targetMethod("m_88315_(Lnet/minecraft/client/gui/GuiGraphics;IIF)V")
.targetInjectionPoint("Lnet/minecraft/client/gui/GuiGraphics;m_280488_(Lnet/minecraft/client/gui/Font;Ljava/lang/String;III)I")
.modifyTarget("lambda$render$12", "lambda$render$13")
.build(),
Patch.builder()
.targetClass("net/minecraft/world/entity/player/Player")
.targetMethod("m_6728_")
Expand Down Expand Up @@ -293,6 +299,7 @@ public class MixinPatchTransformer implements Transformer {
.targetMethod("m_109093_(FJZ)V")
.targetInjectionPoint("Lnet/minecraft/client/gui/screens/Screen;m_280264_(Lnet/minecraft/client/gui/GuiGraphics;IIF)V")
.modifyInjectionPoint("Lnet/minecraftforge/client/ForgeHooksClient;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V")
.modifyVariableIndex(0, 1)
.build(),
Patch.builder()
.targetClass("net/minecraft/client/renderer/entity/BoatRenderer")
Expand Down

0 comments on commit 893dd5e

Please sign in to comment.