<???>
This commit is contained in:
parent
eb39675b15
commit
f5840c4ca1
@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
|
||||
import ru.dbotthepony.mc.otm.capability.moveEnergy
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue
|
||||
import ru.dbotthepony.mc.otm.core.math.defineDecimal
|
||||
@ -86,19 +87,8 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
|
||||
for (ent in level.getEntitiesOfClass(ServerPlayer::class.java, AABB(x, y, z, x + 1.0, y + 2.0, z + 1.0))) {
|
||||
ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||
if (!it.isAndroid)
|
||||
return@ifPresentK
|
||||
|
||||
val missing = it.androidEnergy.missingPower
|
||||
|
||||
if (missing > Decimal.ZERO) {
|
||||
val extract = energy.extractEnergy(missing, true)
|
||||
|
||||
if (extract > Decimal.ZERO) {
|
||||
val received = it.androidEnergy.receiveEnergy(extract, false)
|
||||
energy.extractEnergy(received, false)
|
||||
}
|
||||
}
|
||||
if (it.isAndroid)
|
||||
moveEnergy(energy, it.androidEnergy, amount = energy.batteryLevel, simulate = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,15 +102,9 @@ class AndroidPowerSource(
|
||||
|
||||
if (!item.isEmpty) {
|
||||
item.getCapability(ForgeCapabilities.ENERGY).ifPresentK {
|
||||
if (it is IMatteryEnergyStorage) {
|
||||
val extracted = it.receiveEnergy(howMuch, simulate)
|
||||
received += extracted
|
||||
howMuch -= extracted
|
||||
} else {
|
||||
val extracted = it.receiveEnergy(howMuch, simulate)
|
||||
received += extracted
|
||||
howMuch -= extracted
|
||||
}
|
||||
val extracted = it.receiveEnergy(howMuch, simulate)
|
||||
received += extracted
|
||||
howMuch -= extracted
|
||||
}
|
||||
|
||||
if (howMuch.isZero) {
|
||||
|
Loading…
Reference in New Issue
Block a user