Merge branch 'OC1.3-MC1.7.2' of github.com:MightyPirates/OpenComputers into OC1.3-MC1.7.10

This commit is contained in:
Florian Nücke 2014-07-19 13:49:12 +02:00
commit 6b0fa7d9ce
3 changed files with 24 additions and 17 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,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)

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
}