Rename item handler/energy config classes

This commit is contained in:
DBotThePony 2023-03-25 20:16:39 +07:00
parent ed04506507
commit 37400a2d5d
Signed by: DBot
GPG Key ID: DCC23B5715498507
16 changed files with 68 additions and 83 deletions

View File

@ -12,9 +12,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.RelativeSide
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import java.util.function.Predicate import java.util.function.Predicate
private fun <S : MatteryScreen<*>> makeRedstoneSettingButton( private fun <S : MatteryScreen<*>> makeRedstoneSettingButton(
@ -41,7 +41,7 @@ private fun <S : MatteryScreen<*>> makeRedstoneSettingButton(
} }
} }
private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePanel<S>, input: ItemHandlerPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, MatteryDeviceBlockEntity.ItemHandlerMode> { private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePanel<S>, input: ItemConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, MatteryDeviceBlockEntity.ItemHandlerMode> {
val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default) val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default)
for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) { for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) {
@ -54,7 +54,7 @@ private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePa
return button return button
} }
private fun <S : MatteryScreen<*>> makeEnergyModeButton(screen: S, parent: FramePanel<S>, input: EnergyPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, FlowDirection> { private fun <S : MatteryScreen<*>> makeEnergyModeButton(screen: S, parent: FramePanel<S>, input: EnergyConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, FlowDirection> {
val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default)
for (v in FlowDirection.values()) { for (v in FlowDirection.values()) {
@ -135,7 +135,7 @@ private fun pullPush(frame: FramePanel<*>, pull: BooleanInputWithFeedback, push:
private fun <S : MatteryScreen<*>> makeItemHandlerControlPanel( private fun <S : MatteryScreen<*>> makeItemHandlerControlPanel(
screen: S, screen: S,
inputs: ItemHandlerPlayerInput inputs: ItemConfigPlayerInput
): FramePanel<S> { ): FramePanel<S> {
val frame = object : FramePanel<S>(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.item_config")) { val frame = object : FramePanel<S>(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.item_config")) {
override fun tickInner() { override fun tickInner() {
@ -164,7 +164,7 @@ private fun <S : MatteryScreen<*>> makeItemHandlerControlPanel(
private fun <S : MatteryScreen<*>> makeEnergyConfigPanel( private fun <S : MatteryScreen<*>> makeEnergyConfigPanel(
screen: S, screen: S,
inputs: EnergyPlayerInput inputs: EnergyConfigPlayerInput
): FramePanel<S> { ): FramePanel<S> {
val frame = object : FramePanel<S>(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.energy_config")) { val frame = object : FramePanel<S>(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.energy_config")) {
override fun tickInner() { override fun tickInner() {
@ -196,8 +196,8 @@ class DeviceControls<out S : MatteryScreen<*>>(
parent: FramePanel<S>, parent: FramePanel<S>,
extra: Iterable<EditablePanel<S>> = listOf(), extra: Iterable<EditablePanel<S>> = listOf(),
val redstoneConfig: IPlayerInputWithFeedback<RedstoneSetting>? = null, val redstoneConfig: IPlayerInputWithFeedback<RedstoneSetting>? = null,
val itemConfig: ItemHandlerPlayerInput? = null, val itemConfig: ItemConfigPlayerInput? = null,
val energyConfig: EnergyPlayerInput? = null, val energyConfig: EnergyConfigPlayerInput? = null,
) : EditablePanel<S>(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) { ) : EditablePanel<S>(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) {
val itemConfigButton: LargeRectangleButtonPanel<S>? val itemConfigButton: LargeRectangleButtonPanel<S>?
val energyConfigButton: LargeRectangleButtonPanel<S>? val energyConfigButton: LargeRectangleButtonPanel<S>?
@ -276,8 +276,8 @@ fun <S : MatteryScreen<*>> makeDeviceControls(
parent: FramePanel<S>, parent: FramePanel<S>,
extra: Iterable<EditablePanel<S>> = listOf(), extra: Iterable<EditablePanel<S>> = listOf(),
redstoneConfig: IPlayerInputWithFeedback<RedstoneSetting>? = null, redstoneConfig: IPlayerInputWithFeedback<RedstoneSetting>? = null,
itemConfig: ItemHandlerPlayerInput? = null, itemConfig: ItemConfigPlayerInput? = null,
energyConfig: EnergyPlayerInput? = null, energyConfig: EnergyConfigPlayerInput? = null,
): DeviceControls<S> { ): DeviceControls<S> {
return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig) return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig)
} }

View File

@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu
/** /**
* [allowPull] and [allowPush] controls whenever player is allowed to change these options * [allowPull] and [allowPush] controls whenever player is allowed to change these options
*/ */
class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) {
var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java)
private set private set
@ -25,7 +25,7 @@ class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.
push.filter { allowPush } push.filter { allowPush }
} }
fun configure(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) {
pull.with(config::automatePull) pull.with(config::automatePull)
push.with(config::automatePush) push.with(config::automatePush)
input.withSupplier { config.energyFlow }.withConsumer { if (parent.possibleModes.isSupertype(it)) config.energyFlow = it } input.withSupplier { config.energyFlow }.withConsumer { if (parent.possibleModes.isSupertype(it)) config.energyFlow = it }
@ -45,11 +45,11 @@ class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.
push.filter { allowPush } push.filter { allowPush }
} }
fun configure(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) {
possibleModes = config.possibleModes possibleModes = config.possibleModes
for ((side, v) in config.pieces) { for ((side, v) in config.pieces) {
pieces[side]!!.configure(v, config) pieces[side]!!.with(v, config)
pieces[side]!!.default = config.defaults[side]!! pieces[side]!!.default = config.defaults[side]!!
} }
@ -62,7 +62,7 @@ class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.
init { init {
if (config != null) { if (config != null) {
configure(config) with(config)
} }
} }
} }

View File

@ -8,12 +8,12 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu
/** /**
* [allowPull] and [allowPush] controls whenever player is allowed to change these options * [allowPull] and [allowPush] controls whenever player is allowed to change these options
*/ */
class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableItemHandler? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { class ItemConfigPlayerInput(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 } private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it }
fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean
inner class Piece(val side: RelativeSide) { inner class Piece(val side: RelativeSide) {
fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = this@ItemHandlerPlayerInput.isAllowed(value) fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = this@ItemConfigPlayerInput.isAllowed(value)
val pull = BooleanInputWithFeedback(menu) val pull = BooleanInputWithFeedback(menu)
val push = BooleanInputWithFeedback(menu) val push = BooleanInputWithFeedback(menu)
@ -26,7 +26,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn
push.filter { allowPush } push.filter { allowPush }
} }
fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) { fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) {
pull.with(config::automatePull) pull.with(config::automatePull)
push.with(config::automatePush) push.with(config::automatePush)
input.withSupplier { config.mode }.withConsumer { if (isAllowed(it)) config.mode = it } input.withSupplier { config.mode }.withConsumer { if (isAllowed(it)) config.mode = it }
@ -46,13 +46,13 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn
push.filter { allowPush } push.filter { allowPush }
} }
fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) {
for ((f, v) in allowedFlags) { for ((f, v) in allowedFlags) {
f.boolean = v in config.possibleViews f.boolean = v in config.possibleViews
} }
for ((side, v) in config.pieces) { for ((side, v) in config.pieces) {
pieces[side]!!.configure(v) pieces[side]!!.with(v)
pieces[side]!!.default = config.defaults[side]!! pieces[side]!!.default = config.defaults[side]!!
} }
@ -65,7 +65,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn
init { init {
if (config != null) { if (config != null) {
configure(config) with(config)
} }
} }
} }

View File

@ -1,24 +1,20 @@
package ru.dbotthepony.mc.otm.menu.matter package ru.dbotthepony.mc.otm.menu.matter
import com.google.common.collect.ImmutableList
import kotlin.jvm.JvmOverloads import kotlin.jvm.JvmOverloads
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import net.minecraft.world.SimpleContainer import net.minecraft.world.SimpleContainer
import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack 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.capability.MatteryCapability
import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.orNull
import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.matter.MatterManager
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
class MatterDecomposerMenu @JvmOverloads constructor( class MatterDecomposerMenu @JvmOverloads constructor(
@ -34,8 +30,8 @@ class MatterDecomposerMenu @JvmOverloads constructor(
val outputStacking: MachineOutputSlot val outputStacking: MachineOutputSlot
val progressWidget = ProgressGaugeWidget(this, tile) val progressWidget = ProgressGaugeWidget(this, tile)
val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull())
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
init { init {
val container = tile?.outputContainer ?: SimpleContainer(2) val container = tile?.outputContainer ?: SimpleContainer(2)

View File

@ -3,13 +3,11 @@ package ru.dbotthepony.mc.otm.menu.matter
import net.minecraft.world.SimpleContainer import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -29,8 +27,8 @@ class MatterReconstructorMenu(
val equipment = makeEquipmentSlots(mapMoveToExternal = true) val equipment = makeEquipmentSlots(mapMoveToExternal = true)
val progress = ProgressGaugeWidget(this) val progress = ProgressGaugeWidget(this)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
init { init {
addStorageSlot(slot) addStorageSlot(slot)

View File

@ -3,14 +3,12 @@ package ru.dbotthepony.mc.otm.menu.matter
import net.minecraft.world.SimpleContainer import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack 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.block.entity.matter.MatterRecyclerBlockEntity
import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.item.MatterDustItem
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -28,8 +26,8 @@ class MatterRecyclerMenu @JvmOverloads constructor(
val progress = ProgressGaugeWidget(this, tile) val progress = ProgressGaugeWidget(this, tile)
val matter = LevelGaugeWidget(this, tile?.matter) val matter = LevelGaugeWidget(this, tile?.matter)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
init { init {
addStorageSlot(input) addStorageSlot(input)

View File

@ -6,13 +6,11 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import net.minecraft.world.SimpleContainer 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.core.immutableList
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
class MatterReplicatorMenu @JvmOverloads constructor( class MatterReplicatorMenu @JvmOverloads constructor(
@ -23,8 +21,8 @@ class MatterReplicatorMenu @JvmOverloads constructor(
val matter = LevelGaugeWidget(this, tile?.matter) val matter = LevelGaugeWidget(this, tile?.matter)
val progress = ProgressGaugeWidget(this, tile) val progress = ProgressGaugeWidget(this, tile)
val storageSlots: List<MachineOutputSlot> val storageSlots: List<MachineOutputSlot>
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
init { init {
val container = tile?.container ?: SimpleContainer(5) val container = tile?.container ?: SimpleContainer(5)

View File

@ -11,8 +11,8 @@ import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.matter.MatterManager
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
class MatterScannerMenu @JvmOverloads constructor( class MatterScannerMenu @JvmOverloads constructor(
@ -23,8 +23,8 @@ class MatterScannerMenu @JvmOverloads constructor(
val input: MatterySlot val input: MatterySlot
val progress = ProgressGaugeWidget(this, tile) val progress = ProgressGaugeWidget(this, tile)
val patterns = LevelGaugeWidget(this) val patterns = LevelGaugeWidget(this)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
init { init {
val container = tile?.container ?: SimpleContainer(1) val container = tile?.container ?: SimpleContainer(1)

View File

@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity
import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.PatternSlot import ru.dbotthepony.mc.otm.menu.PatternSlot
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -18,7 +18,7 @@ class PatternStorageMenu @JvmOverloads constructor(
) : MatteryMenu(MMenus.PATTERN_STORAGE, p_38852_, inventory, tile) { ) : MatteryMenu(MMenus.PATTERN_STORAGE, p_38852_, inventory, tile) {
val storedThis = LevelGaugeWidget(this, tile) val storedThis = LevelGaugeWidget(this, tile)
val storedGrid = LevelGaugeWidget(this) val storedGrid = LevelGaugeWidget(this)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val storageSlots: List<PatternSlot> val storageSlots: List<PatternSlot>

View File

@ -1,21 +1,18 @@
package ru.dbotthepony.mc.otm.menu.tech package ru.dbotthepony.mc.otm.menu.tech
import com.google.common.collect.ImmutableList
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.Container import net.minecraft.world.Container
import net.minecraft.world.SimpleContainer import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.inventory.Slot
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ForgeCapabilities
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer 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.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KMutableProperty0
@ -114,7 +111,7 @@ class AndroidStationMenu @JvmOverloads constructor(
} }
val equipment = makeEquipmentSlots() val equipment = makeEquipmentSlots()
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
init { init {
addInventorySlots() addInventorySlots()

View File

@ -13,9 +13,9 @@ import ru.dbotthepony.mc.otm.core.orNull
import ru.dbotthepony.mc.otm.menu.BatterySlot import ru.dbotthepony.mc.otm.menu.BatterySlot
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
class BatteryBankMenu @JvmOverloads constructor( class BatteryBankMenu @JvmOverloads constructor(
@ -26,14 +26,14 @@ class BatteryBankMenu @JvmOverloads constructor(
val powerLevel: LevelGaugeWidget val powerLevel: LevelGaugeWidget
val storageSlots: List<MatterySlot> val storageSlots: List<MatterySlot>
val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java)
val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true) val energyConfig = EnergyConfigPlayerInput(this, allowPull = false, allowPush = true)
val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = false) val itemConfig = ItemConfigPlayerInput(this, allowPull = false, allowPush = false)
init { init {
if (tile != null) { if (tile != null) {
redstone.with(tile.redstoneControl::redstoneSetting) redstone.with(tile.redstoneControl::redstoneSetting)
energyConfig.configure(tile.energyConfig) energyConfig.with(tile.energyConfig)
itemConfig.configure(tile.itemConfig) itemConfig.with(tile.itemConfig)
} }
val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY) val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY)

View File

@ -10,9 +10,9 @@ import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity
import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.ifPresentK
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -21,8 +21,8 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t
: MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) { : MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) {
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this) val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPush = true) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPush = true)
init { init {
if (tile != null) { if (tile != null) {

View File

@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.core.immutableList
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -19,7 +19,7 @@ class CobblerMenu @JvmOverloads constructor(
) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) {
val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } }
val redstone = EnumInputWithFeedback<RedstoneSetting>(this) val redstone = EnumInputWithFeedback<RedstoneSetting>(this)
val itemConfig = ItemHandlerPlayerInput(this) val itemConfig = ItemConfigPlayerInput(this)
val progress = ProgressGaugeWidget(this) val progress = ProgressGaugeWidget(this)
@ -27,7 +27,7 @@ class CobblerMenu @JvmOverloads constructor(
if (tile != null) { if (tile != null) {
progress.with(tile::workProgress, tile::isUnableToProcess) progress.with(tile::workProgress, tile::isUnableToProcess)
redstone.with(tile.redstoneControl::redstoneSetting) redstone.with(tile.redstoneControl::redstoneSetting)
itemConfig.configure(tile.itemConfig) itemConfig.with(tile.itemConfig)
} }
addInventorySlots() addInventorySlots()

View File

@ -8,9 +8,9 @@ import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity
import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energy
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -34,8 +34,8 @@ class EnergyServoMenu @JvmOverloads constructor(
val equipment = makeEquipmentSlots(mapMoveToExternal = true) val equipment = makeEquipmentSlots(mapMoveToExternal = true)
val powerGauge = LevelGaugeWidget(this, tile?.energy) val powerGauge = LevelGaugeWidget(this, tile?.energy)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true)
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this) val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
init { init {

View File

@ -6,16 +6,14 @@ import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity
import ru.dbotthepony.mc.otm.capability.itemsStream
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.core.util.LongValueCodec
import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem
import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.item.EssenceServoItem
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -26,7 +24,7 @@ class EssenceStorageMenu @JvmOverloads constructor(
) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) { ) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) {
val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }).property val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }).property
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this) val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig)
val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) { val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) {
override fun mayPlace(itemStack: ItemStack): Boolean { override fun mayPlace(itemStack: ItemStack): Boolean {

View File

@ -7,8 +7,8 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MachineOutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MMenus
@ -21,8 +21,8 @@ class PlatePressMenu @JvmOverloads constructor(
val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) }
val progressGauge = ProgressGaugeWidget(this, tile) val progressGauge = ProgressGaugeWidget(this, tile)
val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
init { init {
addStorageSlot(inputSlot) addStorageSlot(inputSlot)