mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 09:18:05 -04:00
Power mountables without requiring them to be connected to the outside. Closes #2020.
This commit is contained in:
parent
7d6da949de
commit
c2a79a19eb
@ -383,15 +383,33 @@ class Rack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalance
|
||||
override def updateEntity() {
|
||||
super.updateEntity()
|
||||
if (isServer && isConnected) {
|
||||
lazy val connectors = ForgeDirection.VALID_DIRECTIONS.map(sidedNode).collect {
|
||||
case connector: Connector => connector
|
||||
}
|
||||
components.zipWithIndex.collect {
|
||||
case (Some(mountable: RackMountable), slot) if hasChanged(slot) =>
|
||||
hasChanged(slot) = false
|
||||
lastData(slot) = mountable.getData
|
||||
ServerPacketSender.sendRackMountableData(this, slot)
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, block)
|
||||
// These are working state dependent, so recompute them.
|
||||
isOutputEnabled = hasRedstoneCard
|
||||
isAbstractBusAvailable = hasAbstractBusCard
|
||||
case (Some(mountable: RackMountable), slot) =>
|
||||
if (hasChanged(slot)) {
|
||||
hasChanged(slot) = false
|
||||
lastData(slot) = mountable.getData
|
||||
ServerPacketSender.sendRackMountableData(this, slot)
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, block)
|
||||
// These are working state dependent, so recompute them.
|
||||
isOutputEnabled = hasRedstoneCard
|
||||
isAbstractBusAvailable = hasAbstractBusCard
|
||||
}
|
||||
|
||||
// Power mountables without requiring them to be connected to the outside.
|
||||
mountable.node match {
|
||||
case connector: Connector =>
|
||||
var remaining = Settings.get.serverRackRate
|
||||
for (outside <- connectors if remaining > 0) {
|
||||
val received = remaining + outside.changeBuffer(-remaining)
|
||||
val rejected = connector.changeBuffer(received)
|
||||
outside.changeBuffer(rejected)
|
||||
remaining -= received - rejected
|
||||
}
|
||||
case _ => // Nothing using energy.
|
||||
}
|
||||
}
|
||||
|
||||
updateComponents()
|
||||
|
Loading…
x
Reference in New Issue
Block a user