Revert fluid gauge panel clicking for jei recipes

This commit is contained in:
DBotThePony 2024-01-09 13:15:41 +07:00
parent b95a1885e8
commit 1c9ea6f8bd
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -1,11 +1,8 @@
package ru.dbotthepony.mc.otm.client.screen.widget package ru.dbotthepony.mc.otm.client.screen.widget
import com.mojang.blaze3d.platform.InputConstants
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.VertexFormat import com.mojang.blaze3d.vertex.VertexFormat
import mezz.jei.api.forge.ForgeTypes
import mezz.jei.api.recipe.RecipeIngredientRole
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
@ -16,16 +13,12 @@ import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions
import net.minecraftforge.fml.ModList import net.minecraftforge.fml.ModList
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.CursorType
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.render.tesselator
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel 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.TextComponent
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty
@ -34,7 +27,6 @@ import ru.dbotthepony.mc.otm.core.math.linearInterpolation
import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.core.util.formatFluidLevel import ru.dbotthepony.mc.otm.core.util.formatFluidLevel
import ru.dbotthepony.mc.otm.menu.widget.FluidGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.FluidGaugeWidget
import kotlin.jvm.optionals.getOrNull
open class FluidGaugePanel<out S : Screen>( open class FluidGaugePanel<out S : Screen>(
screen: S, screen: S,
@ -42,7 +34,7 @@ open class FluidGaugePanel<out S : Screen>(
val widget: FluidGaugeWidget, val widget: FluidGaugeWidget,
x: Float = 0f, x: Float = 0f,
y: Float = 0f y: Float = 0f
) : AbstractButtonPanel<S>(screen, parent, x, y, width = GAUGE.width, height = GAUGE.height) { ) : EditablePanel<S>(screen, parent, x, y, width = GAUGE.width, height = GAUGE.height) {
init { init {
scissor = true scissor = true
} }
@ -69,29 +61,6 @@ open class FluidGaugePanel<out S : Screen>(
return false return false
} }
private fun openFluidRecipes(button: Int) {
val ingredient = JEIPlugin.RUNTIME.ingredientManager.createTypedIngredient(ForgeTypes.FLUID_STACK, widget.fluid).getOrNull() ?: return
if (button == InputConstants.MOUSE_BUTTON_RIGHT) {
JEIPlugin.RUNTIME.recipesGui.show(JEIPlugin.RUNTIME.jeiHelpers.focusFactory.createFocus(RecipeIngredientRole.INPUT, ingredient))
} else {
JEIPlugin.RUNTIME.recipesGui.show(JEIPlugin.RUNTIME.jeiHelpers.focusFactory.createFocus(RecipeIngredientRole.OUTPUT, ingredient))
}
}
override val cursorType: CursorType
get() = if (isJeiLoaded && widget.fluid.isNotEmpty) CursorType.HAND else CursorType.ARROW
override fun test(value: Int): Boolean {
return (value == InputConstants.MOUSE_BUTTON_RIGHT || value == InputConstants.MOUSE_BUTTON_LEFT) && isJeiLoaded && widget.fluid.isNotEmpty
}
override fun onClick(mouseButton: Int) {
if (isJeiLoaded && widget.fluid.isNotEmpty) {
openFluidRecipes(mouseButton)
}
}
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) { if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) {
val data = IClientFluidTypeExtensions.of(widget.fluid.fluid) val data = IClientFluidTypeExtensions.of(widget.fluid.fluid)