Allow to extract matter containers from matter capacitor bank

This commit is contained in:
DBotThePony 2023-03-25 20:37:20 +07:00
parent 065dd8bbe6
commit f683f5acf8
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 9 additions and 3 deletions

View File

@ -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
}
}))

View File

@ -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)