diff --git a/li/cil/oc/common/tileentity/Computer.scala b/li/cil/oc/common/tileentity/Computer.scala index 066d662f7..294ec6572 100644 --- a/li/cil/oc/common/tileentity/Computer.scala +++ b/li/cil/oc/common/tileentity/Computer.scala @@ -37,7 +37,7 @@ abstract class Computer(isRemote: Boolean) extends Environment with ComponentInv // Note: we implement IContext in the TE to allow external components to cast // their owner to it (to allow interacting with their owning computer). - def address() = computer.address + def address = computer.address def canInteract(player: String) = if (isServer) computer.canInteract(player) diff --git a/li/cil/oc/common/tileentity/Robot.scala b/li/cil/oc/common/tileentity/Robot.scala index 509a89b88..318e3c3c9 100644 --- a/li/cil/oc/common/tileentity/Robot.scala +++ b/li/cil/oc/common/tileentity/Robot.scala @@ -159,9 +159,11 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w // the client by sending a corresponding packet. This also saves us from // having to send the complete state again (e.g. screen buffer) each move. world.setBlockToAir(nx, ny, nz) - val created = Blocks.robotProxy.setBlock(world, nx, ny, nz, 1) + // In some cases (though I couldn't quite figure out which one) setBlock + // will return true, even though the block was not created / adjusted. + val created = Blocks.robotProxy.setBlock(world, nx, ny, nz, 1) && + world.getBlockTileEntity(nx, ny, nz) == proxy if (created) { - assert(world.getBlockTileEntity(nx, ny, nz) == proxy) assert(x == nx && y == ny && z == nz) world.setBlock(ox, oy, oz, 0, 0, 1) Blocks.robotAfterimage.setBlock(world, ox, oy, oz, 1) diff --git a/li/cil/oc/common/tileentity/RobotProxy.scala b/li/cil/oc/common/tileentity/RobotProxy.scala index 00f3da150..ea4a3293c 100644 --- a/li/cil/oc/common/tileentity/RobotProxy.scala +++ b/li/cil/oc/common/tileentity/RobotProxy.scala @@ -2,7 +2,7 @@ package li.cil.oc.common.tileentity import cpw.mods.fml.common.Optional import cpw.mods.fml.relauncher.{Side, SideOnly} -import li.cil.oc.api +import li.cil.oc.{Settings, api} import li.cil.oc.api.Network import li.cil.oc.api.network._ import li.cil.oc.client.gui @@ -61,10 +61,17 @@ class RobotProxy(val robot: Robot) extends Computer(robot.isClient) with ISidedI // ----------------------------------------------------------------------- // override def updateEntity() { - if (node != null && node.network == null) { + robot.updateEntity() + if (!addedToNetwork) { + addedToNetwork = true + // Use the same address we use internally on the outside. + if (isServer) { + val nbt = new NBTTagCompound() + nbt.setString("address", robot.address) + node.load(nbt) + } Network.joinOrCreateNetwork(this) } - robot.updateEntity() } override def validate() { @@ -127,10 +134,7 @@ class RobotProxy(val robot: Robot) extends Computer(robot.isClient) with ISidedI // ----------------------------------------------------------------------- // - override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = { - robot.onAnalyze(player, side, hitX, hitY, hitZ) - Array(node) - } + override def onAnalyze(player: EntityPlayer, side: Int, hitX: Float, hitY: Float, hitZ: Float) = robot.onAnalyze(player, side, hitX, hitY, hitZ) // ----------------------------------------------------------------------- // diff --git a/li/cil/oc/server/component/machine/Machine.scala b/li/cil/oc/server/component/machine/Machine.scala index 97c5df611..6790a396c 100644 --- a/li/cil/oc/server/component/machine/Machine.scala +++ b/li/cil/oc/server/component/machine/Machine.scala @@ -508,6 +508,9 @@ class Machine(val owner: Machine.Owner) extends ManagedComponent with Context wi components ++= nbt.getTagList("components").iterator[NBTTagCompound].map(c => c.getString("address") -> c.getString("name")) + rom.foreach(rom => rom.load(nbt.getCompoundTag("rom"))) + tmp.foreach(tmp => tmp.load(nbt.getCompoundTag("tmp"))) + if (state.size > 0 && state.top != Machine.State.Stopped && init()) { architecture.load(nbt) @@ -534,8 +537,6 @@ class Machine(val owner: Machine.Owner) extends ManagedComponent with Context wi }.toArray) }) - rom.foreach(rom => rom.load(nbt.getCompoundTag("rom"))) - tmp.foreach(tmp => tmp.load(nbt.getCompoundTag("tmp"))) timeStarted = nbt.getLong("timeStarted") cpuTime = nbt.getLong("cpuTime") remainingPause = nbt.getInteger("remainingPause") @@ -572,6 +573,9 @@ class Machine(val owner: Machine.Owner) extends ManagedComponent with Context wi } nbt.setTag("components", componentsNbt) + rom.foreach(rom => nbt.setNewCompoundTag("rom", rom.save)) + tmp.foreach(tmp => nbt.setNewCompoundTag("tmp", tmp.save)) + if (state.top != Machine.State.Stopped) { architecture.save(nbt) @@ -601,9 +605,6 @@ class Machine(val owner: Machine.Owner) extends ManagedComponent with Context wi } nbt.setTag("signals", signalsNbt) - rom.foreach(rom => nbt.setNewCompoundTag("rom", rom.save)) - tmp.foreach(tmp => nbt.setNewCompoundTag("tmp", tmp.save)) - nbt.setLong("timeStarted", timeStarted) nbt.setLong("cpuTime", cpuTime) nbt.setInteger("remainingPause", remainingPause)