mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
removed some redundant code from distributor (that led to an assertion error, yay assertions!) and fixed visuals on additional distributors not updating immediately; fixed derpy optimization breaking receiving power from buildcraft
This commit is contained in:
parent
b535e85c82
commit
dcda6056df
@ -7,11 +7,11 @@ import ic2.api.energy.tile.IEnergySink
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.{Settings, api}
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.{ForgeDirection, MinecraftForge}
|
||||
import universalelectricity.core.block.IElectrical
|
||||
import universalelectricity.core.electricity.ElectricityPack
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
|
||||
@Optional.InterfaceList(Array(
|
||||
new Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@ -39,11 +39,8 @@ class PowerConverter extends Environment with Analyzable with IEnergySink with I
|
||||
}
|
||||
if (isBuildCraftAvailable && demand > 1 && world.getWorldTime % Settings.get.tickFrequency == 0) {
|
||||
val wantInMJ = demand.toFloat / Settings.get.ratioBuildCraft
|
||||
val powerProvider = getPowerProvider
|
||||
if (wantInMJ < powerProvider.getEnergyStored) {
|
||||
val gotInMJ = powerProvider.useEnergy(1, wantInMJ, true)
|
||||
node.changeBuffer(gotInMJ * Settings.get.ratioBuildCraft)
|
||||
}
|
||||
val gotInMJ = getPowerProvider.useEnergy(1, wantInMJ, true)
|
||||
node.changeBuffer(gotInMJ * Settings.get.ratioBuildCraft)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import li.cil.oc.common.tileentity.PowerInformation
|
||||
import li.cil.oc.server.network.Connector
|
||||
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
||||
import li.cil.oc.{Settings, api}
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
import scala.collection.mutable
|
||||
|
||||
class PowerDistributor(val owner: PowerInformation) extends ManagedComponent {
|
||||
@ -20,7 +19,7 @@ class PowerDistributor(val owner: PowerInformation) extends ManagedComponent {
|
||||
|
||||
var dirty = true
|
||||
|
||||
private var lastSentRatio = 0.0
|
||||
private var lastSentRatio = -1.0
|
||||
|
||||
private val buffers = mutable.ArrayBuffer.empty[Connector]
|
||||
|
||||
@ -100,20 +99,6 @@ class PowerDistributor(val owner: PowerInformation) extends ManagedComponent {
|
||||
override def onConnect(node: Node) {
|
||||
super.onConnect(node)
|
||||
if (node == this.node) {
|
||||
for (node <- node.reachableNodes) node match {
|
||||
case connector: Connector if connector.localBufferSize > 0 => this.synchronized {
|
||||
assert(!buffers.contains(connector))
|
||||
buffers += connector
|
||||
globalBuffer += connector.localBuffer
|
||||
globalBufferSize += connector.localBufferSize
|
||||
}
|
||||
case _ => node.host match {
|
||||
case distributor: PowerDistributor if distributor.node.canBeSeenFrom(this.node) =>
|
||||
assert(!distributors.contains(distributor))
|
||||
distributors += distributor
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
assert(!distributors.contains(this))
|
||||
distributors += this
|
||||
dirty = true
|
||||
@ -177,7 +162,7 @@ class PowerDistributor(val owner: PowerInformation) extends ManagedComponent {
|
||||
distributor.globalBufferSize = sumBufferSize
|
||||
distributor.owner.globalBuffer = sumBuffer
|
||||
distributor.owner.globalBufferSize = sumBufferSize
|
||||
if (shouldSend) {
|
||||
if (shouldSend || distributor.lastSentRatio < 0) {
|
||||
distributor.lastSentRatio = fillRatio
|
||||
ServerPacketSender.sendPowerState(distributor.owner)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user