Allow bottler slots to be filtered
This commit is contained in:
parent
e3a11b3b9e
commit
f011c1a912
@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer
|
||||
import ru.dbotthepony.mc.otm.container.HandlerFilter
|
||||
import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
||||
import ru.dbotthepony.mc.otm.container.slotted.ContainerSlot
|
||||
import ru.dbotthepony.mc.otm.container.slotted.FilteredContainerSlot
|
||||
import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer
|
||||
import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu
|
||||
import ru.dbotthepony.mc.otm.registry.game.MBlockEntities
|
||||
@ -40,13 +41,13 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) :
|
||||
override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, upgrades.transform(MachinesConfig.MatterBottler.VALUES)))
|
||||
val energyConfig = ConfigurableEnergy(energy)
|
||||
|
||||
private inner class BottlingSlot(container: SlottedContainer, slot: Int) : ContainerSlot(container, slot) {
|
||||
private inner class BottlingSlot(container: SlottedContainer, slot: Int) : FilteredContainerSlot(container, slot) {
|
||||
override fun canAutomationPlaceItem(itemStack: ItemStack): Boolean {
|
||||
return super.canAutomationPlaceItem(itemStack) && isBottling && itemStack.getCapability(MatteryCapability.MATTER_ITEM)?.receiveMatterChecked(Decimal.ONE, true)?.isPositive == true
|
||||
}
|
||||
}
|
||||
|
||||
private inner class UnBottlingSlot(container: SlottedContainer, slot: Int) : ContainerSlot(container, slot) {
|
||||
private inner class UnBottlingSlot(container: SlottedContainer, slot: Int) : FilteredContainerSlot(container, slot) {
|
||||
override fun canAutomationPlaceItem(itemStack: ItemStack): Boolean {
|
||||
return super.canAutomationPlaceItem(itemStack) && !isBottling && itemStack.getCapability(MatteryCapability.MATTER_ITEM)?.extractMatterChecked(Decimal.ONE, true)?.isPositive == true
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.container.IFilteredContainerSlot
|
||||
import ru.dbotthepony.mc.otm.container.util.containerSlotOrNull
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.menu.UserFilteredMenuSlot
|
||||
import javax.annotation.Nonnull
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@ -204,7 +205,7 @@ fun <S : MatteryScreen<*>, T : Slot> BatterySlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.BATTERY_SLOT_BACKGROUND }
|
||||
) = (if (slot is UserFilteredMenuSlot) UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) else SlotPanel(screen, parent, slot, x, y, width, height)).also { it.slotBackgroundEmpty = Widgets18.BATTERY_SLOT_BACKGROUND }
|
||||
|
||||
fun <S : MatteryScreen<*>, T : Slot> EquipmentBatterySlotPanel(
|
||||
screen: S,
|
||||
@ -214,7 +215,7 @@ fun <S : MatteryScreen<*>, T : Slot> EquipmentBatterySlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND }
|
||||
) = (if (slot is UserFilteredMenuSlot) UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) else SlotPanel(screen, parent, slot, x, y, width, height)).also { it.slotBackgroundEmpty = Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND }
|
||||
|
||||
fun <S : MatteryScreen<*>, T : Slot> PatternSlotPanel(
|
||||
screen: S,
|
||||
@ -224,7 +225,7 @@ fun <S : MatteryScreen<*>, T : Slot> PatternSlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.PATTERN_SLOT_BACKGROUND }
|
||||
) = (if (slot is UserFilteredMenuSlot) UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) else SlotPanel(screen, parent, slot, x, y, width, height)).also { it.slotBackgroundEmpty = Widgets18.PATTERN_SLOT_BACKGROUND }
|
||||
|
||||
fun <S : MatteryScreen<*>, T : Slot> MatterCapacitorSlotPanel(
|
||||
screen: S,
|
||||
@ -234,4 +235,4 @@ fun <S : MatteryScreen<*>, T : Slot> MatterCapacitorSlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.MATTER_CAPACITOR_SLOT_BACKGROUND }
|
||||
) = (if (slot is UserFilteredMenuSlot) UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) else SlotPanel(screen, parent, slot, x, y, width, height)).also { it.slotBackgroundEmpty = Widgets18.MATTER_CAPACITOR_SLOT_BACKGROUND }
|
||||
|
@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenuSlot
|
||||
import ru.dbotthepony.mc.otm.menu.UserFilteredMenuSlot
|
||||
import ru.dbotthepony.mc.otm.menu.makeSlots
|
||||
import ru.dbotthepony.mc.otm.menu.makeUpgradeSlots
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
|
||||
@ -28,8 +29,8 @@ class MatterBottlerMenu(
|
||||
val progressWidget = ProgressGaugeWidget(this)
|
||||
val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter))
|
||||
|
||||
val storageSlots: ImmutableList<MatteryMenuSlot> = makeSlots(CombinedContainer(tile?.bottling ?: SlottedContainer.simple(3), tile?.unbottling ?: SlottedContainer.simple(3))) { it, index ->
|
||||
object : MatteryMenuSlot(it, index) {
|
||||
val storageSlots: ImmutableList<UserFilteredMenuSlot> = makeSlots(CombinedContainer(tile?.bottling ?: SlottedContainer.filtered(3), tile?.unbottling ?: SlottedContainer.filtered(3))) { it, index ->
|
||||
object : UserFilteredMenuSlot(it, index) {
|
||||
override fun mayPlace(itemStack: ItemStack): Boolean {
|
||||
val cap = itemStack.getCapability(MatteryCapability.MATTER_ITEM) ?: return false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user