added side check to avoid potential crash in GUIs

This commit is contained in:
Florian Nücke 2014-03-03 00:09:07 +01:00
parent 461e4abbbf
commit 9d545e653d

View File

@ -1,5 +1,6 @@
package li.cil.oc.common.container
import cpw.mods.fml.common.FMLCommonHandler
import li.cil.oc.api
import li.cil.oc.common.tileentity
import li.cil.oc.server.{PacketSender => ServerPacketSender}
@ -25,11 +26,13 @@ class Robot(playerInventory: InventoryPlayer, robot: tileentity.Robot) extends P
override def detectAndSendChanges() {
super.detectAndSendChanges()
if (FMLCommonHandler.instance.getEffectiveSide.isServer) {
if (math.abs(robot.globalBuffer - lastSentBuffer) > 1) {
lastSentBuffer = robot.globalBuffer
ServerPacketSender.sendPowerState(robot)
}
}
}
override def canInteractWith(player: EntityPlayer) =
super.canInteractWith(player) && robot.canInteract(player.getCommandSenderName)