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 bc77a87fd..55b269ea3 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 @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal @@ -122,17 +123,27 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) val container = object : MatteryContainer(this::setChangedLight, BatteryBankBlockEntity.CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - capacitorStatus[slot].value = new.getCapability(MatteryCapability.MATTER).isPresent + capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent gaugeLevel = (storedMatter / maxStoredMatter).toFloat() } }.also(::addDroppableContainer) + val itemConfig = ConfigurableItemHandler(input = 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 + } + })) + val capacitorStatus = immutableList(BatteryBankBlockEntity.CAPACITY) { synchronizer.bool(false) } init { - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) exposeGlobally(MatteryCapability.MATTER, this) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt index f1c7767f3..0cfb538d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt @@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -22,6 +23,8 @@ class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inv for (i in 6 .. 11) MatterCapacitorSlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) + makeDeviceControls(this, frame, itemConfig = menu.itemConfig) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index c8ca49197..fe1b4cbf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatterContainerInputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -14,11 +15,10 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterCapacitorBankBlockEntity? = null -) : MatteryMenu( - MMenus.MATTER_CAPACITOR_BANK, p_38852_, inventory, tile -) { +) : MatteryMenu(MMenus.MATTER_CAPACITOR_BANK, p_38852_, inventory, tile) { val matterGauge = LevelGaugeWidget(this) val totalMatterGauge = LevelGaugeWidget(this) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val storageSlots: List