diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 4cf96e086..67a707821 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -17,13 +17,17 @@ import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters +import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot +import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer +import ru.dbotthepony.mc.otm.container.slotted.and import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState) { - val discharge = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) - val charge = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val discharge = SlottedContainer.simple(1, AutomationFilters.DISCHARGABLE.filteredProvider, ::markDirtyFast).also(::addDroppableContainer) + val charge = SlottedContainer.simple(1, AutomationFilters.CHARGEABLE.filteredProvider, ::markDirtyFast).also(::addDroppableContainer) val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : IMatteryEnergyStorage { override val energyFlow: FlowDirection get() { @@ -61,11 +65,7 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte }) val energyConfig = ConfigurableEnergy(energy, possibleModes = FlowDirection.BI_DIRECTIONAL) - - val itemConfig = ConfigurableItemHandler( - input = charge.handler(HandlerFilter.OnlyIn.and(HandlerFilter.Chargeable)), - output = discharge.handler(HandlerFilter.OnlyOut.and(HandlerFilter.Dischargeable)) - ) + val itemConfig = ConfigurableItemHandler(input = charge, output = discharge) init { savetables.stateful(::charge) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 73b7568d3..61cdd9018 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -1,36 +1,25 @@ package ru.dbotthepony.mc.otm.menu.tech -import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity -import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer +import ru.dbotthepony.mc.otm.menu.BatteryMenuSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.menu.MatteryMenuSlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.game.MMenus -class EnergyServoMenu @JvmOverloads constructor( +class EnergyServoMenu( p_38852_: Int, inventory: Inventory, tile: EnergyServoBlockEntity? = null ) : MatteryMenu(MMenus.ENERGY_SERVO, p_38852_, inventory, tile) { - val dischargeSlot = object : MatteryMenuSlot(tile?.discharge ?: SimpleContainer(1), 0) { - override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && (itemStack.energy?.canExtract() ?: false) - } - } - - val chargeSlot = object : MatteryMenuSlot(tile?.charge ?: SimpleContainer(1), 0) { - override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && (itemStack.energy?.canReceive() ?: false) - } - } - + val dischargeSlot = BatteryMenuSlot(tile?.discharge ?: SlottedContainer.filtered(1), 0, direction = FlowDirection.OUTPUT) + val chargeSlot = BatteryMenuSlot(tile?.charge ?: SlottedContainer.filtered(1), 0, direction = FlowDirection.INPUT) val equipment = makeEquipmentSlots(mapMoveToExternal = true) val powerGauge = ProfiledLevelGaugeWidget(this, tile?.energy)