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

This commit is contained in:
Florian Nücke 2013-12-23 14:25:08 +01:00
parent 73999ff939
commit c0adb97603

View File

@ -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()
}
}