From a4353bb760e616f6cd281a9f519c3b91dcc7c727 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 22 May 2016 20:36:05 +1000 Subject: [PATCH] Forge fix Fixes #119 Close #120 --- core/src/main/java/com/boydti/fawe/Fawe.java | 12 ++++++++++++ .../java/com/boydti/fawe/forge/ForgeTaskMan.java | 2 ++ .../java/com/boydti/fawe/forge/ForgeTaskMan.java | 2 ++ 3 files changed, 16 insertions(+) diff --git a/core/src/main/java/com/boydti/fawe/Fawe.java b/core/src/main/java/com/boydti/fawe/Fawe.java index 0d25e630..88fe4e5b 100644 --- a/core/src/main/java/com/boydti/fawe/Fawe.java +++ b/core/src/main/java/com/boydti/fawe/Fawe.java @@ -387,10 +387,22 @@ public class Fawe { } } + /** + * Get the main thread + * @return + */ public Thread getMainThread() { return this.thread; } + /** + * Sets the main thread to the current thread + * @return + */ + public Thread setMainThread() { + return this.thread = Thread.currentThread(); + } + private ConcurrentHashMap players = new ConcurrentHashMap<>(); public void register(FawePlayer player) { diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java b/forge1710/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java index c06b6f0f..c780e74b 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java @@ -1,5 +1,6 @@ package com.boydti.fawe.forge; +import com.boydti.fawe.Fawe; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; import cpw.mods.fml.common.FMLCommonHandler; @@ -55,6 +56,7 @@ public class ForgeTaskMan extends TaskManager { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onServerTick(TickEvent.ServerTickEvent event) { + Fawe.get().setMainThread(); int asyncSize = asyncTasks.size(); for (int i = 0; i < asyncSize; i++) { Runnable item = asyncTasks.poll(); diff --git a/forge189/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java b/forge189/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java index 1b9f34c1..d1940818 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/ForgeTaskMan.java @@ -1,5 +1,6 @@ package com.boydti.fawe.forge; +import com.boydti.fawe.Fawe; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; import java.util.concurrent.ConcurrentHashMap; @@ -55,6 +56,7 @@ public class ForgeTaskMan extends TaskManager { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onServerTick(TickEvent.ServerTickEvent event) { + Fawe.get().setMainThread(); int asyncSize = asyncTasks.size(); for (int i = 0; i < asyncSize; i++) { Runnable item = asyncTasks.poll();