mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -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() {
|
override def updateEntity() {
|
||||||
super.updateEntity()
|
super.updateEntity()
|
||||||
if (isServer && isConnected) {
|
if (isServer && isConnected) {
|
||||||
|
lazy val connectors = ForgeDirection.VALID_DIRECTIONS.map(sidedNode).collect {
|
||||||
|
case connector: Connector => connector
|
||||||
|
}
|
||||||
components.zipWithIndex.collect {
|
components.zipWithIndex.collect {
|
||||||
case (Some(mountable: RackMountable), slot) if hasChanged(slot) =>
|
case (Some(mountable: RackMountable), slot) =>
|
||||||
hasChanged(slot) = false
|
if (hasChanged(slot)) {
|
||||||
lastData(slot) = mountable.getData
|
hasChanged(slot) = false
|
||||||
ServerPacketSender.sendRackMountableData(this, slot)
|
lastData(slot) = mountable.getData
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, block)
|
ServerPacketSender.sendRackMountableData(this, slot)
|
||||||
// These are working state dependent, so recompute them.
|
world.notifyBlocksOfNeighborChange(x, y, z, block)
|
||||||
isOutputEnabled = hasRedstoneCard
|
// These are working state dependent, so recompute them.
|
||||||
isAbstractBusAvailable = hasAbstractBusCard
|
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()
|
updateComponents()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user