diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 877a2d08a..aa10846f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -15,6 +15,8 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot +import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.registry.game.MBlockEntities import ru.dbotthepony.mc.otm.storage.optics.priority @@ -45,19 +47,21 @@ class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery markDirtyFast() } - val container: MatteryContainer = object : MatteryContainer(::markDirtyFast, 4) { - override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - super.setChanged(slot, new, old) + private inner class Slot(container: SlottedContainer, slot: Int) : ContainerSlot(container, slot) { + override fun notifyChanged(old: ItemStack) { + super.notifyChanged(old) old.getCapability(MatteryCapability.CONDENSATION_DRIVE)?.let { cell.removeStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy).flow(::mode)) } - new.getCapability(MatteryCapability.CONDENSATION_DRIVE)?.let { + item.getCapability(MatteryCapability.CONDENSATION_DRIVE)?.let { cell.addStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy).flow(::mode)) } } - }.also(::addDroppableContainer) + } + + val container = SlottedContainer.simple(4, ::Slot, ::markDirtyFast).also(::addDroppableContainer) init { savetables.stateful(::energy, ENERGY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt index 9855f5b58..2fc33a8f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.container.EnhancedContainer import ru.dbotthepony.mc.otm.menu.DriveMenuSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput @@ -18,7 +19,7 @@ class DriveRackMenu @JvmOverloads constructor( inventory: Inventory, tile: DriveRackBlockEntity? = null ) : MatteryPoweredMenu(MMenus.DRIVE_RACK, containerId, inventory, tile) { - val storageSlots = makeSlots(tile?.container ?: SimpleContainer(4), ::DriveMenuSlot) + val storageSlots = makeSlots(tile?.container ?: EnhancedContainer(4), ::DriveMenuSlot) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority })