diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 378b917a9..96d029eac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -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) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 1559d828e..1f1bc6445 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -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) {