Skip to content

Commit

Permalink
fix(fabric): Use shutdown hook instead of client stopping event for s…
Browse files Browse the repository at this point in the history
…hutdown, as on NeoForge

fixes #199
  • Loading branch information
jpenilla committed Jan 17, 2025
1 parent a524a21 commit 3f79c79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
package xyz.jpenilla.tabtps.fabric;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import xyz.jpenilla.tabtps.common.TabTPS;

public class TabTPSFabricClient implements ClientModInitializer {
public final class TabTPSFabricClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientLifecycleEvents.CLIENT_STOPPING.register(minecraft -> {
final Thread thread = new Thread(() -> {
final TabTPS tabTPS = TabTPSFabric.get().tabTPS();
tabTPS.shutdown();
});
thread.setName("TabTPS-Client-Shutdown-Thread");
Runtime.getRuntime().addShutdownHook(thread);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
@Mod(value = "tabtps", dist = Dist.CLIENT)
public final class TabTPSNeoForgeClient {
public TabTPSNeoForgeClient() {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
final Thread thread = new Thread(() -> {
final TabTPS tabTPS = TabTPSNeoForge.get().tabTPS();
tabTPS.shutdown();
}));
});
thread.setName("TabTPS-Client-Shutdown-Thread");
Runtime.getRuntime().addShutdownHook(thread);
}
}

0 comments on commit 3f79c79

Please sign in to comment.