diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 21fedbda6..c12d6d5b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -221,25 +221,35 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } inner class ConfigurableItemHandler( - val input: IItemHandler? = null, - val output: IItemHandler? = null, + input: IItemHandler? = null, + output: IItemHandler? = null, inputOutput: IItemHandler? = null, val battery: IItemHandler? = null, - val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT), - val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK), - val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.LEFT), - val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.RIGHT), - val topDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.TOP), - val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BOTTOM), + val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.FRONT), + val backDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.BACK), + val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.LEFT), + val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.RIGHT), + val topDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.TOP), + val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.BOTTOM), ) { val sideless: IItemHandler val possibleViews: ImmutableSet val inputOutput: IItemHandler? + val input: IItemHandler? + val output: IItemHandler? init { if ((input != null || output != null) && inputOutput != null) throw IllegalArgumentException("Either specify input or/and output separately, or specify inputOutput") + if (inputOutput != null) { + this.input = inputOutput + this.output = inputOutput + } else { + this.input = input + this.output = output + } + val builder = ImmutableSet.Builder() builder.add(ItemHandlerMode.DISABLED) @@ -430,14 +440,14 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } companion object { - private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode { + private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, inputOutput: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode { if (side == RelativeSide.BACK && battery != null) { return ItemHandlerMode.BATTERY } - if (input == null && output == null) { + if (input == null && output == null && inputOutput == null) { return ItemHandlerMode.DISABLED - } else if (input != null && output != null) { + } else if (input != null && output != null || inputOutput != null) { return when (side) { RelativeSide.FRONT, RelativeSide.BACK -> ItemHandlerMode.DISABLED RelativeSide.RIGHT, RelativeSide.TOP -> ItemHandlerMode.INPUT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 60fa7ae59..2fb8ecca8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -118,10 +118,10 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } val energy = WorkerEnergyStorage(this, ENERGY_VALUES) + val energyConfig = ConfigurableEnergy(energy) init { - exposeEnergyGlobally(energy) - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } val matter = MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) @@ -130,25 +130,30 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) init { exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) } // вход, выход - val container = MatteryContainer(this::setChangedLight, 3).also(::addDroppableContainer) + val inputContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val outputContainer = MatteryContainer(::setChangedLight, 2).also(::addDroppableContainer) - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return slot == INPUT_SLOT && MatterManager.canDecompose(stack) - } + val itemConfig = ConfigurableItemHandler( + input = inputContainer.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return MatterManager.canDecompose(stack) + } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return slot != INPUT_SLOT - } - }) + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + }), + + output = outputContainer.handler(HandlerFilter.OnlyOut) + ) init { - exposeItemsGlobally(itemHandler) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::inputContainer) + savetables.stateful(::outputContainer) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -157,7 +162,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) override fun onJobFinish(job: DecomposerJob): Status { if (job.toDust) { - job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) + job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, outputContainer, 0, 1) if (!job.matterValue.isZero) { return Status.FAILURE_WAIT_FAST @@ -176,7 +181,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } override fun computeNextJob(): Pair { - val stack = container[INPUT_SLOT] + val stack = inputContainer[0] if (!stack.isEmpty) { val copy = stack.copy() @@ -218,10 +223,6 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } companion object { - const val INPUT_SLOT = 0 - const val OUTPUT_DUST_MAIN = 1 - const val OUTPUT_DUST_STACKING = 2 - val CAPACITY get() = _CAPACITY.get() val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 9db761ccd..6625247d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -64,18 +64,13 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = MatterStorageImpl( - this::matterLevelUpdated, - FlowDirection.OUTPUT, - ::CAPACITY - ) - - val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) + val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY) + val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) + val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_CONFIG) - private val itemHandler = container.handler(object : HandlerFilter { + val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.item is MatterDustItem } @@ -83,16 +78,17 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { return false } - }) + })) + + val energyConfig = ConfigurableEnergy(energy) init { - exposeItemsGlobally(itemHandler) - exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::energy, ENERGY_KEY) - savetable(::container, INVENTORY_KEY) - savetable(::matter, MATTER_STORAGE_KEY) + + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::container, INVENTORY_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) } override fun setRemoved() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1206dc3aa..c85da2531 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -99,10 +99,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) - val container = MatteryContainer(this::itemContainerUpdated, 5).also(::addDroppableContainer) - val itemHandler = container.handler(HandlerFilter.OnlyOut) + val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES) + val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) + val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) + + val energyConfig = ConfigurableEnergy(energy) + val itemConfig = ConfigurableItemHandler(output = container.handler(HandlerFilter.OnlyOut)) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { @@ -129,14 +131,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } init { - exposeEnergyGlobally(energy) - exposeItemsGlobally(itemHandler) exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::energy, ENERGY_KEY) - savetable(::matter, MATTER_STORAGE_KEY) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::container, INVENTORY_KEY) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 93b068c2d..7936b0ffd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -35,9 +35,10 @@ import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob) { - val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - val itemHandler = container.handler(object : HandlerFilter { + val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) + val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES) + + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return MatterManager.canDecompose(stack) } @@ -45,7 +46,9 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { return isIdling } - }) + })) + + val energyConfig = ConfigurableEnergy(energy) val matterNode = object : MatterNode() { override fun onPatternAdded(state: IPatternState) { @@ -68,12 +71,10 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } init { - exposeItemsGlobally(itemHandler) - exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::container, INVENTORY_KEY) - savetable(::energy, ENERGY_KEY) + savetables.stateful(::container, INVENTORY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } override fun invalidateCaps() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 36c49590d..59230312f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -76,7 +76,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - private val itemHandler = container.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent } + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler { _: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent }) override fun setLevel(level: Level) { super.setLevel(level) @@ -91,9 +91,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : init { exposeGlobally(MatteryCapability.PATTERN, this) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - exposeItemsGlobally(itemHandler) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 212084307..e892a19e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -32,9 +32,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return AndroidStationMenu(containerID, inventory, this) } - val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, - AndroidStationBlockEntity.Companion::CAPACITY, - AndroidStationBlockEntity.Companion::MAX_IO, { null }) { + val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { @@ -59,9 +57,10 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } + val energyConfig = ConfigurableEnergy(energy) + init { - exposeEnergyGlobally(energy) - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } private var tickedOnce = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index 5413f446a..b255cef0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -46,11 +46,13 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma override fun tick() { super.tick() - val capsule = capsuleContainer[0] + if (!redstoneControl.isBlockedByRedstone) { + val capsule = capsuleContainer[0] - if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) { - experienceStored += EssenceCapsuleItem.experienceStored(capsule) - capsuleContainer.clearContent() + if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) { + experienceStored += EssenceCapsuleItem.experienceStored(capsule) + capsuleContainer.clearContent() + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 213dba6a2..217ec4f57 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -25,7 +25,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip") - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index 713119729..e6bd13407 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -41,7 +41,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index ab2c64c78..de53ba607 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -28,7 +28,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 3ca95e957..5a15bdecc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -5,7 +5,6 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode -import ru.dbotthepony.mc.otm.client.screen.panels.EntityRendererPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls @@ -29,7 +28,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent SlotPanel(this, frame, menu.slot, 66f, PROGRESS_SLOT_TOP) ProgressGaugePanel(this, frame, menu.progress, 37f, PROGRESS_ARROW_TOP) - makeDeviceControls(this, frame, redstone = menu.redstoneControl, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) makeCuriosPanel(this, frame, menu.equipment.curiosSlots) PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index beb48e502..cdb8c55ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) @@ -24,7 +24,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 022b961ae..58af3e175 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) @@ -30,7 +30,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index 524284ccc..201f208bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -25,7 +25,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt index e60cf894e..f6ce0456e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt @@ -5,12 +5,13 @@ import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu 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.client.screen.panels.slot.PatternSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = PatternGaugePanel(this, frame, menu.storedThis, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) @@ -22,6 +23,8 @@ class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_ for (i in 4 until 8) PatternSlotPanel(this, frame, menu.storageSlots[i], 62f + (i - 4) * 18, 32f + 18f) + makeDeviceControls(this, frame, itemConfig = menu.itemConfig) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt index ef1e43b1f..e6873d5a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt @@ -275,9 +275,9 @@ fun > makeDeviceControls( screen: S, parent: FramePanel, extra: Iterable> = listOf(), - redstone: IPlayerInputWithFeedback? = null, + redstoneConfig: IPlayerInputWithFeedback? = null, itemConfig: ItemHandlerPlayerInput? = null, energyConfig: EnergyPlayerInput? = null, ): DeviceControls { - return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstone, itemConfig = itemConfig, energyConfig = energyConfig) + return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 8d759e8c3..1b9314e50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -29,7 +29,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 720e7f8c6..c896eb6e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -29,7 +29,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 27c850202..19ea22c86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -29,7 +29,7 @@ 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) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index 5eda45a80..dd113f6e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -67,7 +67,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve } } - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt index 349007b01..d492f5f75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt @@ -727,7 +727,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I this.playerStrip = playerStrip - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index df622243a..3555ddb66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -23,7 +23,7 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co for (i in 6 .. 11) BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) - makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index 64de1b85b..8f9f7562a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -34,7 +34,7 @@ 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, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt index d50eb7f5a..e067b90ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt @@ -20,7 +20,7 @@ class CobblerScreen(menu: CobblerMenu, inventory: Inventory, title: Component) : for (column in 0 .. 2) SlotPanel(this, frame, menu.storageSlots[row * 3 + column], 80f + column * AbstractSlotPanel.SIZE, 26f + row * AbstractSlotPanel.SIZE) - makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index ee5cb47e1..08845d991 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -108,7 +108,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: limitsTab.onClose!!.run() - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index d3a0a114e..c167d665d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -74,7 +74,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp it.dockRight } - makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 6b199f79b..0ca7b3434 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -17,6 +17,7 @@ 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.Label import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.HorizontalStripPanel @@ -246,6 +247,8 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig) + return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 9f9c1382b..45b347412 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -23,7 +23,7 @@ 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, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index d2cb0f0a3..e0658604f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -13,7 +13,10 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.* +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.inventory.InventoryMenu +import net.minecraft.world.inventory.MenuType +import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse @@ -36,8 +39,6 @@ import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec -import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.synchronizer.IField import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket @@ -46,13 +47,14 @@ import ru.dbotthepony.mc.otm.network.SetInventoryFilterPacket import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.IField import java.io.DataInputStream import java.io.DataOutputStream import java.math.BigDecimal import java.util.* import java.util.function.Predicate import java.util.function.Supplier -import kotlin.collections.ArrayList data class PlayerSlot(val functional: A, val cosmetic: B? = null) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 95f99d198..5e924f71f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -6,7 +6,6 @@ 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.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -18,11 +17,11 @@ abstract class MatteryPoweredMenu protected constructor( ) : MatteryMenu(menuType, containerID, inventory, tile) { val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy) val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) - val redstone = EnumInputWithFeedback(this) + val redstoneConfig = EnumInputWithFeedback(this) init { if (tile != null) { - redstone.with(tile.redstoneControl::redstoneSetting) + redstoneConfig.with(tile.redstoneControl::redstoneSetting) } addSlot(batterySlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt index 2a75d9421..a4166cc53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { +class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) private set @@ -59,4 +59,10 @@ class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, v pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } + + init { + if (config != null) { + configure(config) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index 12d721a50..7df8347ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { +class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableItemHandler? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean @@ -48,7 +48,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { for ((f, v) in allowedFlags) { - f.value = v in config.possibleViews + f.boolean = v in config.possibleViews } for ((side, v) in config.pieces) { @@ -62,4 +62,10 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } + + init { + if (config != null) { + configure(config) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 7050d6813..48db6ca77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -9,12 +9,16 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer 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.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterDecomposerMenu @JvmOverloads constructor( @@ -22,27 +26,23 @@ class MatterDecomposerMenu @JvmOverloads constructor( inventory: Inventory, tile: MatterDecomposerBlockEntity? = null ) : MatteryPoweredMenu(MMenus.MATTER_DECOMPOSER, containerID, inventory, tile) { - val input: MatterySlot + val input = object : MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack) + } + val outputMain: MachineOutputSlot val outputStacking: MachineOutputSlot - val progressWidget = ProgressGaugeWidget(this) + val progressWidget = ProgressGaugeWidget(this, tile) val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { - val container = tile?.container ?: SimpleContainer(3) - - // Вход - input = object : MatterySlot(container, 0) { - override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack) - } + val container = tile?.outputContainer ?: SimpleContainer(2) // Выход - outputMain = MachineOutputSlot(container, 1) - outputStacking = MachineOutputSlot(container, 2) - - if (tile != null) { - progressWidget.with(tile::workProgress, tile::isUnableToProcess) - } + outputMain = MachineOutputSlot(container, 0) + outputStacking = MachineOutputSlot(container, 1) addStorageSlot(outputMain) addStorageSlot(outputStacking) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index c57423d91..ac24ea07b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -29,20 +29,13 @@ class MatterReconstructorMenu( val equipment = makeEquipmentSlots(mapMoveToExternal = true) val progress = ProgressGaugeWidget(this) - val redstoneControl = EnumInputWithFeedback(this) - val energyConfig = EnergyPlayerInput(this) - val itemConfig = ItemHandlerPlayerInput(this) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) init { addStorageSlot(slot) addInventorySlots() - if (tile != null) { - redstoneControl.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) - } - if (tile != null) { progress.with(tile::visualProgress, tile::isUnableToProcess) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index 55d216cce..99e5da69f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -3,10 +3,14 @@ package ru.dbotthepony.mc.otm.menu.matter 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.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -22,14 +26,12 @@ class MatterRecyclerMenu @JvmOverloads constructor( } } - val progress = ProgressGaugeWidget(this) + val progress = ProgressGaugeWidget(this, tile) val matter = LevelGaugeWidget(this, tile?.matter) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { - if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) - } - addStorageSlot(input) addInventorySlots() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index f44597064..f0ae25d5a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -6,21 +6,25 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterReplicatorMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterReplicatorBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile -) { +) : MatteryPoweredMenu(MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile) { val matter = LevelGaugeWidget(this, tile?.matter) - val progress = ProgressGaugeWidget(this) + val progress = ProgressGaugeWidget(this, tile) val storageSlots: List + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { val container = tile?.container ?: SimpleContainer(5) @@ -29,10 +33,6 @@ class MatterReplicatorMenu @JvmOverloads constructor( addStorageSlot(MachineOutputSlot(container, it)) } - if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) - } - addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index c8dbf3f0d..1388816c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -11,18 +11,20 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterScannerMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterScannerBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.MATTER_SCANNER, p_38852_, inventory, tile -) { +) : MatteryPoweredMenu(MMenus.MATTER_SCANNER, p_38852_, inventory, tile) { val input: MatterySlot - val progress = ProgressGaugeWidget(this) + val progress = ProgressGaugeWidget(this, tile) val patterns = LevelGaugeWidget(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { val container = tile?.container ?: SimpleContainer(1) @@ -34,7 +36,6 @@ class MatterScannerMenu @JvmOverloads constructor( addStorageSlot(input) if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) patterns.with( { Decimal(tile.matterNode.graph.patternCount) }, { Decimal(tile.matterNode.graph.patternCapacity) }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 6de88f8b0..dfd63e482 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.PatternSlot +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -14,17 +15,15 @@ class PatternStorageMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: PatternStorageBlockEntity? = null -) : MatteryMenu( - MMenus.PATTERN_STORAGE, p_38852_, inventory, tile -) { - val storedThis = LevelGaugeWidget(this) +) : MatteryMenu(MMenus.PATTERN_STORAGE, p_38852_, inventory, tile) { + val storedThis = LevelGaugeWidget(this, tile) val storedGrid = LevelGaugeWidget(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val storageSlots: List init { if (tile != null) { - storedThis.with(tile) storedGrid.with({ Decimal(tile.matterNode.graph.patternCount) }, { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 219bad732..40c50f401 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus import kotlin.reflect.KMutableProperty0 @@ -113,6 +114,7 @@ class AndroidStationMenu @JvmOverloads constructor( } val equipment = makeEquipmentSlots() + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 8cf626104..1b0e57152 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -20,15 +20,13 @@ 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) - val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = true) - val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true) + val redstoneConfig = EnumInputWithFeedback(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPush = true) init { if (tile != null) { - redstone.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) + redstoneConfig.with(tile.redstoneControl::redstoneSetting) } } @@ -64,7 +62,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t addStorageSlot(residueSlot) if (tile != null) { - progress.with { 1f - tile.workTicks.toFloat() / tile.workTicksTotal } + progress.with { if (tile.workTicksTotal == 0) 0f else 1f - tile.workTicks.toFloat() / tile.workTicksTotal } } } 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 a21b60f6a..10c909a28 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 @@ -34,15 +34,13 @@ class EnergyServoMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots(mapMoveToExternal = true) val powerGauge = LevelGaugeWidget(this, tile?.energy) - val itemConfig = ItemHandlerPlayerInput(this) - val energyConfig = EnergyPlayerInput(this, true, true) - val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) + val redstoneConfig = EnumInputWithFeedback(this) init { if (tile != null) { - redstone.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) + redstoneConfig.with(tile.redstoneControl::redstoneSetting) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index f0b88e85a..5b7fe6a2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.server.level.ServerPlayer 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.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.capability.itemsStream import ru.dbotthepony.mc.otm.capability.matteryPlayer @@ -13,6 +14,8 @@ import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.EssenceServoItem 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.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MMenus @@ -21,7 +24,9 @@ class EssenceStorageMenu @JvmOverloads constructor( inventory: Inventory, tile: EssenceStorageBlockEntity? = null ) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) { - val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }) + val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }).property + val redstoneConfig = EnumInputWithFeedback(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { @@ -90,6 +95,10 @@ class EssenceStorageMenu @JvmOverloads constructor( dispenseLevels.filter { (tile?.experienceStored ?: experienceStored) > 0L } + if (tile != null) { + redstoneConfig.with(tile.redstoneControl::redstoneSetting) + } + addStorageSlot(capsuleSlot) addStorageSlot(servoSlot) addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 8893a870c..05c51d69e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -20,20 +20,13 @@ class PlatePressMenu @JvmOverloads constructor( val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } - val progressGauge = ProgressGaugeWidget(this) - - val itemConfig = ItemHandlerPlayerInput(this, allowPush = true) - val energyConfig = EnergyPlayerInput(this, allowPull = true) + val progressGauge = ProgressGaugeWidget(this, tile) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true) init { addStorageSlot(inputSlot) addStorageSlot(outputSlot) addInventorySlots() - - if (tile != null) { - progressGauge.with(tile::workProgress, tile::isUnableToProcess) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 5b6560a2c..7ceb4aa32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.menu.widget -import mekanism.api.functions.FloatSupplier +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.core.FloatSupplier import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.util.function.BooleanSupplier @@ -9,7 +10,7 @@ class ProgressGaugeWidget(menu: MatteryMenu) { var progressSupplier: FloatSupplier = FloatSupplier { 0f } var stuckSupplier: BooleanSupplier = BooleanSupplier { false } - val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.asFloat }) + val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() }) val isStuck by menu.mSynchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }) constructor( @@ -19,6 +20,15 @@ class ProgressGaugeWidget(menu: MatteryMenu) { this.progressSupplier = progress } + constructor( + menu: MatteryMenu, + blockEntity: MatteryWorkerBlockEntity<*>? + ) : this(menu) { + if (blockEntity != null) { + with(blockEntity) + } + } + constructor( menu: MatteryMenu, progress: FloatSupplier, @@ -39,4 +49,9 @@ class ProgressGaugeWidget(menu: MatteryMenu) { this.stuckSupplier = stuck return this } + + fun with(blockEntity: MatteryWorkerBlockEntity<*>): ProgressGaugeWidget { + with(blockEntity::workProgress, blockEntity::isUnableToProcess) + return this + } }