From f683f5acf8f30c56e9ae6a96bec76bde74c8ec86 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:37:20 +0700 Subject: [PATCH] Allow to extract matter containers from matter capacitor bank --- .../entity/matter/MatterCapacitorBankBlockEntity.kt | 10 ++++++++-- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 55b269ea3..cc597834f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -128,13 +128,19 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) } }.also(::addDroppableContainer) - val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.getCapability(MatteryCapability.MATTER).isPresent } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return false + stack.getCapability(MatteryCapability.MATTER).ifPresentK { + if (it.storedMatter.isPositive) { + return false + } + } + + return true } })) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index ad1a054a4..dbb5c6cc2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -57,7 +57,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private var lastTickDischarged = false init { - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) savetables.int(::currentChangeSlot) savetables.int(::currentDischangeSlot) savetables.bool(::lastTickCharged)