mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
Fixed robots sometimes holding their innards in their hands.
This *probably* fixes #637 (it at least fixes it partially).
This commit is contained in:
parent
a96aa6a997
commit
1b3f1fa2db
@ -591,7 +591,7 @@ object TextBuffer {
|
||||
private lazy val Debugger = api.Items.get("debugger")
|
||||
|
||||
private def debug(message: String) {
|
||||
if (api.Items.get(Minecraft.getMinecraft.thePlayer.getHeldItem) == Debugger) {
|
||||
if (Minecraft.getMinecraft != null && Minecraft.getMinecraft.thePlayer != null && api.Items.get(Minecraft.getMinecraft.thePlayer.getHeldItem) == Debugger) {
|
||||
OpenComputers.log.info(s"[NETWORK DEBUGGER] Sending packet to node $nodeAddress: " + message)
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +486,20 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
|
||||
|
||||
override def markDirty() {
|
||||
super.markDirty()
|
||||
// Avoid getting into a bad state on the client when updating before we
|
||||
// got the descriptor packet from the server. If we manage to open the
|
||||
// GUI before the descriptor packet arrived, close it again because it is
|
||||
// invalid anyway.
|
||||
if (inventorySize >= 0) {
|
||||
updateInventorySize()
|
||||
}
|
||||
else if (isClient) {
|
||||
Minecraft.getMinecraft.currentScreen match {
|
||||
case robotGui: gui.Robot if robotGui.robot == this =>
|
||||
Minecraft.getMinecraft.displayGuiScreen(null)
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
renderingErrored = false
|
||||
}
|
||||
|
||||
@ -592,8 +605,9 @@ class Robot extends traits.Computer with traits.PowerInformation with IFluidHand
|
||||
setInventorySlotContents(slot, null)
|
||||
if (stack != null) removed += stack
|
||||
}
|
||||
Array.copy(components, getSizeInventory - componentCount, components, realSize, componentCount)
|
||||
for (slot <- getSizeInventory - componentCount until getSizeInventory if slot < realSize || slot >= realSize + componentCount) {
|
||||
val copyComponentCount = math.min(getSizeInventory, componentCount)
|
||||
Array.copy(components, getSizeInventory - copyComponentCount, components, realSize, copyComponentCount)
|
||||
for (slot <- math.max(0, getSizeInventory - componentCount) until getSizeInventory if slot < realSize || slot >= realSize + componentCount) {
|
||||
components(slot) = None
|
||||
}
|
||||
getSizeInventory = realSize + componentCount
|
||||
|
Loading…
x
Reference in New Issue
Block a user