Fixed energy glitch in robots carried over from 1.2.

This commit is contained in:
Florian Nücke 2014-05-29 19:07:33 +02:00
parent fcc0dc85c3
commit 8540f2eed0
3 changed files with 6 additions and 3 deletions

View File

@ -284,6 +284,10 @@ class Robot(val isRemote: Boolean) extends traits.Computer with traits.PowerInfo
// Ensure we have a node address, because the proxy needs this to initialize // Ensure we have a node address, because the proxy needs this to initialize
// its own node to the same address ours has. // its own node to the same address ours has.
api.Network.joinNewNetwork(node) api.Network.joinNewNetwork(node)
// Flush excess energy to other components (mostly relevant for upgrading
// robots from 1.2 to 1.3, to move energy to the experience upgrade).
bot.node.setLocalBufferSize(bot.node.localBufferSize)
} }
} }

View File

@ -6,7 +6,7 @@ import li.cil.oc.common.component.ManagedComponent
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
class UpgradeExperience extends ManagedComponent { class UpgradeExperience extends ManagedComponent {
def node = api.Network.newNode(this, Visibility.Network). val node = api.Network.newNode(this, Visibility.Network).
withComponent("experience"). withComponent("experience").
withConnector(30 * Settings.get.bufferPerLevel). withConnector(30 * Settings.get.bufferPerLevel).
create() create()
@ -25,7 +25,6 @@ class UpgradeExperience extends ManagedComponent {
if (experience >= xpForNextLevel) { if (experience >= xpForNextLevel) {
updateXpInfo() updateXpInfo()
} }
// ServerPacketSender.sendRobotXp(this)
} }
} }

View File

@ -94,7 +94,7 @@ trait Connector extends network.Connector with Node {
} }
localBufferSize = math.max(size, 0) localBufferSize = math.max(size, 0)
val surplus = math.max(localBuffer - localBufferSize, 0) val surplus = math.max(localBuffer - localBufferSize, 0)
localBuffer = math.min(localBuffer, localBufferSize) changeBuffer(-surplus)
d.changeBuffer(surplus) d.changeBuffer(surplus)
} }
case _ => case _ =>