Compiler fun!

This commit is contained in:
Florian Nücke 2014-07-19 13:47:30 +02:00
parent 9d49a98db7
commit da8b6c55aa
2 changed files with 22 additions and 15 deletions

View File

@ -0,0 +1,22 @@
package li.cil.oc.util;
import cpw.mods.fml.common.FMLCommonHandler;
import java.util.Collections;
import java.util.Set;
public final class SideTracker {
private static final Set<Thread> serverThreads = Collections.newSetFromMap(new java.util.WeakHashMap<Thread, Boolean>());
public static void addServerThread() {
serverThreads.add(Thread.currentThread());
}
public static boolean isServer() {
return FMLCommonHandler.instance().getEffectiveSide().isServer() || serverThreads.contains(Thread.currentThread());
}
public static boolean isClient() {
return !isServer();
}
}

View File

@ -1,15 +0,0 @@
package li.cil.oc.util
import java.util.Collections
import cpw.mods.fml.common.FMLCommonHandler
object SideTracker {
private val serverThreads = Collections.newSetFromMap(new java.util.WeakHashMap[Thread, java.lang.Boolean])
def addServerThread() = serverThreads.add(Thread.currentThread())
def isServer = FMLCommonHandler.instance.getEffectiveSide.isServer || serverThreads.contains(Thread.currentThread())
def isClient = !isServer
}