Redstone controls in menus, fix a lot of machines ignoring their redstone control

This commit is contained in:
DBotThePony 2023-01-30 23:48:56 +07:00
parent 9e995a88ae
commit 0ad7618ad7
Signed by: DBot
GPG Key ID: DCC23B5715498507
24 changed files with 101 additions and 6 deletions

View File

@ -486,7 +486,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
}
override fun insertStack(stack: ItemStackWrapper, simulate: Boolean): ItemStackWrapper {
if (energy.batteryLevel.isZero || !filter.match(stack.item))
if (redstoneControl.isBlockedByRedstone || energy.batteryLevel.isZero || !filter.match(stack.item))
return stack
val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * stack.count
@ -531,7 +531,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter
}
override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): ItemStackWrapper {
if (!amount.isPositive)
if (redstoneControl.isBlockedByRedstone || !amount.isPositive)
return ItemStackWrapper.EMPTY
val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * amount

View File

@ -194,7 +194,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState)
}
override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack {
if (!filter.match(stack))
if (redstoneControl.isBlockedByRedstone || !filter.match(stack))
return stack
val view = cell.storageGraph?.getVirtualComponent(ITEM_STORAGE) ?: return stack
@ -225,6 +225,9 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState)
}
fun tick() {
if (redstoneControl.isBlockedByRedstone)
return
batteryChargeLoop()
cell.tickEnergyDemanding()
@ -334,6 +337,9 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) :
}
fun tick() {
if (redstoneControl.isBlockedByRedstone)
return
batteryChargeLoop()
cell.tickEnergyDemanding()

View File

@ -76,6 +76,9 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState
}
fun tick() {
if (redstoneControl.isBlockedByRedstone)
return
batteryChargeLoop()
if (energy.batteryLevel.isZero)

View File

@ -145,6 +145,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
override val energyFlow = FlowDirection.input(isInput)
override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal {
if (redstoneControl.isBlockedByRedstone)
return Decimal.ZERO
val it = inputCapability.first
if (it != null) {
@ -170,6 +173,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat
}
override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal {
if (redstoneControl.isBlockedByRedstone)
return Decimal.ZERO
val it = outputCapability.first
if (it != null) {

View File

@ -133,6 +133,9 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte
}
fun tick() {
if (redstoneControl.isBlockedByRedstone)
return
val charge = container[SLOT_CHARGE]
val discharge = container[SLOT_DISCHARGE]

View File

@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
@ -40,6 +41,8 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title:
ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode"), onPress = menu.workFlow::switchValue)
}
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
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.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
@ -27,6 +28,8 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory
SlotPanel(this, frame, menu.outputMain, 74f, PROGRESS_SLOT_TOP)
SlotPanel(this, frame, menu.outputStacking, 56f, PROGRESS_SLOT_TOP)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
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.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
@ -23,6 +24,8 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title
ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true
SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
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.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
@ -29,6 +30,8 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory
SlotPanel(this, frame, menu.storageSlots[3], 80f, PROGRESS_SLOT_TOP + 22f)
SlotPanel(this, frame, menu.storageSlots[4], 80f + 18f, PROGRESS_SLOT_TOP + 22f)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
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.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
@ -24,6 +25,8 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97
ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true
SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -40,7 +40,7 @@ fun <S : MatteryScreen<*>> makeDeviceControls(
parent: FramePanel<S>,
redstone: IPlayerInputWithFeedback<RedstoneSetting>? = null
): EditablePanel<S> {
val panel = object : EditablePanel<S>(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f) {
val panel = object : EditablePanel<S>(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f, x = parent.width + 3f) {
override fun tick() {
super.tick()
x = parent.width + 3f

View File

@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
@ -28,6 +29,8 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
@ -28,6 +29,8 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
@ -28,6 +29,8 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit
CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel
@ -66,6 +67,8 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve
}
}
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.render.drawRect
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel
@ -730,6 +731,8 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
this.playerStrip = playerStrip
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}

View File

@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component
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.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
@ -12,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu
class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen<ChemicalGeneratorMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
val frame = super.makeMainFrame()!!
WidePowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
@ -33,6 +34,8 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory,
SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP)
SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkNumberInputPanel
import ru.dbotthepony.mc.otm.core.util.formatPower
import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu
@ -106,6 +107,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title:
limitsTab.onClose!!.run()
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
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.widget.HorizontalPowerGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel
@ -61,6 +62,8 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp
it.dockRight
}
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
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.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
@ -12,7 +13,7 @@ import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) :
MatteryScreen<PlatePressMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<out MatteryScreen<*>> {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
val frame = super.makeMainFrame()!!
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
@ -22,6 +23,8 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon
ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP)
SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP)
makeDeviceControls(this, frame, redstone = menu.redstone)
return frame
}
}

View File

@ -5,6 +5,8 @@ import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import net.minecraft.world.SimpleContainer
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
abstract class MatteryPoweredMenu protected constructor(
menuType: MenuType<*>,
@ -14,6 +16,7 @@ abstract class MatteryPoweredMenu protected constructor(
) : MatteryMenu(menuType, containerID, inventory, tile) {
val powerWidget: LevelGaugeWidget
val batterySlot: BatterySlot
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
init {
if (tile == null) {
@ -22,6 +25,7 @@ abstract class MatteryPoweredMenu protected constructor(
} else {
powerWidget = LevelGaugeWidget(this, tile.energy)
batterySlot = BatterySlot(tile.batteryContainer, 0)
redstone.with(tile.redstoneControl::redstoneSetting)
}
addSlot(batterySlot)

View File

@ -5,10 +5,12 @@ import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack
import net.minecraftforge.common.ForgeHooks
import net.minecraftforge.common.capabilities.ForgeCapabilities
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity
import ru.dbotthepony.mc.otm.core.ifPresentK
import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus
@ -16,6 +18,14 @@ import ru.dbotthepony.mc.otm.registry.MMenus
class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, tile: ChemicalGeneratorBlockEntity? = null)
: MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) {
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
init {
if (tile != null) {
redstone.with(tile.redstoneControl::redstoneSetting)
}
}
val container = tile?.container ?: SimpleContainer(3)
val fuelSlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_INPUT) {
@ -44,6 +54,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t
val energy = LevelGaugeWidget(this, tile?.energy)
var burnTime by mSynchronizer.int()
override val storageSlots = listOf(
addSlot(fuelSlot),
addSlot(batterySlot),

View File

@ -5,10 +5,12 @@ import kotlin.jvm.JvmOverloads
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.Slot
import net.minecraft.world.level.block.Block
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock
import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity
import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.registry.MMenus
import java.math.BigDecimal
@ -28,6 +30,14 @@ class EnergyCounterMenu @JvmOverloads constructor(
tile.level?.setBlock(tile.blockPos, tile.blockState.setValue(EnergyCounterBlock.INPUT_DIRECTION, tile.blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION).opposite), Block.UPDATE_ALL)
}
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
init {
if (tile != null) {
redstone.with(tile.redstoneControl::redstoneSetting)
}
}
var inputDirection by mSynchronizer.enum(Direction::class.java)
val maxIOInput = bigDecimalInput {

View File

@ -5,10 +5,12 @@ import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.Slot
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.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus
@ -22,6 +24,14 @@ class EnergyServoMenu @JvmOverloads constructor(
val powerGauge = LevelGaugeWidget(this, tile?.energy)
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
init {
if (tile != null) {
redstone.with(tile.redstoneControl::redstoneSetting)
}
}
init {
val container = tile?.container ?: SimpleContainer(2)