Update Driver Rack to use SlottedContainer
This commit is contained in:
parent
1f8cd2cfe3
commit
c08ea8a43d
@ -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.capability.energy.WorkerEnergyStorage
|
||||||
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||||
import ru.dbotthepony.mc.otm.container.MatteryContainer
|
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.menu.storage.DriveRackMenu
|
||||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||||
import ru.dbotthepony.mc.otm.storage.optics.priority
|
import ru.dbotthepony.mc.otm.storage.optics.priority
|
||||||
@ -45,19 +47,21 @@ class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery
|
|||||||
markDirtyFast()
|
markDirtyFast()
|
||||||
}
|
}
|
||||||
|
|
||||||
val container: MatteryContainer = object : MatteryContainer(::markDirtyFast, 4) {
|
private inner class Slot(container: SlottedContainer, slot: Int) : ContainerSlot(container, slot) {
|
||||||
override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {
|
override fun notifyChanged(old: ItemStack) {
|
||||||
super.setChanged(slot, new, old)
|
super.notifyChanged(old)
|
||||||
|
|
||||||
old.getCapability(MatteryCapability.CONDENSATION_DRIVE)?.let {
|
old.getCapability(MatteryCapability.CONDENSATION_DRIVE)?.let {
|
||||||
cell.removeStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy).flow(::mode))
|
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))
|
cell.addStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy).flow(::mode))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.also(::addDroppableContainer)
|
}
|
||||||
|
|
||||||
|
val container = SlottedContainer.simple(4, ::Slot, ::markDirtyFast).also(::addDroppableContainer)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
savetables.stateful(::energy, ENERGY_KEY)
|
savetables.stateful(::energy, ENERGY_KEY)
|
||||||
|
@ -4,6 +4,7 @@ import net.minecraft.world.SimpleContainer
|
|||||||
import net.minecraft.world.entity.player.Inventory
|
import net.minecraft.world.entity.player.Inventory
|
||||||
import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.capability.FlowDirection
|
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.DriveMenuSlot
|
||||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||||
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
|
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
|
||||||
@ -18,7 +19,7 @@ class DriveRackMenu @JvmOverloads constructor(
|
|||||||
inventory: Inventory,
|
inventory: Inventory,
|
||||||
tile: DriveRackBlockEntity? = null
|
tile: DriveRackBlockEntity? = null
|
||||||
) : MatteryPoweredMenu(MMenus.DRIVE_RACK, containerId, inventory, tile) {
|
) : 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 energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
|
||||||
val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
|
val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
|
||||||
val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority })
|
val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority })
|
||||||
|
Loading…
Reference in New Issue
Block a user