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 1e437404a..40d188eb6 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 @@ -60,8 +60,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) return summ } - override fun tick() { - super.tick() + private fun updateGaugeLevel() { var stored = Decimal.ZERO var maxStored = Decimal.ZERO @@ -74,6 +73,11 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) gaugeLevel = stored.percentage(maxStored) } + override fun tick() { + super.tick() + updateGaugeLevel() + } + override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -134,7 +138,6 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) super.notifyChanged(old) capacitorStatus[slot].value = item.getCapability(MatteryCapability.MATTER_ITEM) != null - gaugeLevel = storedMatter.percentage(maxStoredMatter) } override fun canAutomationPlaceItem(itemStack: ItemStack): Boolean { @@ -155,7 +158,12 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) get() = 1 } - val container = SlottedContainer.simple(BatteryBankBlockEntity.CAPACITY, ::Slot, ::markDirtyFast).also(::addDroppableContainer) + private fun containerUpdated() { + markDirtyFast() + updateGaugeLevel() + } + + val container = SlottedContainer.simple(BatteryBankBlockEntity.CAPACITY, ::Slot, ::containerUpdated).also(::addDroppableContainer) val itemConfig = ConfigurableItemHandler(inputOutput = container) val capacitorStatus = immutableList(BatteryBankBlockEntity.CAPACITY) {