mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-24 04:50:30 -04:00
Merge branch 'OC1.3-MC1.7.2' of github.com:MightyPirates/OpenComputers into OC1.3-MC1.7.10
This commit is contained in:
commit
6b0fa7d9ce
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,11 +1,11 @@
|
||||
package li.cil.oc.common
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent._
|
||||
import cpw.mods.fml.common.gameevent.TickEvent
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent
|
||||
import cpw.mods.fml.common.{FMLCommonHandler, Optional}
|
||||
import ic2.api.energy.event.{EnergyTileLoadEvent, EnergyTileUnloadEvent}
|
||||
import li.cil.oc._
|
||||
import li.cil.oc.api.Network
|
||||
@ -85,7 +85,7 @@ object EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
def playerLoggedIn(e: PlayerLoggedInEvent) {
|
||||
if (FMLCommonHandler.instance.getEffectiveSide.isServer) e.player match {
|
||||
if (SideTracker.isServer) e.player match {
|
||||
case player: EntityPlayerMP =>
|
||||
if (!LuaStateFactory.isAvailable) {
|
||||
player.addChatMessage(Localization.Chat.WarningLuaFallback)
|
||||
|
@ -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