Added output/input check

This commit is contained in:
Timo Ley 2021-04-11 11:09:33 +02:00
parent f2bb532f65
commit d654762a0e

View file

@ -289,6 +289,7 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr
}
override def receiveEnergy(side: ForgeDirection, i: Int, b: Boolean): Int = {
if (getInputDirections().contains(side)) {
val joule: Double = i * 50
val maxReceive = Math.min(joule, energy.max - energy.value)
if (!b) {
@ -297,8 +298,11 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr
}
return (maxReceive / 50).asInstanceOf[Int]
}
return 0
}
override def extractEnergy(side: ForgeDirection, i: Int, b: Boolean): Int = {
if (getOutputDirections().contains(side)) {
val joule: Double = i * 50
val maxExtract = Math.min(joule, energy.value)
if (!b) {
@ -307,6 +311,8 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr
}
return (maxExtract / 50).asInstanceOf[Int]
}
return 0
}
override def getEnergyStored(side: ForgeDirection): Int = {
(energy.value / 50).asInstanceOf[Int]