Pull and push modes now can be independently configured

This commit is contained in:
DBotThePony 2023-06-20 20:36:33 +07:00
parent e83121c77a
commit ab61101ab6
Signed by: DBot
GPG Key ID: DCC23B5715498507
14 changed files with 203 additions and 156 deletions

View File

@ -661,6 +661,9 @@ private fun gui(provider: MatteryLanguageProvider) {
gui("sides.energy_config", "Energy Configuration")
gui("sides.fluid_config", "Fluid Configuration")
gui("sides.pull_help", "Hold Shift to cycle pull mode")
gui("sides.push_help", "Hold Ctrl to cycle push mode")
gui("sides.top", "Top")
gui("sides.bottom", "Bottom")
gui("sides.front", "Front")

View File

@ -666,6 +666,9 @@ private fun gui(provider: MatteryLanguageProvider) {
gui("sides.energy_config", "Настройка энергии")
gui("sides.fluid_config", "Настройка жидкости")
gui("sides.pull_help", "Удерживайте Shift для настройки режима забора")
gui("sides.push_help", "Удерживайте Ctrl для настройки режима выталкивания")
gui("sides.top", "Верхняя сторона")
gui("sides.bottom", "Нижняя сторона")
gui("sides.front", "Передняя сторона")

View File

@ -68,14 +68,14 @@ enum class FlowDirection(val input: Boolean, val output: Boolean, val translatio
get() = TranslatableComponent(translationKey)
/**
* Subtype test (returns true if we can assign [t] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT])
* Subtype test (returns true if we can assign [t] to this, for example if we can assign [BI_DIRECTIONAL] to [INPUT])
*/
override fun test(t: FlowDirection): Boolean {
return t === this || (!input || t.input) && (!output || t.output)
}
/**
* Subtype test (returns true if we can assign [value] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT])
* Subtype test (returns true if we can assign [value] to this, for example if we can assign [BI_DIRECTIONAL] to [INPUT])
*/
fun isSubtype(value: FlowDirection) = test(value)

View File

@ -59,40 +59,99 @@ object Widgets18 {
val PATTERN_SLOT_BACKGROUND = slotBgGrid.next()
val MATTER_CAPACITOR_SLOT_BACKGROUND = slotBgGrid.next()
private val redstoneGrid = WidgetLocation.REDSTONE_CONTROLS.grid(rows = 1, columns = 3)
private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 7, columns = 9)
val REDSTONE_IGNORED = redstoneGrid.next()
val REDSTONE_LOW = redstoneGrid.next()
val REDSTONE_HIGH = redstoneGrid.next()
val BATTERY_ONLY = controlsGrid.next()
val ITEMS_CONFIGURATION = controlsGrid.next()
val ENERGY_CONFIGURATION = controlsGrid.next()
val FLUID_CONFIGURATION = controlsGrid.next()
private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 8)
val REDSTONE_IGNORED = controlsGrid.next()
val REDSTONE_LOW = controlsGrid.next()
val REDSTONE_HIGH = controlsGrid.next()
val PULL = controlsGrid.next()
val PUSH = controlsGrid.next()
val PULL_DISABLED = controlsGrid.next()
val PUSH_DISABLED = controlsGrid.next()
private fun controls() = immutableMap {
put(FlowDirection.NONE, controlsGrid.next())
put(FlowDirection.INPUT, controlsGrid.next())
put(FlowDirection.OUTPUT, controlsGrid.next())
put(FlowDirection.BI_DIRECTIONAL, controlsGrid.next())
init {
controlsGrid.jump()
}
private fun controls2(input: Map<FlowDirection, MatterySprite>) = immutableMap {
put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, input[FlowDirection.NONE]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input[FlowDirection.INPUT]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, input[FlowDirection.OUTPUT]!!)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, input[FlowDirection.BI_DIRECTIONAL]!!)
class SideControls {
val disabled = controlsGrid.next()
val input = controlsGrid.next()
val pull = controlsGrid.next()
val output = controlsGrid.next()
val push = controlsGrid.next()
val inputOutput = controlsGrid.next()
val pullOutput = controlsGrid.next()
val inputPush = controlsGrid.next()
val pullPush = controlsGrid.next()
val flow = immutableMap {
put(FlowDirection.NONE, disabled)
put(FlowDirection.INPUT, input)
put(FlowDirection.OUTPUT, output)
put(FlowDirection.BI_DIRECTIONAL, inputOutput)
}
val flowPush = immutableMap {
put(FlowDirection.NONE, disabled)
put(FlowDirection.INPUT, input)
put(FlowDirection.OUTPUT, push)
put(FlowDirection.BI_DIRECTIONAL, inputPush)
}
val flowPull = immutableMap {
put(FlowDirection.NONE, disabled)
put(FlowDirection.INPUT, pull)
put(FlowDirection.OUTPUT, output)
put(FlowDirection.BI_DIRECTIONAL, pullOutput)
}
val flowPullPush = immutableMap {
put(FlowDirection.NONE, disabled)
put(FlowDirection.INPUT, pull)
put(FlowDirection.OUTPUT, push)
put(FlowDirection.BI_DIRECTIONAL, pullPush)
}
val items = immutableMap {
put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input)
put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, output)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, inputOutput)
put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY)
}
val LEFT_CONTROLS = controls()
val RIGHT_CONTROLS = controls()
val TOP_CONTROLS = controls()
val BOTTOM_CONTROLS = controls()
val FRONT_CONTROLS = controls()
val BACK_CONTROLS = controls()
val itemsPush = immutableMap {
put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input)
put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, push)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, inputPush)
put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY)
}
val itemsPull = immutableMap {
put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, pull)
put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, output)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, pullOutput)
put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY)
}
val itemsPullPush = immutableMap {
put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, pull)
put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, push)
put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, pullPush)
put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY)
}
}
val LEFT_CONTROLS = SideControls()
val RIGHT_CONTROLS = SideControls()
val TOP_CONTROLS = SideControls()
val BOTTOM_CONTROLS = SideControls()
val FRONT_CONTROLS = SideControls()
val BACK_CONTROLS = SideControls()
val CONTROLS = immutableMap {
put(RelativeSide.BOTTOM, BOTTOM_CONTROLS)
@ -102,25 +161,4 @@ object Widgets18 {
put(RelativeSide.FRONT, FRONT_CONTROLS)
put(RelativeSide.BACK, BACK_CONTROLS)
}
val BATTERY_ONLY = controlsGrid.next()
val ITEMS_CONFIGURATION = controlsGrid.next()
val ENERGY_CONFIGURATION = controlsGrid.next()
val FLUID_CONFIGURATION = controlsGrid.next()
val LEFT_CONTROLS_ITEMS = controls2(LEFT_CONTROLS)
val RIGHT_CONTROLS_ITEMS = controls2(RIGHT_CONTROLS)
val TOP_CONTROLS_ITEMS = controls2(TOP_CONTROLS)
val BOTTOM_CONTROLS_ITEMS = controls2(BOTTOM_CONTROLS)
val FRONT_CONTROLS_ITEMS = controls2(FRONT_CONTROLS)
val BACK_CONTROLS_ITEMS = controls2(BACK_CONTROLS)
val ITEMS_CONTROLS = immutableMap {
put(RelativeSide.BOTTOM, BOTTOM_CONTROLS_ITEMS)
put(RelativeSide.TOP, TOP_CONTROLS_ITEMS)
put(RelativeSide.LEFT, LEFT_CONTROLS_ITEMS)
put(RelativeSide.RIGHT, RIGHT_CONTROLS_ITEMS)
put(RelativeSide.FRONT, FRONT_CONTROLS_ITEMS)
put(RelativeSide.BACK, BACK_CONTROLS_ITEMS)
}
}

