diff --git a/src/main/java/li/cil/oc/util/SideTracker.java b/src/main/java/li/cil/oc/util/SideTracker.java new file mode 100644 index 000000000..6618e795f --- /dev/null +++ b/src/main/java/li/cil/oc/util/SideTracker.java @@ -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 serverThreads = Collections.newSetFromMap(new java.util.WeakHashMap()); + + 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(); + } +} diff --git a/src/main/scala/li/cil/oc/util/SideTracker.scala b/src/main/scala/li/cil/oc/util/SideTracker.scala deleted file mode 100644 index d9662869a..000000000 --- a/src/main/scala/li/cil/oc/util/SideTracker.scala +++ /dev/null @@ -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 -}