JEI recipes button inside machines GUI
This commit is contained in:
parent
2e94245d7c
commit
c7442e4ad2
@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer
|
||||
import ru.dbotthepony.mc.otm.container.balance
|
||||
import ru.dbotthepony.mc.otm.core.immutableList
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
|
||||
class PoweredFurnaceBlockEntity(
|
||||
type: BlockEntityType<PoweredFurnaceBlockEntity>,
|
||||
@ -80,8 +81,13 @@ class PoweredFurnaceBlockEntity(
|
||||
super.tick()
|
||||
}
|
||||
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu {
|
||||
return PoweredFurnaceMenu(containerID, inventory, this)
|
||||
override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? {
|
||||
return when (type) {
|
||||
MBlockEntities.POWERED_FURNACE -> PoweredFurnaceMenu.furnace(containerID, inventory, this)
|
||||
MBlockEntities.POWERED_BLAST_FURNACE -> PoweredFurnaceMenu.blasting(containerID, inventory, this)
|
||||
MBlockEntities.POWERED_SMOKER -> PoweredFurnaceMenu.smoking(containerID, inventory, this)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onJobFinish(status: JobStatus<ItemJob>, id: Int) {
|
||||
|
@ -13,6 +13,8 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.compat.jei.MatterEntanglerRecipeCategory
|
||||
import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory
|
||||
import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu
|
||||
|
||||
class MatterEntanglerScreen(menu: MatterEntanglerMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterEntanglerMenu>(menu, inventory, title) {
|
||||
@ -35,6 +37,7 @@ class MatterEntanglerScreen(menu: MatterEntanglerMenu, inventory: Inventory, tit
|
||||
it.dock = Dock.LEFT
|
||||
it.dockHorizontal(4f)
|
||||
it.dockResize = DockResizeMode.NONE
|
||||
it.setRecipeType { listOf(MatterEntanglerRecipeCategory.recipeType) }
|
||||
}
|
||||
|
||||
SlotPanel(this, frame, menu.outputs[0]).also {
|
||||
|
@ -1,5 +1,6 @@
|
||||
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
|
||||
@ -30,6 +31,9 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory,
|
||||
}
|
||||
|
||||
progress.flop = true
|
||||
|
||||
progress.setRecipeType { listOf(RecipeTypes.FUELING) }
|
||||
|
||||
SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP)
|
||||
SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP)
|
||||
|
||||
|
@ -9,6 +9,7 @@ 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) :
|
||||
@ -20,7 +21,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon
|
||||
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)
|
||||
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)
|
||||
|
@ -1,5 +1,6 @@
|
||||
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
|
||||
@ -11,6 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu
|
||||
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
|
||||
class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<PoweredFurnaceMenu>(menu, inventory, title) {
|
||||
@ -21,15 +23,32 @@ class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title
|
||||
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.progressGauge[0], 78f, PROGRESS_ARROW_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)
|
||||
ProgressGaugePanel(this, frame, menu.progressGauge[1], 78f, PROGRESS_ARROW_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(RecipeTypes.SMOKING) }
|
||||
b.setRecipeType { listOf(RecipeTypes.SMOKING) }
|
||||
}
|
||||
}
|
||||
|
||||
return frame
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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) :
|
||||
@ -20,11 +21,11 @@ class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
@ -1,7 +1,9 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.widget
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.recipe.RecipeType
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
@ -9,22 +11,28 @@ import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel
|
||||
import ru.dbotthepony.mc.otm.compat.jei.JEIPlugin
|
||||
import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
import java.util.function.Supplier
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
open class ProgressGaugePanel<out S : Screen> @JvmOverloads constructor(
|
||||
open class ProgressGaugePanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val widget: ProgressGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f
|
||||
): EditablePanel<S>(screen, parent, x, y, width = GAUGE_BACKGROUND.width, height = GAUGE_BACKGROUND.height) {
|
||||
): AbstractButtonPanel<S>(screen, parent, x, y, width = GAUGE_BACKGROUND.width, height = GAUGE_BACKGROUND.height) {
|
||||
init {
|
||||
scissor = true
|
||||
}
|
||||
|
||||
var flop = false
|
||||
private var recipeTypeSupplier: Supplier<List<RecipeType<*>>>? = null
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Component> {
|
||||
val tooltip: MutableList<Component>
|
||||
@ -46,6 +54,11 @@ open class ProgressGaugePanel<out S : Screen> @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
if (recipeTypeSupplier != null) {
|
||||
tooltip.add(TextComponent(""))
|
||||
tooltip.add(TranslatableComponent("jei.tooltip.show.recipes").withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
return tooltip
|
||||
}
|
||||
|
||||
@ -78,6 +91,25 @@ open class ProgressGaugePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun test(value: Int): Boolean {
|
||||
return recipeTypeSupplier != null && value == InputConstants.MOUSE_BUTTON_LEFT
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
val recipeTypeSupplier = recipeTypeSupplier ?: return
|
||||
JEIPlugin.RUNTIME.recipesGui.showTypes(recipeTypeSupplier.get())
|
||||
}
|
||||
|
||||
private fun setRecipeType0(provider: Supplier<List<RecipeType<*>>>) {
|
||||
recipeTypeSupplier = provider
|
||||
}
|
||||
|
||||
fun setRecipeType(provider: Supplier<List<RecipeType<*>>>) {
|
||||
if (isJeiLoaded) {
|
||||
setRecipeType0(provider)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val GAUGE_BACKGROUND = WidgetLocation.PROGRESS_ARROWS.sprite(y = 0f, width = 22f, height = 15f)
|
||||
val GAUGE_FOREGROUND = WidgetLocation.PROGRESS_ARROWS.sprite(y = 15f, width = 22f, height = 15f)
|
||||
|
@ -13,6 +13,7 @@ import mezz.jei.api.registration.IRecipeCategoryRegistration
|
||||
import mezz.jei.api.registration.IRecipeRegistration
|
||||
import mezz.jei.api.registration.IRecipeTransferRegistration
|
||||
import mezz.jei.api.runtime.IClickableIngredient
|
||||
import mezz.jei.api.runtime.IJeiRuntime
|
||||
import net.minecraft.client.renderer.Rect2i
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.ItemStack
|
||||
@ -40,6 +41,11 @@ class JEIPlugin : IModPlugin {
|
||||
|
||||
var helpers: IJeiHelpers by Delegates.notNull()
|
||||
private set
|
||||
|
||||
private var _RUNTIME: IJeiRuntime? = null
|
||||
|
||||
val RUNTIME: IJeiRuntime
|
||||
get() = checkNotNull(_RUNTIME) { "JEI runtime is unavailable" }
|
||||
}
|
||||
|
||||
init {
|
||||
@ -63,6 +69,14 @@ class JEIPlugin : IModPlugin {
|
||||
registration.addRecipeCatalyst(ItemStack(MItems.MATTER_ENTANGLER), MatterEntanglerRecipeCategory.recipeType)
|
||||
}
|
||||
|
||||
override fun onRuntimeAvailable(jeiRuntime: IJeiRuntime) {
|
||||
_RUNTIME = jeiRuntime
|
||||
}
|
||||
|
||||
override fun onRuntimeUnavailable() {
|
||||
_RUNTIME = null
|
||||
}
|
||||
|
||||
override fun registerCategories(registration: IRecipeCategoryRegistration) {
|
||||
helpers = registration.jeiHelpers
|
||||
registration.addRecipeCategories(PlatePressRecipeCategory)
|
||||
|
@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.menu.tech
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.immutableList
|
||||
import ru.dbotthepony.mc.otm.menu.OutputSlot
|
||||
@ -16,10 +17,11 @@ import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.registry.MMenus
|
||||
|
||||
class PoweredFurnaceMenu(
|
||||
type: MenuType<PoweredFurnaceMenu>,
|
||||
containerID: Int,
|
||||
inventory: Inventory,
|
||||
tile: PoweredFurnaceBlockEntity? = null
|
||||
) : MatteryPoweredMenu(MMenus.POWERED_FURNACE, containerID, inventory, tile) {
|
||||
) : MatteryPoweredMenu(type, containerID, inventory, tile) {
|
||||
val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot)
|
||||
val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.popExperience(player as ServerPlayer) } }
|
||||
|
||||
@ -38,4 +40,30 @@ class PoweredFurnaceMenu(
|
||||
addStorageSlot(outputSlots)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun furnace(
|
||||
containerID: Int,
|
||||
inventory: Inventory,
|
||||
tile: PoweredFurnaceBlockEntity? = null
|
||||
) : PoweredFurnaceMenu {
|
||||
return PoweredFurnaceMenu(MMenus.POWERED_FURNACE, containerID, inventory, tile)
|
||||
}
|
||||
|
||||
fun blasting(
|
||||
containerID: Int,
|
||||
inventory: Inventory,
|
||||
tile: PoweredFurnaceBlockEntity? = null
|
||||
) : PoweredFurnaceMenu {
|
||||
return PoweredFurnaceMenu(MMenus.POWERED_BLAST_FURNACE, containerID, inventory, tile)
|
||||
}
|
||||
|
||||
fun smoking(
|
||||
containerID: Int,
|
||||
inventory: Inventory,
|
||||
tile: PoweredFurnaceBlockEntity? = null
|
||||
) : PoweredFurnaceMenu {
|
||||
return PoweredFurnaceMenu(MMenus.POWERED_SMOKER, containerID, inventory, tile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,9 @@ object MMenus {
|
||||
val ENERGY_COUNTER: MenuType<EnergyCounterMenu> by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) }
|
||||
val CHEMICAL_GENERATOR: MenuType<ChemicalGeneratorMenu> by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) }
|
||||
val PLATE_PRESS: MenuType<PlatePressMenu> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) }
|
||||
val POWERED_FURNACE: MenuType<PoweredFurnaceMenu> by registry.register(MNames.POWERED_FURNACE) { MenuType(::PoweredFurnaceMenu, FeatureFlags.VANILLA_SET) }
|
||||
val POWERED_FURNACE: MenuType<PoweredFurnaceMenu> by registry.register(MNames.POWERED_FURNACE) { MenuType(PoweredFurnaceMenu::furnace, FeatureFlags.VANILLA_SET) }
|
||||
val POWERED_BLAST_FURNACE: MenuType<PoweredFurnaceMenu> by registry.register(MNames.POWERED_BLAST_FURNACE) { MenuType(PoweredFurnaceMenu::blasting, FeatureFlags.VANILLA_SET) }
|
||||
val POWERED_SMOKER: MenuType<PoweredFurnaceMenu> by registry.register(MNames.POWERED_SMOKER) { MenuType(PoweredFurnaceMenu::smoking, FeatureFlags.VANILLA_SET) }
|
||||
val TWIN_PLATE_PRESS: MenuType<TwinPlatePressMenu> by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_RECYCLER: MenuType<MatterRecyclerMenu> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val ENERGY_SERVO: MenuType<EnergyServoMenu> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) }
|
||||
@ -148,6 +150,8 @@ object MMenus {
|
||||
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(PAINTER, ::PainterScreen)
|
||||
MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user