Common menu base for processing machines

This commit is contained in:
DBotThePony 2024-01-12 21:00:48 +07:00
parent 71f13f70bf
commit c07120a1cb
Signed by: DBot
GPG Key ID: DCC23B5715498507
13 changed files with 220 additions and 216 deletions

View File

@ -23,7 +23,6 @@ import ru.dbotthepony.mc.otm.container.balance
import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.collect.maybe
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.registry.MRecipes
@ -55,10 +54,7 @@ class PlatePressBlockEntity(
}
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
if (isTwin)
return TwinPlatePressMenu(containerID, inventory, this)
else
return PlatePressMenu(containerID, inventory, this)
return if (isTwin) PlatePressMenu.twin(containerID, inventory, this) else PlatePressMenu.single(containerID, inventory, this)
}
override fun onJobFinish(status: JobStatus<ItemJob>, id: Int) {

View File

@ -233,6 +233,12 @@ open class EditablePanel<out S : Screen>(
parent?.boundsInvalidated = true
}
val effectiveWidth: Float
get() = width - dockPadding.horizontal
val effectiveHeight: Float
get() = height - dockPadding.vertical
/**
* Width of this panel as considered by docking code, updated inside [performLayout]
*
@ -1147,7 +1153,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeHeight)
child.height = child.dockedHeight
else if (child.height != child.dockedHeight)
child.y += child.dockedHeight / 2f - child.height / 2f
child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat()
}
Dock.RIGHT -> {
@ -1161,7 +1167,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeHeight)
child.height = child.dockedHeight
else if (child.height != child.dockedHeight)
child.y += child.dockedHeight / 2f - child.height / 2f
child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat()
}
Dock.TOP -> {
@ -1175,7 +1181,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeWidth)
child.width = child.dockedWidth
else if (child.width != child.dockedWidth)
child.x += child.dockedWidth / 2f - child.width / 2f
child.x += (child.dockedWidth / 2f - child.width / 2f).roundToInt().toFloat()
}
Dock.BOTTOM -> {
@ -1189,7 +1195,7 @@ open class EditablePanel<out S : Screen>(
if (child.dockResize.changeWidth)
child.width = child.dockedWidth
else if (child.width != child.dockedWidth)
child.x += child.dockedWidth / 2f - child.width / 2f
child.x += (child.dockedWidth / 2f - child.width / 2f).roundToInt().toFloat()
}
}
}

View File

@ -19,8 +19,17 @@ open class BackgroundPanel<out S : Screen>(
dockPadding = DockProperty(3f, 3f, 3f, 3f)
}
var drawBackground = true
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
RECTANGLE.render(graphics, width = width, height = height)
if (drawBackground) {
RECTANGLE.render(graphics, width = width, height = height)
}
}
fun removeBackground() {
dockPadding = DockProperty.EMPTY
drawBackground = false
}
companion object {

View File

@ -0,0 +1,83 @@
package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode
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.ScrollbarBackgroundPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded
import ru.dbotthepony.mc.otm.menu.tech.AbstractProcessingMachineMenu
import kotlin.math.roundToInt
open class AbstractProcessingMachineScreen<M : AbstractProcessingMachineMenu>(menu: M, inventory: Inventory, title: Component) : MatteryScreen<M>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
val frame = super.makeMainFrame()!!
WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
val height = menu.processingTuples.size * (AbstractSlotPanel.SIZE + 2f) - 2f
val progressPanels = ArrayList<ProgressGaugePanel<*>>()
val parentTarget = if (height >= frame.effectiveHeight - 10f) {
val parent = ScrollbarBackgroundPanel(this, frame)
parent.removeBackground()
parent.dock = Dock.FILL
parent.dockLeft = 50f
parent.dockRight = 4f
parent.canvas
} else {
val parent = EditablePanel(this, frame)
parent.dock = Dock.FILL
frame.performLayout()
parent.dockPaddingTop = ((parent.effectiveHeight - height) / 2f).roundToInt().toFloat()
parent.dockLeft = 50f
parent
}
for ((input, output, progress) in menu.processingTuples) {
val row = EditablePanel(this, parentTarget, height = AbstractSlotPanel.SIZE)
row.dock = Dock.TOP
row.dockBottom = 2f
SlotPanel(this, row, input).also {
it.dock = Dock.LEFT
}
progressPanels.add(ProgressGaugePanel(this, row, progress).also {
it.dock = Dock.LEFT
it.dockLeft = 4f
it.dockRight = 4f
it.dockResize = DockResizeMode.NONE
})
SlotPanel(this, row, output).also {
it.dock = Dock.LEFT
}
}
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades)
if (isJeiLoaded) {
val recipeTypes = menu.recipeTypes
if (recipeTypes != null) {
progressPanels.forEach {
it.setRecipeType(recipeTypes)
}
}
}
return frame
}
}

View File

@ -1,31 +0,0 @@
package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) :
MatteryScreen<PlatePressMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
val frame = super.makeMainFrame()!!
WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP)
ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) }
SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP)
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, upgrades = menu.upgrades)
return frame
}
}

View File

@ -1,54 +0,0 @@
package ru.dbotthepony.mc.otm.client.screen.tech
import mezz.jei.api.constants.RecipeTypes
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.compat.jei.MicrowaveRecipeCategory
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
import ru.dbotthepony.mc.otm.registry.MMenus
class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) :
MatteryScreen<PoweredFurnaceMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
val frame = super.makeMainFrame()!!
WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f)
val a = ProgressGaugePanel(this, frame, menu.progressGauge[0], 78f, PROGRESS_ARROW_TOP - 10f)
SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f)
SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f)
val b = ProgressGaugePanel(this, frame, menu.progressGauge[1], 78f, PROGRESS_ARROW_TOP + 10f)
SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f)
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades)
when (menu.type) {
MMenus.POWERED_FURNACE -> {
a.setRecipeType { listOf(RecipeTypes.SMELTING) }
b.setRecipeType { listOf(RecipeTypes.SMELTING) }
}
MMenus.POWERED_BLAST_FURNACE -> {
a.setRecipeType { listOf(RecipeTypes.BLASTING) }
b.setRecipeType { listOf(RecipeTypes.BLASTING) }
}
MMenus.POWERED_SMOKER -> {
a.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) }
b.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) }
}
}
return frame
}
}

View File

@ -1,35 +0,0 @@
package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title: Component) :
MatteryScreen<TwinPlatePressMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
val frame = super.makeMainFrame()!!
WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f)
ProgressGaugePanel(this, frame, menu.progressGauge0, 78f, PROGRESS_ARROW_TOP - 10f).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) }
SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f)
SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f)
ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) }
SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f)
makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades)
return frame
}
}

View File

@ -7,7 +7,6 @@ import mezz.jei.api.constants.VanillaTypes
import mezz.jei.api.forge.ForgeTypes
import mezz.jei.api.gui.handlers.IGuiContainerHandler
import mezz.jei.api.helpers.IJeiHelpers
import mezz.jei.api.ingredients.ITypedIngredient
import mezz.jei.api.registration.IGuiHandlerRegistration
import mezz.jei.api.registration.IRecipeCatalystRegistration
import mezz.jei.api.registration.IRecipeCategoryRegistration
@ -18,7 +17,6 @@ import mezz.jei.api.runtime.IJeiRuntime
import net.minecraft.client.renderer.Rect2i
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack
import net.minecraftforge.fluids.FluidStack
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
@ -28,12 +26,10 @@ import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.collect.filterIsInstance
import ru.dbotthepony.mc.otm.core.collect.map
import ru.dbotthepony.mc.otm.core.collect.toList
import ru.dbotthepony.mc.otm.core.filterNotNull
import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu
import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
import ru.dbotthepony.mc.otm.recipe.PainterRecipe
import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MRecipes
@ -112,8 +108,7 @@ class JEIPlugin : IModPlugin {
registration.addRecipeTransferHandler(ExopackInventoryTransferHandler(helper), RecipeTypes.CRAFTING)
registration.addRecipeTransferHandler(simpleTransferInfo(MatterEntanglerRecipeCategory.recipeType, MatterEntanglerMenu::inputs))
registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot))
registration.addRecipeTransferHandler(simpleTransferInfo0(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlot))
registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, TwinPlatePressMenu::inputSlots))
registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlots))
registration.addRecipeTransferHandler(simpleTransferInfo(MicrowaveRecipeCategory.recipeType, PoweredFurnaceMenu::inputSlots))
}

View File

@ -0,0 +1,43 @@
package ru.dbotthepony.mc.otm.menu.tech
import mezz.jei.api.recipe.RecipeType
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.MenuType
import net.minecraft.world.inventory.Slot
import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.UpgradeSlots
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import java.util.function.Supplier
abstract class AbstractProcessingMachineMenu(
type: MenuType<*>,
containerID: Int,
inventory: Inventory,
tile: MatteryPoweredBlockEntity? = null
) : MatteryPoweredMenu(type, containerID, inventory, tile) {
data class ProcessingTuple(
val input: Slot,
val output: Slot,
val progress: ProgressGaugeWidget
)
abstract val processingTuples: List<ProcessingTuple>
abstract val itemConfig: ItemConfigPlayerInput?
abstract val energyConfig: EnergyConfigPlayerInput?
abstract val profiledEnergy: ProfiledLevelGaugeWidget<*>
abstract val balanceInputs: BooleanInputWithFeedback?
abstract val upgrades: UpgradeSlots?
open val recipeTypes: Supplier<List<RecipeType<*>>>?
get() = null
init {
addInventorySlots()
}
}

View File

@ -1,36 +1,64 @@
package ru.dbotthepony.mc.otm.menu.tech
import mezz.jei.api.recipe.RecipeType
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.MenuType
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory
import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded
import ru.dbotthepony.mc.otm.core.immutableList
import ru.dbotthepony.mc.otm.menu.OutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.makeSlots
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus
import java.util.function.Supplier
class PlatePressMenu(
type: MenuType<*>,
containerID: Int,
inventory: Inventory,
tile: PlatePressBlockEntity? = null
) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) {
val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0)
val outputSlot = OutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.experience?.popExperience(player as ServerPlayer) }
tile: PlatePressBlockEntity? = null,
isTwin: Boolean
) : AbstractProcessingMachineMenu(type, containerID, inventory, tile) {
val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(if (isTwin) 2 else 1), ::MatterySlot)
val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(if (isTwin) 2 else 1)) { a, b -> OutputSlot(a, b) { tile?.experience?.popExperience(player as ServerPlayer) } }
val gauges = immutableList(if (isTwin) 2 else 1) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) }
val progressGauge = ProgressGaugeWidget(this, tile)
val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
override val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
override val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
override val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
val upgrades = makeUpgradeSlots(3, tile?.upgrades)
override val balanceInputs = if (isTwin) BooleanInputWithFeedback(this) else null
override val upgrades = makeUpgradeSlots(if (isTwin) 4 else 3, tile?.upgrades)
override val processingTuples: List<ProcessingTuple> = immutableList(if (isTwin) 2 else 1) {
ProcessingTuple(inputSlots[it], outputSlots[it], gauges[it])
}
override val recipeTypes: Supplier<List<RecipeType<*>>>
get() = Supplier { listOf(PlatePressRecipeCategory.recipeType) }
init {
addStorageSlot(inputSlot)
addStorageSlot(outputSlot)
addInventorySlots()
if (tile != null) balanceInputs?.with(tile::balanceInputs)
addStorageSlot(inputSlots)
addStorageSlot(outputSlots)
}
companion object {
fun single(containerID: Int, inventory: Inventory, tile: PlatePressBlockEntity? = null): PlatePressMenu {
return PlatePressMenu(MMenus.PLATE_PRESS, containerID, inventory, tile, false)
}
fun twin(containerID: Int, inventory: Inventory, tile: PlatePressBlockEntity? = null): PlatePressMenu {
return PlatePressMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile, true)
}
}
}

View File

@ -1,5 +1,7 @@
package ru.dbotthepony.mc.otm.menu.tech
import mezz.jei.api.constants.RecipeTypes
import mezz.jei.api.recipe.RecipeType
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.MenuType
@ -7,6 +9,8 @@ import ru.dbotthepony.mc.otm.block.entity.tech.AbstractPoweredFurnaceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.PoweredBlastFurnaceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity
import ru.dbotthepony.mc.otm.block.entity.tech.PoweredSmokerBlockEntity
import ru.dbotthepony.mc.otm.compat.jei.MicrowaveRecipeCategory
import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded
import ru.dbotthepony.mc.otm.core.immutableList
import ru.dbotthepony.mc.otm.menu.OutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
@ -18,30 +22,42 @@ import ru.dbotthepony.mc.otm.menu.makeSlots
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus
import java.util.function.Supplier
class PoweredFurnaceMenu(
type: MenuType<PoweredFurnaceMenu>,
containerID: Int,
inventory: Inventory,
tile: AbstractPoweredFurnaceBlockEntity<*, *>? = null
) : MatteryPoweredMenu(type, containerID, inventory, tile) {
) : AbstractProcessingMachineMenu(type, containerID, inventory, tile) {
val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot)
val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.experience?.popExperience(player as ServerPlayer) } }
val progressGauge = immutableList(2) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) }
val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
val balanceInputs = BooleanInputWithFeedback(this)
override val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
override val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
override val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
override val balanceInputs = BooleanInputWithFeedback(this)
override val upgrades = makeUpgradeSlots(2, tile?.upgrades)
val upgrades = makeUpgradeSlots(2, tile?.upgrades)
override val processingTuples: List<ProcessingTuple> = immutableList(2) {
ProcessingTuple(inputSlots[it], outputSlots[it], progressGauge[it])
}
override val recipeTypes: Supplier<List<RecipeType<*>>>?
get() {
return when (type) {
MMenus.POWERED_FURNACE -> Supplier { listOf(RecipeTypes.SMELTING) }
MMenus.POWERED_BLAST_FURNACE -> Supplier { listOf(RecipeTypes.BLASTING) }
MMenus.POWERED_SMOKER -> Supplier { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) }
else -> null
}
}
init {
if (tile != null) balanceInputs.with(tile::balanceInputs)
addStorageSlot(inputSlots)
addStorageSlot(outputSlots)
addInventorySlots()
}
companion object {

View File

@ -1,47 +0,0 @@
package ru.dbotthepony.mc.otm.menu.tech
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity
import ru.dbotthepony.mc.otm.menu.OutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.makeSlots
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus
class TwinPlatePressMenu(
containerID: Int,
inventory: Inventory,
tile: PlatePressBlockEntity? = null
) : MatteryPoweredMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile) {
val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(2), ::MatterySlot)
val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> OutputSlot(a, b) { tile?.experience?.popExperience(player as ServerPlayer) } }
val progressGauge0 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(0))
val progressGauge1 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(1))
val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true)
val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true)
val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
val balanceInputs = BooleanInputWithFeedback(this)
val upgrades = makeUpgradeSlots(4, tile?.upgrades)
init {
if (tile != null) {
balanceInputs.with(tile::balanceInputs)
}
}
init {
addStorageSlot(inputSlots)
addStorageSlot(outputSlots)
addInventorySlots()
}
}

View File

@ -5,9 +5,7 @@ import net.minecraft.world.flag.FeatureFlags
import net.minecraft.world.inventory.MenuType
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity
import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen
import ru.dbotthepony.mc.otm.client.screen.decorative.FluidTankScreen
@ -38,9 +36,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen
import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen
import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen
import ru.dbotthepony.mc.otm.client.screen.decorative.PainterScreen
import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen
import ru.dbotthepony.mc.otm.client.screen.tech.PoweredFurnaceScreen
import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen
import ru.dbotthepony.mc.otm.client.screen.tech.AbstractProcessingMachineScreen
import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu
import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu
import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu
@ -72,7 +68,6 @@ import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu
import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
object MMenus {
private val registry = MDeferredRegister(ForgeRegistries.MENU_TYPES)
@ -94,11 +89,11 @@ object MMenus {
val ITEM_MONITOR by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu, FeatureFlags.VANILLA_SET) }
val ENERGY_COUNTER by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) }
val CHEMICAL_GENERATOR by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) }
val PLATE_PRESS by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) }
val PLATE_PRESS by registry.register(MNames.PLATE_PRESS) { MenuType(PlatePressMenu::single, FeatureFlags.VANILLA_SET) }
val POWERED_FURNACE by registry.register(MNames.POWERED_FURNACE) { MenuType(PoweredFurnaceMenu::furnace, FeatureFlags.VANILLA_SET) }
val POWERED_BLAST_FURNACE by registry.register(MNames.POWERED_BLAST_FURNACE) { MenuType(PoweredFurnaceMenu::blasting, FeatureFlags.VANILLA_SET) }
val POWERED_SMOKER by registry.register(MNames.POWERED_SMOKER) { MenuType(PoweredFurnaceMenu::smoking, FeatureFlags.VANILLA_SET) }
val TWIN_PLATE_PRESS by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) }
val TWIN_PLATE_PRESS by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(PlatePressMenu::twin, FeatureFlags.VANILLA_SET) }
val MATTER_RECYCLER by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) }
val ENERGY_SERVO by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) }
val HOLO_SIGN by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu, FeatureFlags.VANILLA_SET) }
@ -137,8 +132,8 @@ object MMenus {
MenuScreens.register(ITEM_MONITOR, ::ItemMonitorScreen)
MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen)
MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen)
MenuScreens.register(PLATE_PRESS, ::PlatePressScreen)
MenuScreens.register(TWIN_PLATE_PRESS, ::TwinPlatePressScreen)
MenuScreens.register(PLATE_PRESS, ::AbstractProcessingMachineScreen)
MenuScreens.register(TWIN_PLATE_PRESS, ::AbstractProcessingMachineScreen)
MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen)
MenuScreens.register(STORAGE_BUS, ::StorageBusScreen)
MenuScreens.register(STORAGE_IMPORTER_EXPORTER, ::StorageImporterExporterScreen)
@ -149,9 +144,9 @@ object MMenus {
MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen)
MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen)
MenuScreens.register(FLUID_TANK, ::FluidTankScreen)
MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen)
MenuScreens.register(POWERED_BLAST_FURNACE, ::PoweredFurnaceScreen)
MenuScreens.register(POWERED_SMOKER, ::PoweredFurnaceScreen)
MenuScreens.register(POWERED_FURNACE, ::AbstractProcessingMachineScreen)
MenuScreens.register(POWERED_BLAST_FURNACE, ::AbstractProcessingMachineScreen)
MenuScreens.register(POWERED_SMOKER, ::AbstractProcessingMachineScreen)
MenuScreens.register(PAINTER, ::PainterScreen)
MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen)
}