mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
Compiler fun!
This commit is contained in:
parent
9d49a98db7
commit
da8b6c55aa
22
src/main/java/li/cil/oc/util/SideTracker.java
Normal file
22
src/main/java/li/cil/oc/util/SideTracker.java
Normal 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user