Forge fix

Fixes #119
Close #120
This commit is contained in:
Jesse Boyd 2016-05-22 20:36:05 +10:00
parent 958f40fcbf
commit a4353bb760
3 changed files with 16 additions and 0 deletions

View File

@ -387,10 +387,22 @@ public class Fawe {
} }
} }
/**
* Get the main thread
* @return
*/
public Thread getMainThread() { public Thread getMainThread() {
return this.thread; return this.thread;
} }
/**
* Sets the main thread to the current thread
* @return
*/
public Thread setMainThread() {
return this.thread = Thread.currentThread();
}
private ConcurrentHashMap<String, FawePlayer> players = new ConcurrentHashMap<>(); private ConcurrentHashMap<String, FawePlayer> players = new ConcurrentHashMap<>();
public <T> void register(FawePlayer<T> player) { public <T> void register(FawePlayer<T> player) {

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge; package com.boydti.fawe.forge;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
@ -55,6 +56,7 @@ public class ForgeTaskMan extends TaskManager {
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void onServerTick(TickEvent.ServerTickEvent event) { public void onServerTick(TickEvent.ServerTickEvent event) {
Fawe.get().setMainThread();
int asyncSize = asyncTasks.size(); int asyncSize = asyncTasks.size();
for (int i = 0; i < asyncSize; i++) { for (int i = 0; i < asyncSize; i++) {
Runnable item = asyncTasks.poll(); Runnable item = asyncTasks.poll();

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge; package com.boydti.fawe.forge;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -55,6 +56,7 @@ public class ForgeTaskMan extends TaskManager {
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void onServerTick(TickEvent.ServerTickEvent event) { public void onServerTick(TickEvent.ServerTickEvent event) {
Fawe.get().setMainThread();
int asyncSize = asyncTasks.size(); int asyncSize = asyncTasks.size();
for (int i = 0; i < asyncSize; i++) { for (int i = 0; i < asyncSize; i++) {
Runnable item = asyncTasks.poll(); Runnable item = asyncTasks.poll();