View File

@ -391,6 +391,26 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
field = value
}
fun prependTooltip(text: Component) {
if (tooltip == null && tooltipList == null) {
tooltip = text
} else if (tooltip != null) {
tooltipList = listOf(text, tooltip!!)
} else {
tooltipList = tooltipList!!.toMutableList().also { it.add(0, text) }
}
}
fun appendTooltip(text: Component) {
if (tooltip == null && tooltipList == null) {
tooltip = text
} else if (tooltip != null) {
tooltipList = listOf(text, tooltip!!)
} else {
tooltipList = tooltipList!!.toMutableList().also { it.add(text) }
}
}
var blockingWindow: EditablePanel<*>? = null
get() {
if (field?.isRemoved != true) {

View File

@ -1,14 +1,20 @@
package ru.dbotthepony.mc.otm.client.screen.panels.button
import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.client.isCtrlDown
import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.core.GetterSetter
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.math.RelativeSide
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
@ -42,11 +48,64 @@ private fun <S : MatteryScreen<*>> makeRedstoneSettingButton(
}
}
private class PullPushButton<out S : MatteryScreen<*>, T : Enum<T>>(
screen: S,
parent: EditablePanel<*>?,
x: Float = 0f,
y: Float = 0f,
enum: Class<T>,
prop: GetterSetter<T>,
defaultValue: T,
val pullProp: BooleanInputWithFeedback,
val pushProp: BooleanInputWithFeedback
) : LargeEnumRectangleButtonPanel<S, T>(screen, parent, x = x, y = y, enum = enum, prop = prop, defaultValue = defaultValue) {
init {
if (pullProp.test(minecraft.player) && pushProp.test(minecraft.player)) {
tooltipList = listOf(TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY), TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY))
} else if (pullProp.test(minecraft.player)) {
tooltip = TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY)
} else if (pushProp.test(minecraft.player)) {
tooltip = TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY)
}
}
data class State<T : Enum<T>>(val pull: Boolean, val push: Boolean, val value: T)
private val sprites = HashMap<State<T>, AbstractMatterySprite>()
fun addSprite(pull: Boolean, push: Boolean, value: T, sprite: AbstractMatterySprite) {
sprites[State(pull, push, value)] = sprite
}
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
super.innerRender(graphics, mouseX, mouseY, partialTick)
sprites[State(pullProp.value, pushProp.value, prop.get())]?.render(graphics, 0f, 0f, width, height)
}
override fun onClick(mouseButton: Int) {
if (mouseButton != InputConstants.MOUSE_BUTTON_MIDDLE && minecraft.window.isShiftDown) {
if (pullProp.test(minecraft.player)) {
pullProp.switchValue()
}
} else if (mouseButton != InputConstants.MOUSE_BUTTON_MIDDLE && minecraft.window.isCtrlDown) {
if (pushProp.test(minecraft.player)) {
pushProp.switchValue()
}
} else {
super.onClick(mouseButton)
}
}
}
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 = PullPushButton(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default, pullProp = input.pull, pushProp = input.push)
val widgets = Widgets18.CONTROLS[side]!!
for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) {
button.add(v, skinElement = Widgets18.ITEMS_CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey))
button.add(v, tooltip = TranslatableComponent(v.translationKey))
button.addSprite(false, false, v, widgets.items[v]!!)
button.addSprite(true, false, v, widgets.itemsPull[v]!!)
button.addSprite(false, true, v, widgets.itemsPush[v]!!)
button.addSprite(true, true, v, widgets.itemsPullPush[v]!!)
}
button.finish()
@ -56,10 +115,15 @@ private fun <S : MatteryScreen<*>> makeItemModeButton(screen: S, parent: FramePa
}
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 = PullPushButton(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default, pullProp = input.pull, pushProp = input.push)
val widgets = Widgets18.CONTROLS[side]!!
for (v in FlowDirection.values()) {
button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey))
button.add(v, tooltip = TranslatableComponent(v.translationKey))
button.addSprite(false, false, v, widgets.flow[v]!!)
button.addSprite(true, false, v, widgets.flowPull[v]!!)
button.addSprite(false, true, v, widgets.flowPush[v]!!)
button.addSprite(true, true, v, widgets.flowPullPush[v]!!)
}
button.finish()
@ -68,10 +132,15 @@ private fun <S : MatteryScreen<*>> makeEnergyModeButton(screen: S, parent: Frame
}
private fun <S : MatteryScreen<*>> makeFluidModeButton(screen: S, parent: FramePanel<S>, input: FluidConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel<S, FlowDirection> {
val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default)
val button = PullPushButton(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default, pullProp = input.pull, pushProp = input.push)
val widgets = Widgets18.CONTROLS[side]!!
for (v in FlowDirection.values()) {
button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey))
button.add(v, tooltip = TranslatableComponent(v.translationKey))
button.addSprite(false, false, v, widgets.flow[v]!!)
button.addSprite(true, false, v, widgets.flowPull[v]!!)
button.addSprite(false, true, v, widgets.flowPush[v]!!)
button.addSprite(true, true, v, widgets.flowPullPush[v]!!)
}
button.finish()
@ -87,12 +156,12 @@ private fun moveButtons(
top: EditablePanel<*>,
bottom: EditablePanel<*>,
) {
top.tooltip = TranslatableComponent("otm.gui.sides.top")
bottom.tooltip = TranslatableComponent("otm.gui.sides.bottom")
back.tooltip = TranslatableComponent("otm.gui.sides.back")
front.tooltip = TranslatableComponent("otm.gui.sides.front")
left.tooltip = TranslatableComponent("otm.gui.sides.left")
right.tooltip = TranslatableComponent("otm.gui.sides.right")
top.prependTooltip(TranslatableComponent("otm.gui.sides.top"))
bottom.prependTooltip(TranslatableComponent("otm.gui.sides.bottom"))
back.prependTooltip(TranslatableComponent("otm.gui.sides.back"))
front.prependTooltip(TranslatableComponent("otm.gui.sides.front"))
left.prependTooltip(TranslatableComponent("otm.gui.sides.left"))
right.prependTooltip(TranslatableComponent("otm.gui.sides.right"))
top.x = 30f
top.y = 14f
@ -113,39 +182,6 @@ private fun moveButtons(
back.y = 14f + 42f
}
@Suppress("name_shadowing")
private fun pullPush(frame: FramePanel<*>, pull: BooleanInputWithFeedback, push: BooleanInputWithFeedback) {
if (pull.test(minecraft.player)) {
val pull = LargeBooleanRectangleButtonPanel(
frame.screen,
frame,
skinElementActive = Widgets18.PULL,
skinElementInactive = Widgets18.PULL_DISABLED,
prop = pull,
)
pull.tooltip = TranslatableComponent("otm.gui.side_mode.pull")
pull.x = 30f - 20f
pull.y = 14f
}
if (push.test(minecraft.player)) {
val push = LargeBooleanRectangleButtonPanel(
frame.screen,
frame,
skinElementActive = Widgets18.PUSH,
skinElementInactive = Widgets18.PUSH_DISABLED,
prop = push,
)
push.tooltip = TranslatableComponent("otm.gui.side_mode.push")
push.x = 30f + 20f
push.y = 14f
}
}
private fun <S : MatteryScreen<*>> makeItemHandlerControlPanel(
screen: S,
inputs: ItemConfigPlayerInput
@ -167,7 +203,6 @@ private fun <S : MatteryScreen<*>> makeItemHandlerControlPanel(
val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP)
val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM)
pullPush(frame, inputs.pull, inputs.push)
moveButtons(front, back, left, right, top, bottom)
screen.addPanel(frame)
frame.requestFocus()
@ -196,7 +231,6 @@ private fun <S : MatteryScreen<*>> makeEnergyConfigPanel(
val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
pullPush(frame, inputs.pull, inputs.push)
moveButtons(front, back, left, right, top, bottom)
screen.addPanel(frame)
frame.requestFocus()
@ -225,7 +259,6 @@ private fun <S : MatteryScreen<*>> makeFluidConfigPanel(
val top = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
val bottom = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } }
pullPush(frame, inputs.pull, inputs.push)
moveButtons(front, back, left, right, top, bottom)
screen.addPanel(frame)
frame.requestFocus()

View File

@ -1686,7 +1686,7 @@ object MatterManager {
fun onServerStarted(event: ServerStartedEvent) {
check(Resolver.ready) { "Recipe resolver is not ready somehow" }
check(Registry.ready) { "Matter registry is not ready somehow" }
finishUpIfRequiredAndPossible(event.server ?: throw NullPointerException("what."))
finishUpIfRequiredAndPossible(event.server)
}
fun get(value: Item): IMatterValue {

View File

@ -21,8 +21,8 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE
var default by menu.mSynchronizer.enum(FlowDirection.NONE)
init {
pull.filter { allowPull }
push.filter { allowPush }
pull.filter { allowPull && possibleModes.isSupertype(FlowDirection.INPUT) }
push.filter { allowPush && possibleModes.isSupertype(FlowDirection.OUTPUT) }
}
fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) {
@ -34,17 +34,6 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE
val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) }
// TODO
val pull = BooleanInputWithFeedback(menu)
// TODO
val push = BooleanInputWithFeedback(menu)
init {
pull.filter { allowPull }
push.filter { allowPush }
}
fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) {
possibleModes = config.possibleModes
@ -52,12 +41,6 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE
pieces[side]!!.with(v, config)
pieces[side]!!.default = config.defaults[side]!!
}
pull.withSupplier { pieces.values.all { it.pull.value } }
push.withSupplier { pieces.values.all { it.push.value } }
pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } }
push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } }
}
init {

View File

@ -21,8 +21,8 @@ class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn
var default by menu.mSynchronizer.enum(FlowDirection.NONE)
init {
pull.filter { allowPull }
push.filter { allowPush }
pull.filter { allowPull && possibleModes.isSupertype(FlowDirection.INPUT) }
push.filter { allowPush && possibleModes.isSupertype(FlowDirection.OUTPUT) }
}
fun with(config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>) {
@ -34,17 +34,6 @@ class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn
val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) }
// TODO
val pull = BooleanInputWithFeedback(menu)
// TODO
val push = BooleanInputWithFeedback(menu)
init {
pull.filter { allowPull }
push.filter { allowPush }
}
fun with(config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>) {
possibleModes = config.possibleModes
@ -52,12 +41,6 @@ class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn
pieces[side]!!.with(v, config)
pieces[side]!!.default = config.defaults[side]!!
}
pull.withSupplier { pieces.values.all { it.pull.value } }
push.withSupplier { pieces.values.all { it.push.value } }
pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } }
push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } }
}
init {

View File

@ -1,6 +1,7 @@
package ru.dbotthepony.mc.otm.menu.input
import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.core.immutableMap
import ru.dbotthepony.mc.otm.core.math.RelativeSide
import ru.dbotthepony.mc.otm.menu.MatteryMenu
@ -22,8 +23,8 @@ class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEnt
var default by menu.mSynchronizer.enum(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED)
init {
pull.filter { allowPull }
push.filter { allowPush }
pull.filter { allowPull && isAllowed(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT) }
push.filter { allowPush && isAllowed(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT) }
}
fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) {
@ -35,17 +36,6 @@ class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEnt
val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) }
// TODO
val pull = BooleanInputWithFeedback(menu)
// TODO
val push = BooleanInputWithFeedback(menu)
init {
pull.filter { allowPull }
push.filter { allowPush }
}
fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) {
for ((f, v) in allowedFlags) {
f.boolean = v in config.possibleViews
@ -55,12 +45,6 @@ class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEnt
pieces[side]!!.with(v)
pieces[side]!!.default = config.defaults[side]!!
}
pull.withSupplier { pieces.values.all { it.pull.value } }
push.withSupplier { pieces.values.all { it.push.value } }
pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } }
push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } }
}
init {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB