diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 2f178dfb4..efaf4c0c7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -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") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index c450a4a45..ad0fc506c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -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", "Передняя сторона") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index 4e72ceb3a..ae15a5428 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index a34697f1c..3e03f8ed5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -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) = 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]!!) - put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + 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 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 = controls() - val RIGHT_CONTROLS = controls() - val TOP_CONTROLS = controls() - val BOTTOM_CONTROLS = controls() - val FRONT_CONTROLS = controls() - val BACK_CONTROLS = controls() + 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) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index c322ffbc0..a0ca9d7c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -391,6 +391,26 @@ open class EditablePanel @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) { 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 d89dbc847..7db124cc0 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 @@ -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 > makeRedstoneSettingButton( } } +private class PullPushButton, T : Enum>( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + enum: Class, + prop: GetterSetter, + defaultValue: T, + val pullProp: BooleanInputWithFeedback, + val pushProp: BooleanInputWithFeedback +) : LargeEnumRectangleButtonPanel(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>(val pull: Boolean, val push: Boolean, val value: T) + private val sprites = HashMap, 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 > makeItemModeButton(screen: S, parent: FramePanel, input: ItemConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { - 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 > makeItemModeButton(screen: S, parent: FramePa } private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { - 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 > makeEnergyModeButton(screen: S, parent: Frame } private fun > makeFluidModeButton(screen: S, parent: FramePanel, input: FluidConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { - 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 > makeItemHandlerControlPanel( screen: S, inputs: ItemConfigPlayerInput @@ -167,7 +203,6 @@ private fun > 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 > 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 > 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() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 95c511b37..ea34a8d46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -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 { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt index 2abbbbf96..3525c023f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt @@ -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 { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt index aa0afad4e..b7c33511e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt @@ -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 { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt index 3424eb284..8c6216f03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt @@ -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 { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png deleted file mode 100644 index 25899a087..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.xcf deleted file mode 100644 index 06b0bac05..000000000 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.xcf and /dev/null differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index b9553b67f..23f14bebe 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf index 119df61fc..1556edefa 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf differ