From c0adb97603b1d4c38efe9b9136ce4793c78d9e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 23 Dec 2013 14:25:08 +0100 Subject: [PATCH] making sure robot upgrade is properly sent to client on load in case TE is sent before first update (player triggered load) by sending it again in the first update --- li/cil/oc/common/tileentity/Robot.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/li/cil/oc/common/tileentity/Robot.scala b/li/cil/oc/common/tileentity/Robot.scala index 071bb6fbf..ac199972c 100644 --- a/li/cil/oc/common/tileentity/Robot.scala +++ b/li/cil/oc/common/tileentity/Robot.scala @@ -385,7 +385,7 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w val stack = getStackInSlot(3) // We're guaranteed to have a driver for entries. environment.save(dataTag(Registry.driverFor(stack).get, stack)) - case _ => + case _ => // See onConnect() } nbt.setNewCompoundTag("upgrade", getStackInSlot(3).writeToNBT) } @@ -409,6 +409,16 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w computer.node.connect(buffer.node) computer.node.connect(gpu.node) buffer.node.connect(keyboard.node) + // There's a chance the server sends a robot tile entity to its clients + // before the tile entity's first update was called, in which case the + // component list isn't initialized (e.g. when a client triggers a chunk + // load, most noticeable in single player). In that case the current + // equipment will be initialized incorrectly. So we have to send it + // again when the first update is run. One of the two (this and the info + // sent in writeToNBTForClient) may be superfluous, but the packet is + // quite small compared to what else is sent on a chunk load, so we don't + // really worry about it and just send it. + saveUpgrade() } }