Get rid of most code in MatteryScreen
This commit is contained in:
parent
72b577434c
commit
58bd62d1a2
@ -49,8 +49,8 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
||||
|
||||
var frame = new FramePanel(this, null, 0, 0, width, height, getTitle()) {
|
||||
@Override
|
||||
protected boolean mouseScrolledInner(double mouse_x, double mouse_y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(mouse_x, mouse_y, scroll);
|
||||
protected boolean mouseScrolledInner(double x, double y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(x, y, scroll);
|
||||
}
|
||||
};
|
||||
|
||||
@ -86,8 +86,8 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
||||
|
||||
var grid = new GridPanel(this, frame, 0, 0, GRID_WIDTH * AbstractSlotPanel.REGULAR_DIMENSIONS, 0, GRID_WIDTH, GRID_HEIGHT) {
|
||||
@Override
|
||||
protected boolean mouseScrolledInner(double mouse_x, double mouse_y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(mouse_x, mouse_y, scroll);
|
||||
protected boolean mouseScrolledInner(double x, double y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(x, y, scroll);
|
||||
}
|
||||
};
|
||||
|
||||
@ -123,12 +123,12 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mouseScrolledInner(double mouse_x, double mouse_y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(mouse_x, mouse_y, scroll);
|
||||
protected boolean mouseScrolledInner(double x, double y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(x, y, scroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mouseClickedInner(double mouse_x, double mouse_y, int flag) {
|
||||
protected boolean mouseClickedInner(double x, double y, int flag) {
|
||||
if (slot >= menu.getPatterns().size()) {
|
||||
return true;
|
||||
}
|
||||
@ -166,12 +166,12 @@ public class MatterPanelScreen extends MatteryScreen<MatterPanelMenu> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mouseScrolledInner(double mouse_x, double mouse_y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(mouse_x, mouse_y, scroll);
|
||||
protected boolean mouseScrolledInner(double x, double y, double scroll) {
|
||||
return scroll_panel.mouseScrolledInner(x, y, scroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mouseClickedInner(double mouse_x, double mouse_y, int flag) {
|
||||
protected boolean mouseClickedInner(double x, double y, int flag) {
|
||||
if (slot >= menu.getTasks().size()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ private open class AndroidResearchButton(
|
||||
}
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
val hovered = (screen as AndroidStationScreen).hoveredResearch
|
||||
|
||||
val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking
|
||||
@ -342,8 +342,8 @@ private open class AndroidResearchButton(
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
if (mouse_click_type == InputConstants.MOUSE_BUTTON_LEFT) {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (button == InputConstants.MOUSE_BUTTON_LEFT) {
|
||||
if (node.canResearch && !node.isResearched) {
|
||||
MatteryPlayerNetworkChannel.sendToServer(AndroidResearchRequestPacket(node.type))
|
||||
}
|
||||
@ -388,7 +388,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
val rows = Int2ObjectAVLTreeMap<EditablePanel>()
|
||||
|
||||
canvas = object : DraggableCanvasPanel(this@AndroidStationScreen, research, width = (GRID_WIDTH * 22).toFloat(), height = 0f) {
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
drawColor = RGBAColor.BLACK
|
||||
drawRect(stack, 0f, 0f, width, height)
|
||||
}
|
||||
@ -404,9 +404,9 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
for (i in 0 .. tree.height) {
|
||||
rows.computeIfAbsent(i, Int2ObjectFunction {
|
||||
object : EditablePanel(this@AndroidStationScreen, canvas, 0f, it * 24f, 10000f, 22f) {
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int) = false
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int) = false
|
||||
override fun mouseDraggedInner(mouse_x: Double, mouse_y: Double, flag: Int, drag_x: Double, drag_y: Double) = false
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double) = false
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -418,9 +418,9 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
for (research in graph.second) {
|
||||
val row = rows.computeIfAbsent(research.researchTreeDepth, Int2ObjectFunction {
|
||||
object : EditablePanel(this@AndroidStationScreen, canvas, 0f, it * 24f, 10000f, 22f) {
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int) = false
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int) = false
|
||||
override fun mouseDraggedInner(mouse_x: Double, mouse_y: Double, flag: Int, drag_x: Double, drag_y: Double) = false
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int) = false
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double) = false
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -63,18 +63,18 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp
|
||||
return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.item ?: ItemStack.EMPTY
|
||||
}
|
||||
|
||||
override fun mouseScrolledInner(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
return scrollBar.mouseScrolledInner(mouse_x, mouse_y, scroll)
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return scrollBar.mouseScrolledInner(x, y, scroll)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
val index = i + scrollBar.getScroll(GRID_WIDTH)
|
||||
menu.networkedItemView.mouseClick(index, mouse_click_type)
|
||||
menu.networkedItemView.mouseClick(index, button)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
renderSlotBackground(stack, mouse_x, mouse_y, flag)
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
renderSlotBackground(stack, mouseX, mouseY, partialTick)
|
||||
renderRegular(stack, getItemStack(), "")
|
||||
}
|
||||
|
||||
|
@ -55,17 +55,17 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.item ?: ItemStack.EMPTY
|
||||
}
|
||||
|
||||
override fun mouseScrolledInner(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
return viewScrollBar.mouseScrolledInner(mouse_x, mouse_y, scroll)
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return viewScrollBar.mouseScrolledInner(x, y, scroll)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
menu.networkedItemView.mouseClick(index, mouse_click_type)
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
menu.networkedItemView.mouseClick(index, button)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
renderSlotBackground(stack, mouse_x, mouse_y, flag)
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
renderSlotBackground(stack, mouseX, mouseY, partialTick)
|
||||
|
||||
val itemstack = menu.networkedItemView.sortedView.getOrNull(index)?.stack ?: ITEM_STORAGE.empty
|
||||
|
||||
@ -108,7 +108,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
}
|
||||
|
||||
val arrowAndButtons = object : EditablePanel(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.w) {
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
ProgressGaugePanel.GAUGE_BACKGROUND.render(stack, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.h / 2f)
|
||||
}
|
||||
}
|
||||
@ -178,8 +178,8 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
return ItemStack(Items.ARROW, 42)
|
||||
}
|
||||
|
||||
override fun mouseScrolledInner(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
return craftingHistoryScroll.mouseScrolledInner(mouse_x, mouse_y, scroll)
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return craftingHistoryScroll.mouseScrolledInner(x, y, scroll)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,143 +1,76 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen;
|
||||
package ru.dbotthepony.mc.otm.client.screen
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu;
|
||||
import ru.dbotthepony.mc.otm.menu.MatterySlot;
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_ALWAYS;
|
||||
import static org.lwjgl.opengl.GL11.GL_LESS;
|
||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background
|
||||
import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL13
|
||||
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.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
|
||||
/**
|
||||
* This class encapsulate most of logic for handling EditablePanel and it's children
|
||||
* It inherits AbstractContainerScreen, but most of methods of AbstractContainerScreen are re implemented or straight removed
|
||||
* since they are present inside EditablePanel subclasses, therefore
|
||||
* it inherits AbstractContainerScreen just for signature compatibility
|
||||
* This class encapsulate most of logic for handling EditablePanel and it's children.
|
||||
*
|
||||
* Widgets such as slots are not drawn/interacted with using MatteryScreen,
|
||||
* but are handled by appropriate panels
|
||||
*
|
||||
* @param <T> type of menu, which extends MatteryMenu
|
||||
*/
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public abstract class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScreen<T> {
|
||||
public static final float SNAPBACK_SPEED = 100.0F;
|
||||
public static final int QUICKDROP_DELAY = 500;
|
||||
public static final int DOUBLECLICK_SPEED = 250;
|
||||
public static final int SLOT_ITEM_BLIT_OFFSET = 100;
|
||||
public static final int HOVER_ITEM_BLIT_OFFSET = 200;
|
||||
@Suppress("LeakingThis")
|
||||
abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, title: Component) : AbstractContainerScreen<T>(menu, inventory, title) {
|
||||
protected val panels = ArrayDeque<EditablePanel>()
|
||||
|
||||
public final T menu;
|
||||
public final Component playerInventoryTitle;
|
||||
var inventoryFrame: FramePanel? = null
|
||||
var mainFrame: FramePanel? = null
|
||||
private var madeMainFrame = false
|
||||
|
||||
@Nullable
|
||||
public Slot hoveredSlot;
|
||||
@Nullable
|
||||
public Slot clickedSlot;
|
||||
@Nullable
|
||||
public Slot snapbackEnd;
|
||||
@Nullable
|
||||
public Slot quickdropSlot;
|
||||
@Nullable
|
||||
public Slot lastClickSlot;
|
||||
|
||||
protected int leftPos;
|
||||
protected int topPos;
|
||||
protected boolean isSplittingStack;
|
||||
protected ItemStack draggingItem = ItemStack.EMPTY;
|
||||
protected int snapbackStartX;
|
||||
protected int snapbackStartY;
|
||||
protected long snapbackTime;
|
||||
protected ItemStack snapbackItem = ItemStack.EMPTY;
|
||||
protected long quickdropTime;
|
||||
public final Set<Slot> quickCraftSlots = Sets.newHashSet();
|
||||
|
||||
public boolean isQuickCrafting() {
|
||||
return isQuickCrafting;
|
||||
}
|
||||
|
||||
protected boolean isQuickCrafting;
|
||||
|
||||
public int getQuickCraftingType() {
|
||||
return quickCraftingType;
|
||||
}
|
||||
|
||||
protected int quickCraftingType;
|
||||
protected int quickCraftingButton;
|
||||
protected boolean skipNextRelease;
|
||||
protected int quickCraftingRemainder;
|
||||
protected long lastClickTime;
|
||||
protected int lastClickButton;
|
||||
protected boolean doubleclick;
|
||||
protected ItemStack lastQuickMoved = ItemStack.EMPTY;
|
||||
|
||||
protected final ArrayList<EditablePanel> panels = new ArrayList<>();
|
||||
public FramePanel inventory_frame;
|
||||
public FramePanel main_frame;
|
||||
private boolean made_main_frame = false;
|
||||
|
||||
public static final float DEFAULT_FRAME_WIDTH = 18 * 9 + 16;
|
||||
public static final float DEFAULT_FRAME_HEIGHT = 100;
|
||||
|
||||
public static final float INVENTORY_FRAME_WIDTH = DEFAULT_FRAME_WIDTH;
|
||||
public static final float INVENTORY_FRAME_HEIGHT = 3 * 18 + 18 + 24;
|
||||
|
||||
public MatteryScreen(T menu, Inventory inventory, Component title) {
|
||||
super(menu, inventory, title);
|
||||
this.menu = menu;
|
||||
playerInventoryTitle = inventory.getDisplayName();
|
||||
|
||||
if (menu.getPlayerInventorySlots().size() != 0) {
|
||||
inventory_frame = new FramePanel(this, null, 0, 0, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.getDisplayName());
|
||||
panels.add(inventory_frame);
|
||||
|
||||
for (var slot : menu.getPlayerInventorySlots()) {
|
||||
new SlotPanel<>(
|
||||
this,
|
||||
inventory_frame,
|
||||
slot,
|
||||
slot.x,
|
||||
slot.y,
|
||||
18, 18);
|
||||
}
|
||||
fun addPanel(panel: EditablePanel): Boolean {
|
||||
if (!panels.contains(panel)) {
|
||||
panels.addFirst(panel)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
public void addPanel(EditablePanel panel) {
|
||||
if (!panels.contains(panel))
|
||||
panels.add(panel);
|
||||
fun removePanel(panel: EditablePanel): Boolean {
|
||||
val indexOf = panels.indexOf(panel)
|
||||
|
||||
if (indexOf != -1) {
|
||||
panels.removeAt(indexOf)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
public void removePanel(EditablePanel panel) {
|
||||
panels.remove(panel);
|
||||
/**
|
||||
* Moves panel at top of all other panels
|
||||
*
|
||||
* @param panel panel to be pushed up
|
||||
*/
|
||||
fun popup(panel: EditablePanel) {
|
||||
val indexOf = panels.indexOf(panel)
|
||||
|
||||
require(indexOf != -1) { "No such panel $panel" }
|
||||
|
||||
if (indexOf == panels.size - 1) {
|
||||
return
|
||||
}
|
||||
|
||||
panels.removeAt(indexOf)
|
||||
panels.addFirst(panel)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,571 +80,287 @@ public abstract class MatteryScreen<T extends MatteryMenu> extends AbstractConta
|
||||
*
|
||||
* @return FramePanel created, or null
|
||||
*/
|
||||
@Nullable
|
||||
protected FramePanel makeMainFrame() {
|
||||
return new FramePanel(this, null, 0, 0, DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT, getTitle());
|
||||
protected open fun makeMainFrame(): FramePanel? {
|
||||
return FramePanel(this, null, 0f, 0f, DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT, getTitle())
|
||||
}
|
||||
|
||||
public static final float GAUGE_TOP_WITH_SLOT = 17;
|
||||
public static final float GAUGE_TOP_WITHOUT_SLOT = 26;
|
||||
public static final float SLOT_TOP_UNDER_GAUGE = 70;
|
||||
public static final float PROGRESS_ARROW_TOP = 42;
|
||||
public static final float PROGRESS_SLOT_TOP = 41;
|
||||
public static final float LEFT_MARGIN = 8;
|
||||
var itemRenderer: ItemRenderer
|
||||
get() = itemRenderer
|
||||
set(itemRenderer) { super.itemRenderer = itemRenderer }
|
||||
var font: Font
|
||||
get() = font
|
||||
set(font) { super.font = font }
|
||||
var hoveredSlot: Slot?
|
||||
get() = hoveredSlot
|
||||
set(value) { super.hoveredSlot = value }
|
||||
val quickCraftSlots: MutableSet<Slot> get() = quickCraftSlots
|
||||
val quickCraftingType get() = quickCraftingType
|
||||
val isQuickCrafting get() = isQuickCrafting
|
||||
|
||||
public ItemRenderer getItemRenderer() {
|
||||
return itemRenderer;
|
||||
public override fun recalculateQuickCraftRemaining() {
|
||||
super.recalculateQuickCraftRemaining()
|
||||
}
|
||||
|
||||
public Font getFont() {
|
||||
return font;
|
||||
}
|
||||
fun movePanels() {
|
||||
var top = height / 2
|
||||
val mainFrame = mainFrame
|
||||
val inventoryFrame = inventoryFrame
|
||||
|
||||
/**
|
||||
* Moves panel at top of all other panels
|
||||
*
|
||||
* @param panel panel to be pushed up
|
||||
*/
|
||||
public void popup(EditablePanel panel) {
|
||||
if (!panels.contains(panel))
|
||||
throw new IllegalArgumentException("No such panel " + panel);
|
||||
|
||||
if (panels.indexOf(panel) == panels.size())
|
||||
return;
|
||||
|
||||
panels.remove(panel);
|
||||
panels.add(panel);
|
||||
}
|
||||
|
||||
public void movePanels() {
|
||||
var top = height / 2;
|
||||
|
||||
if (main_frame != null) {
|
||||
top -= main_frame.getHeight() / 2;
|
||||
if (mainFrame != null) {
|
||||
top -= (mainFrame.height / 2).toInt()
|
||||
}
|
||||
|
||||
if (inventory_frame != null) {
|
||||
top -= inventory_frame.getHeight() / 2;
|
||||
if (inventoryFrame != null) {
|
||||
top -= (inventoryFrame.height / 2).toInt()
|
||||
}
|
||||
|
||||
if (main_frame != null) {
|
||||
main_frame.setPos(width / 2 - main_frame.getWidth() / 2, top);
|
||||
top += main_frame.getHeight();
|
||||
if (mainFrame != null) {
|
||||
mainFrame.setPos(width / 2 - mainFrame.width / 2, top.toFloat())
|
||||
top += mainFrame.height.toInt()
|
||||
}
|
||||
|
||||
if (inventory_frame != null) {
|
||||
inventory_frame.setPos(width / 2 - inventory_frame.getWidth() / 2, top);
|
||||
top += inventory_frame.getHeight();
|
||||
if (inventoryFrame != null) {
|
||||
inventoryFrame.setPos(width / 2 - inventoryFrame.width / 2, top.toFloat())
|
||||
top += inventoryFrame.height.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
override fun init() {
|
||||
super.init()
|
||||
|
||||
movePanels();
|
||||
if (!madeMainFrame) {
|
||||
madeMainFrame = true
|
||||
mainFrame = makeMainFrame()?.also(this::addPanel)
|
||||
movePanels()
|
||||
}
|
||||
|
||||
movePanels()
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double p_97748_, double p_97749_, int p_97750_) {
|
||||
var happen_to_click = false;
|
||||
override fun mouseClicked(x: Double, y: Double, button: Int): Boolean {
|
||||
var click = false
|
||||
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
if (happen_to_click) {
|
||||
panel.killFocusForEverythingExceptInner();
|
||||
} else if (panel.mouseClickedChecked(p_97748_, p_97749_, p_97750_)) {
|
||||
happen_to_click = true;
|
||||
for (panel in panels) {
|
||||
if (click || !panel.mouseClickedChecked(x, y, button)) {
|
||||
panel.killFocusForEverythingExceptInner()
|
||||
} else {
|
||||
panel.killFocusForEverythingExceptInner();
|
||||
if (returnSlot != null) {
|
||||
super.mouseClicked(x, y, button)
|
||||
returnSlot = null
|
||||
}
|
||||
|
||||
click = true
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double p_97752_, double p_97753_, int p_97754_, double p_97755_, double p_97756_) {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
override fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.mouseDraggedChecked(x, y, button, xDelta, yDelta)) {
|
||||
if (returnSlot != null) {
|
||||
super.mouseDragged(x, y, button, xDelta, yDelta)
|
||||
returnSlot = null
|
||||
}
|
||||
|
||||
if (panel.mouseDraggedChecked(p_97752_, p_97753_, p_97754_, p_97755_, p_97756_)) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
override fun mouseReleased(p_97812_: Double, p_97813_: Double, p_97814_: Int): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.mouseReleasedChecked(p_97812_, p_97813_, p_97814_)) {
|
||||
return true;
|
||||
if (returnSlot != null) {
|
||||
super.mouseReleased(p_97812_, p_97813_, p_97814_)
|
||||
returnSlot = null
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// handle quick moving ("quickcraft") by ourselves if we depressed outside of slot
|
||||
onMouseReleasedSlot(null, p_97812_, p_97813_, p_97814_, true);
|
||||
|
||||
return true;
|
||||
return super.mouseReleased(p_97812_, p_97813_, p_97814_)
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double p_94686_, double p_94687_, double p_94688_) {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
override fun mouseScrolled(p_94686_: Double, p_94687_: Double, p_94688_: Double): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.mouseScrolledChecked(p_94686_, p_94687_, p_94688_)) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyReleased(int p_94715_, int p_94716_, int p_94717_) {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
override fun keyReleased(p_94715_: Int, p_94716_: Int, p_94717_: Int): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.keyReleased(p_94715_, p_94716_, p_94717_)) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char p_94683_, int p_94684_) {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
override fun charTyped(p_94683_: Char, p_94684_: Int): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.charTyped(p_94683_, p_94684_)) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) {
|
||||
InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_);
|
||||
override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
for (panel in panels) {
|
||||
if (panel.keyPressed(key, scancode, mods)) {
|
||||
if (returnSlot != null) {
|
||||
super.keyPressed(key, scancode, mods)
|
||||
returnSlot = null
|
||||
}
|
||||
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
if (panel.keyPressed(p_97765_, p_97766_, p_97767_)) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
boolean handled = this.checkHotbarKeyPressed(p_97765_, p_97766_);// Forge MC-146650: Needs to return true when the key is handled
|
||||
if (this.hoveredSlot != null && this.hoveredSlot.hasItem()) {
|
||||
if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 0, ClickType.CLONE);
|
||||
handled = true;
|
||||
} else if (this.minecraft.options.keyDrop.isActiveAndMatches(mouseKey)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, hasControlDown() ? 1 : 0, ClickType.THROW);
|
||||
handled = true;
|
||||
return super.keyPressed(key, scancode, mods)
|
||||
}
|
||||
|
||||
override fun renderBg(p_97787_: PoseStack, p_97788_: Float, p_97789_: Int, p_97790_: Int) {}
|
||||
|
||||
var returnSlot: Slot? = null
|
||||
|
||||
init {
|
||||
if (menu.playerInventorySlots.isNotEmpty()) {
|
||||
inventoryFrame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel)
|
||||
|
||||
for (slot in menu.playerInventorySlots) {
|
||||
SlotPanel(this, inventoryFrame, slot, slot.x.toFloat(), slot.y.toFloat())
|
||||
}
|
||||
} else if (this.minecraft.options.keyDrop.isActiveAndMatches(mouseKey)) {
|
||||
handled = true; // Forge MC-146650: Emulate MC bug, so we don't drop from hotbar when pressing drop without hovering over a item.
|
||||
}
|
||||
|
||||
// return handled;
|
||||
|
||||
// nothing dangerous in super method
|
||||
return super.keyPressed(p_97765_, p_97766_, p_97767_);
|
||||
}
|
||||
|
||||
public void renderFloatingItem(ItemStack p_97783_, int p_97784_, int p_97785_, String p_97786_) {
|
||||
PoseStack posestack = RenderSystem.getModelViewStack();
|
||||
posestack.translate(0.0D, 0.0D, 32.0D);
|
||||
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
this.setBlitOffset(200);
|
||||
this.itemRenderer.blitOffset = 200.0F;
|
||||
|
||||
net.minecraft.client.gui.Font font = p_97783_.getItem().getRenderPropertiesInternal() instanceof IClientItemExtensions ext ? ext.getFont(p_97783_, IClientItemExtensions.FontContext.TOOLTIP) : null;
|
||||
if (font == null) font = this.font;
|
||||
|
||||
this.itemRenderer.renderAndDecorateItem(p_97783_, p_97784_, p_97785_);
|
||||
this.itemRenderer.renderGuiItemDecorations(font, p_97783_, p_97784_, p_97785_ - (this.draggingItem.isEmpty() ? 0 : 8), p_97786_);
|
||||
|
||||
this.setBlitOffset(0);
|
||||
this.itemRenderer.blitOffset = 0.0F;
|
||||
override fun findSlot(x: Double, y: Double): Slot? {
|
||||
return returnSlot
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack p_97787_, float p_97788_, int p_97789_, int p_97790_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack pose, int mouse_x, int mouse_y, float flag) {
|
||||
if (!made_main_frame) {
|
||||
made_main_frame = true;
|
||||
main_frame = makeMainFrame();
|
||||
|
||||
if (main_frame != null) {
|
||||
addPanel(main_frame);
|
||||
}
|
||||
|
||||
movePanels();
|
||||
}
|
||||
|
||||
int render_x = this.leftPos;
|
||||
int render_y = this.topPos;
|
||||
override fun render(poseStack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
val mouseXf = mouseX.toFloat()
|
||||
val mouseYf = mouseY.toFloat()
|
||||
|
||||
// dark background
|
||||
this.renderBackground(pose);
|
||||
this.renderBackground(poseStack)
|
||||
|
||||
hoveredSlot = null;
|
||||
|
||||
var hovered = false;
|
||||
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
hoveredSlot = null
|
||||
var hovered = false
|
||||
|
||||
for (panel in panels) {
|
||||
if (hovered) {
|
||||
panel.unsetHovered();
|
||||
} else if (panel.tickHover(mouse_x, mouse_y)) {
|
||||
hovered = true;
|
||||
panel.unsetHovered()
|
||||
} else if (panel.tickHover(mouseXf, mouseYf)) {
|
||||
hovered = true
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.activeTexture(GL_TEXTURE0);
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.enableDepthTest()
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.activeTexture(GL13.GL_TEXTURE0)
|
||||
|
||||
float depth = -900f;
|
||||
var depth = -900f
|
||||
|
||||
for (var panel : panels) {
|
||||
RenderSystem.depthFunc(GL_ALWAYS);
|
||||
|
||||
panel.setAccumulatedDepth(depth);
|
||||
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
|
||||
depth = Math.max(depth, panel.render(pose, mouse_x, mouse_y, flag));
|
||||
for (i in panels.indices.reversed()) {
|
||||
val panel = panels[i]
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
panel.accumulatedDepth = depth
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
depth = depth.coerceAtLeast(panel.render(poseStack, mouseXf, mouseYf, partialTick))
|
||||
}
|
||||
|
||||
RenderSystem.depthFunc(GL_LESS);
|
||||
|
||||
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ContainerScreenEvent.Render.Background(this, pose, mouse_x, mouse_y));
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
MinecraftForge.EVENT_BUS.post(Background(this, poseStack, mouseX, mouseY))
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
// Screen.super.render
|
||||
for (Widget widget : this.renderables) {
|
||||
widget.render(pose, mouse_x, mouse_y, flag);
|
||||
for (widget in renderables) {
|
||||
widget.render(poseStack, mouseX, mouseY, partialTick)
|
||||
}
|
||||
// /Screen.super.render
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.disableDepthTest()
|
||||
MinecraftForge.EVENT_BUS.post(Foreground(this, poseStack, mouseX, mouseY))
|
||||
|
||||
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ContainerScreenEvent.Render.Foreground(this, pose, mouse_x, mouse_y));
|
||||
var itemstack = if (draggingItem.isEmpty) menu.carried else draggingItem
|
||||
|
||||
var itemstack = this.draggingItem.isEmpty() ? this.menu.getCarried() : this.draggingItem;
|
||||
if (!itemstack.isEmpty) {
|
||||
val i2 = if (draggingItem.isEmpty) 8 else 16
|
||||
var overrideCount: String? = null
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
int i2 = this.draggingItem.isEmpty() ? 8 : 16;
|
||||
String override_count = null;
|
||||
if (isQuickCrafting && quickCraftSlots.size > 1) {
|
||||
itemstack = itemstack.copy()
|
||||
itemstack.count = quickCraftingRemainder
|
||||
|
||||
if (this.isQuickCrafting && this.quickCraftSlots.size() > 1) {
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.setCount(this.quickCraftingRemainder);
|
||||
|
||||
if (itemstack.isEmpty()) {
|
||||
override_count = ChatFormatting.YELLOW + "0";
|
||||
if (itemstack.isEmpty) {
|
||||
overrideCount = ChatFormatting.YELLOW.toString() + "0"
|
||||
}
|
||||
}
|
||||
|
||||
this.renderFloatingItem(itemstack, mouse_x - render_x - 8, mouse_y - render_y - i2, override_count);
|
||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
renderFloatingItem(itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
}
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
// forge's hard limit tooltip Z position to 500 units
|
||||
// so if we have anything drawn above 500 units, lift it up
|
||||
if (depth > 500) {
|
||||
pose.pushPose();
|
||||
pose.translate(0, 0, depth - 500);
|
||||
if (depth > 500f) {
|
||||
poseStack.pushPose()
|
||||
poseStack.translate(0.0, 0.0, depth - 500.0)
|
||||
}
|
||||
|
||||
if (this.menu.getCarried().isEmpty()) {
|
||||
if (this.hoveredSlot != null && this.hoveredSlot.hasItem()) {
|
||||
this.renderTooltip(pose, this.hoveredSlot.getItem(), mouse_x, mouse_y);
|
||||
if (menu.carried.isEmpty) {
|
||||
val hoveredSlot = hoveredSlot
|
||||
|
||||
if (hoveredSlot != null && hoveredSlot.hasItem()) {
|
||||
this.renderTooltip(poseStack, hoveredSlot.item, mouseX, mouseY)
|
||||
} else {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
var panel = panels.get(i);
|
||||
|
||||
if (panel.renderTooltips(pose, mouse_x, mouse_y, flag)) {
|
||||
break;
|
||||
for (panel in panels) {
|
||||
if (panel.renderTooltips(poseStack, mouseXf, mouseYf, partialTick)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (depth > 500) {
|
||||
pose.popPose();
|
||||
if (depth > 500f) {
|
||||
poseStack.popPose()
|
||||
}
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableDepthTest()
|
||||
}
|
||||
|
||||
// AbstractContainerScreen
|
||||
public void recalculateQuickCraftRemaining() {
|
||||
ItemStack itemstack = this.menu.getCarried();
|
||||
|
||||
if (!itemstack.isEmpty() && this.isQuickCrafting) {
|
||||
if (this.quickCraftingType == 2) {
|
||||
this.quickCraftingRemainder = itemstack.getMaxStackSize();
|
||||
} else {
|
||||
this.quickCraftingRemainder = itemstack.getCount();
|
||||
|
||||
for(Slot slot : this.quickCraftSlots) {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
ItemStack itemstack2 = slot.getItem();
|
||||
int i = itemstack2.isEmpty() ? 0 : itemstack2.getCount();
|
||||
AbstractContainerMenu.getQuickCraftSlotCount(this.quickCraftSlots, this.quickCraftingType, itemstack1, i);
|
||||
int j = Math.min(itemstack1.getMaxStackSize(), slot.getMaxStackSize(itemstack1));
|
||||
if (itemstack1.getCount() > j) {
|
||||
itemstack1.setCount(j);
|
||||
}
|
||||
|
||||
this.quickCraftingRemainder -= itemstack1.getCount() - i;
|
||||
}
|
||||
|
||||
}
|
||||
override fun containerTick() {
|
||||
for (panel in panels) {
|
||||
panel.tick()
|
||||
}
|
||||
}
|
||||
|
||||
public void onSlotClicked(MatterySlot slot, int mouse_button) {
|
||||
InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(mouse_button);
|
||||
boolean flag = this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey);
|
||||
|
||||
long i = Util.getMillis();
|
||||
|
||||
this.doubleclick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == mouse_button;
|
||||
this.skipNextRelease = false;
|
||||
|
||||
if (mouse_button != 0 && mouse_button != 1 && !flag) {
|
||||
this.checkHotbarMouseClicked(mouse_button);
|
||||
} else if (!this.isQuickCrafting) {
|
||||
if (this.menu.getCarried().isEmpty()) {
|
||||
if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
|
||||
this.slotClicked(slot, slot.index, mouse_button, ClickType.CLONE);
|
||||
} else {
|
||||
boolean shift_click = (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 340) || InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 344));
|
||||
ClickType clicktype = ClickType.PICKUP;
|
||||
|
||||
if (shift_click) {
|
||||
this.lastQuickMoved = slot != null && slot.hasItem() ? slot.getItem().copy() : ItemStack.EMPTY;
|
||||
clicktype = ClickType.QUICK_MOVE;
|
||||
}
|
||||
|
||||
this.slotClicked(slot, slot.index, mouse_button, clicktype);
|
||||
}
|
||||
|
||||
this.skipNextRelease = true;
|
||||
} else {
|
||||
this.isQuickCrafting = true;
|
||||
this.quickCraftingButton = mouse_button;
|
||||
this.quickCraftSlots.clear();
|
||||
|
||||
if (mouse_button == 0) {
|
||||
this.quickCraftingType = 0;
|
||||
} else if (mouse_button == 1) {
|
||||
this.quickCraftingType = 1;
|
||||
} else if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
|
||||
this.quickCraftingType = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.lastClickSlot = slot;
|
||||
this.lastClickTime = i;
|
||||
this.lastClickButton = mouse_button;
|
||||
companion object {
|
||||
const val DEFAULT_FRAME_WIDTH = 18f * 9f + 16f
|
||||
const val DEFAULT_FRAME_HEIGHT = 100f
|
||||
const val INVENTORY_FRAME_WIDTH = DEFAULT_FRAME_WIDTH
|
||||
const val INVENTORY_FRAME_HEIGHT = 3f * 18f + 18f + 24f
|
||||
const val GAUGE_TOP_WITH_SLOT = 17f
|
||||
const val GAUGE_TOP_WITHOUT_SLOT = 26f
|
||||
const val SLOT_TOP_UNDER_GAUGE = 70f
|
||||
const val PROGRESS_ARROW_TOP = 42f
|
||||
const val PROGRESS_SLOT_TOP = 41f
|
||||
const val LEFT_MARGIN = 8f
|
||||
}
|
||||
|
||||
public void checkHotbarMouseClicked(int mouse_code) {
|
||||
if (this.hoveredSlot != null && this.menu.getCarried().isEmpty()) {
|
||||
if (this.minecraft.options.keySwapOffhand.matchesMouse(mouse_code)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 40, ClickType.SWAP);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (this.minecraft.options.keyHotbarSlots[i].matchesMouse(mouse_code)) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ClickType.SWAP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSlotMouseDragged(@Nonnull MatterySlot slot, int click_type) {
|
||||
ItemStack itemstack = this.menu.getCarried();
|
||||
|
||||
if (this.clickedSlot != null && this.minecraft.options.touchscreen().get()) {
|
||||
if (click_type == 0 || click_type == 1) {
|
||||
if (this.draggingItem.isEmpty()) {
|
||||
if (slot != this.clickedSlot && !this.clickedSlot.getItem().isEmpty()) {
|
||||
this.draggingItem = this.clickedSlot.getItem().copy();
|
||||
}
|
||||
} else if (this.draggingItem.getCount() > 1 && AbstractContainerMenu.canItemQuickReplace(slot, this.draggingItem, false)) {
|
||||
long i = Util.getMillis();
|
||||
if (this.quickdropSlot == slot) {
|
||||
if (i - this.quickdropTime > 500L) {
|
||||
this.slotClicked(this.clickedSlot, this.clickedSlot.index, 0, ClickType.PICKUP);
|
||||
this.slotClicked(slot, slot.index, 1, ClickType.PICKUP);
|
||||
this.slotClicked(this.clickedSlot, this.clickedSlot.index, 0, ClickType.PICKUP);
|
||||
this.quickdropTime = i + 750L;
|
||||
this.draggingItem.shrink(1);
|
||||
}
|
||||
} else {
|
||||
this.quickdropSlot = slot;
|
||||
this.quickdropTime = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.isQuickCrafting && !itemstack.isEmpty() && (itemstack.getCount() > this.quickCraftSlots.size() || this.quickCraftingType == 2) && AbstractContainerMenu.canItemQuickReplace(slot, itemstack, true) && slot.mayPlace(itemstack) && this.menu.canDragTo(slot)) {
|
||||
this.quickCraftSlots.add(slot);
|
||||
this.recalculateQuickCraftRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
public void onMouseReleasedSlot(@Nullable MatterySlot slot, double p_97812_, double p_97813_, int p_97814_, boolean outside) {
|
||||
int i = this.leftPos;
|
||||
int j = this.topPos;
|
||||
InputConstants.Key mouseKey = InputConstants.Type.MOUSE.getOrCreate(p_97814_);
|
||||
int k = outside ? -999 : slot != null ? slot.index : -1;
|
||||
|
||||
if (this.doubleclick && p_97814_ == 0 && slot != null && this.menu.canTakeItemForPickAll(ItemStack.EMPTY, slot)) {
|
||||
if (hasShiftDown()) {
|
||||
if (!this.lastQuickMoved.isEmpty()) {
|
||||
for(Slot slot2 : this.menu.slots) {
|
||||
if (slot2 != null && slot2.mayPickup(this.minecraft.player) && slot2.hasItem() && slot2.isSameInventory(slot) && AbstractContainerMenu.canItemQuickReplace(slot2, this.lastQuickMoved, true)) {
|
||||
this.slotClicked(slot2, slot2.index, p_97814_, ClickType.QUICK_MOVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.slotClicked(slot, k, p_97814_, ClickType.PICKUP_ALL);
|
||||
}
|
||||
|
||||
this.doubleclick = false;
|
||||
this.lastClickTime = 0L;
|
||||
} else {
|
||||
if (this.isQuickCrafting && this.quickCraftingButton != p_97814_) {
|
||||
this.isQuickCrafting = false;
|
||||
this.quickCraftSlots.clear();
|
||||
this.skipNextRelease = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.skipNextRelease) {
|
||||
this.skipNextRelease = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.clickedSlot != null && this.minecraft.options.touchscreen().get()) {
|
||||
if (p_97814_ == 0 || p_97814_ == 1) {
|
||||
if (this.draggingItem.isEmpty() && slot != this.clickedSlot) {
|
||||
this.draggingItem = this.clickedSlot.getItem();
|
||||
}
|
||||
|
||||
boolean flag2 = AbstractContainerMenu.canItemQuickReplace(slot, this.draggingItem, false);
|
||||
if (k != -1 && !this.draggingItem.isEmpty() && flag2) {
|
||||
this.slotClicked(this.clickedSlot, this.clickedSlot.index, p_97814_, ClickType.PICKUP);
|
||||
this.slotClicked(slot, k, 0, ClickType.PICKUP);
|
||||
if (this.menu.getCarried().isEmpty()) {
|
||||
this.snapbackItem = ItemStack.EMPTY;
|
||||
} else {
|
||||
this.slotClicked(this.clickedSlot, this.clickedSlot.index, p_97814_, ClickType.PICKUP);
|
||||
this.snapbackStartX = Mth.floor(p_97812_ - (double)i);
|
||||
this.snapbackStartY = Mth.floor(p_97813_ - (double)j);
|
||||
this.snapbackEnd = this.clickedSlot;
|
||||
this.snapbackItem = this.draggingItem;
|
||||
this.snapbackTime = Util.getMillis();
|
||||
}
|
||||
} else if (!this.draggingItem.isEmpty()) {
|
||||
this.snapbackStartX = Mth.floor(p_97812_ - (double)i);
|
||||
this.snapbackStartY = Mth.floor(p_97813_ - (double)j);
|
||||
this.snapbackEnd = this.clickedSlot;
|
||||
this.snapbackItem = this.draggingItem;
|
||||
this.snapbackTime = Util.getMillis();
|
||||
}
|
||||
|
||||
this.draggingItem = ItemStack.EMPTY;
|
||||
this.clickedSlot = null;
|
||||
}
|
||||
} else if (this.isQuickCrafting && !this.quickCraftSlots.isEmpty()) {
|
||||
this.slotClicked((Slot)null, -999, AbstractContainerMenu.getQuickcraftMask(0, this.quickCraftingType), ClickType.QUICK_CRAFT);
|
||||
|
||||
for(Slot slot1 : this.quickCraftSlots) {
|
||||
this.slotClicked(slot1, slot1.index, AbstractContainerMenu.getQuickcraftMask(1, this.quickCraftingType), ClickType.QUICK_CRAFT);
|
||||
}
|
||||
|
||||
this.slotClicked((Slot)null, -999, AbstractContainerMenu.getQuickcraftMask(2, this.quickCraftingType), ClickType.QUICK_CRAFT);
|
||||
} else if (!this.menu.getCarried().isEmpty()) {
|
||||
if (this.minecraft.options.keyPickItem.isActiveAndMatches(mouseKey)) {
|
||||
this.slotClicked(slot, k, p_97814_, ClickType.CLONE);
|
||||
} else {
|
||||
boolean flag1 = k != -999 && (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 340) || InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 344));
|
||||
|
||||
if (flag1) {
|
||||
this.lastQuickMoved = slot.hasItem() ? slot.getItem().copy() : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
this.slotClicked(slot, k, p_97814_, flag1 ? ClickType.QUICK_MOVE : ClickType.PICKUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.menu.getCarried().isEmpty()) {
|
||||
this.lastClickTime = 0L;
|
||||
}
|
||||
|
||||
this.isQuickCrafting = false;
|
||||
}
|
||||
|
||||
public void slotClicked(Slot p_97778_, int p_97779_, int p_97780_, ClickType p_97781_) {
|
||||
if (p_97778_ != null) {
|
||||
p_97779_ = p_97778_.index;
|
||||
}
|
||||
|
||||
this.minecraft.gameMode.handleInventoryMouseClick(this.menu.containerId, p_97779_, p_97780_, p_97781_, this.minecraft.player);
|
||||
}
|
||||
|
||||
protected boolean checkHotbarKeyPressed(int p_97806_, int p_97807_) {
|
||||
if (this.menu.getCarried().isEmpty() && this.hoveredSlot != null) {
|
||||
if (this.minecraft.options.keySwapOffhand.isActiveAndMatches(InputConstants.getKey(p_97806_, p_97807_))) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, 40, ClickType.SWAP);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (this.minecraft.options.keyHotbarSlots[i].isActiveAndMatches(InputConstants.getKey(p_97806_, p_97807_))) {
|
||||
this.slotClicked(this.hoveredSlot, this.hoveredSlot.index, i, ClickType.SWAP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void containerTick() {
|
||||
for (var panel : panels) {
|
||||
panel.tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -84,8 +84,8 @@ abstract class AbstractSlotPanel @JvmOverloads constructor(
|
||||
return screen.getTooltipFromItem(stack)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
renderSlotBackground(stack, mouse_x, mouse_y, flag)
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
renderSlotBackground(stack, mouseX, mouseY, partialTick)
|
||||
renderRegular(stack, getItemStack())
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ abstract class SquareButtonPanel(
|
||||
}
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (pressed) {
|
||||
PRESSED.render(stack, 0f, 0f, width, height)
|
||||
} else if (isHovered && !isDisabled) {
|
||||
@ -102,7 +102,7 @@ abstract class SquareButtonPanel(
|
||||
skinElement?.invoke()?.render(stack, 0f, 0f, width, height)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isDisabled) {
|
||||
if (!pressed) {
|
||||
minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f))
|
||||
@ -115,12 +115,12 @@ abstract class SquareButtonPanel(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isDisabled && pressed) {
|
||||
pressed = false
|
||||
|
||||
if (isHovered) {
|
||||
click(flag)
|
||||
click(button)
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,21 +221,21 @@ abstract class EnumSquareButtonPanel<T : Enum<T>>(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
check(!building) { "Still building this button!" }
|
||||
super.innerRender(stack, mouse_x, mouse_y, flag)
|
||||
super.innerRender(stack, mouseX, mouseY, partialTick)
|
||||
val pair = checkNotNull(enumMapping[prop.get()]) { "HOW" }
|
||||
pair.first.render(stack, 0f, 0f, width, height, pair.second)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
check(!building) { "Still building this button!" }
|
||||
return super.mouseClickedInner(mouse_x, mouse_y, mouse_click_type)
|
||||
return super.mouseClickedInner(x, y, button)
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
check(!building) { "Still building this button!" }
|
||||
return super.mouseReleasedInner(mouse_x, mouse_y, flag)
|
||||
return super.mouseReleasedInner(x, y, button)
|
||||
}
|
||||
|
||||
override fun click(clickButton: Int) {
|
||||
|
@ -23,7 +23,7 @@ open class CheckBoxPanel(
|
||||
) {
|
||||
open var checked = false
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (checked) {
|
||||
CHECKBOX_CHECKED.render(stack)
|
||||
} else {
|
||||
@ -31,7 +31,7 @@ open class CheckBoxPanel(
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
checked = !checked
|
||||
minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f))
|
||||
return true
|
||||
@ -71,8 +71,8 @@ open class CheckBoxInputPanel(
|
||||
get() = widget.value
|
||||
set(value) {}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
super.mouseClickedInner(mouse_x, mouse_y, mouse_click_type)
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
super.mouseClickedInner(x, y, button)
|
||||
widget.userInput(!checked)
|
||||
return true
|
||||
}
|
||||
|
@ -13,36 +13,25 @@ open class DraggableCanvasPanel @JvmOverloads constructor(
|
||||
screen, parent, x, y, width, height
|
||||
) {
|
||||
protected var dragging = false
|
||||
protected var lastMouseX = 0.0
|
||||
protected var lastMouseY = 0.0
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
dragging = true
|
||||
lastMouseX = mouse_x
|
||||
lastMouseY = mouse_y
|
||||
trapMouseInput = true
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
dragging = false
|
||||
trapMouseInput = false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseDraggedInner(
|
||||
mouse_x: Double,
|
||||
mouse_y: Double,
|
||||
flag: Int,
|
||||
drag_x: Double,
|
||||
drag_y: Double
|
||||
): Boolean {
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
if (dragging) {
|
||||
xOffset -= (lastMouseX - mouse_x).toFloat()
|
||||
yOffset -= (lastMouseY - mouse_y).toFloat()
|
||||
lastMouseX = mouse_x
|
||||
lastMouseY = mouse_y
|
||||
xOffset += xDelta.toFloat()
|
||||
yOffset += yDelta.toFloat()
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ open class EditBoxPanel(
|
||||
widget?.setFocus(new)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
super.mouseClickedInner(mouse_x, mouse_y, flag)
|
||||
override fun mouseClickedInner(x: Double, y: Double, flag: Int): Boolean {
|
||||
super.mouseClickedInner(x, y, flag)
|
||||
requestFocus()
|
||||
return true
|
||||
}
|
||||
|
@ -194,8 +194,8 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
isHovered = false
|
||||
}
|
||||
|
||||
open fun onHovered() {}
|
||||
open fun onUnHovered() {}
|
||||
protected open fun onHovered() {}
|
||||
protected open fun onUnHovered() {}
|
||||
|
||||
var isFocused = false
|
||||
set(value) {
|
||||
@ -244,20 +244,21 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun onParent(child: EditablePanel) {
|
||||
if (children.contains(child)) throw IllegalStateException("Already containing this child")
|
||||
if (children.contains(child)) throw IllegalStateException("Already containing $child")
|
||||
children.add(child)
|
||||
needsInvalidation = true
|
||||
updateVisible()
|
||||
}
|
||||
|
||||
private fun onUnParent(child: EditablePanel) {
|
||||
if (!children.contains(child)) throw IllegalStateException("Already not containing this child")
|
||||
children.remove(child)
|
||||
val indexOf = children.indexOf(child)
|
||||
if (indexOf == -1) throw IllegalStateException("Already not containing $child")
|
||||
children.removeAt(indexOf)
|
||||
needsInvalidation = true
|
||||
updateVisible()
|
||||
}
|
||||
|
||||
protected open fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {}
|
||||
protected open fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {}
|
||||
protected open fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean {
|
||||
return false
|
||||
}
|
||||
@ -266,7 +267,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return visible && visibleAsChildren
|
||||
}
|
||||
|
||||
fun render(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Float {
|
||||
fun render(poseStack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Float {
|
||||
if (!isVisible()) {
|
||||
return 0f
|
||||
}
|
||||
@ -285,10 +286,10 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
absoluteY = y
|
||||
} else {
|
||||
isHovered = parent.isHovered &&
|
||||
mouse_x >= absoluteX &&
|
||||
mouse_x < absoluteX + width &&
|
||||
mouse_y >= absoluteY &&
|
||||
mouse_y < absoluteY + height
|
||||
mouseX >= absoluteX &&
|
||||
mouseX < absoluteX + width &&
|
||||
mouseY >= absoluteY &&
|
||||
mouseY < absoluteY + height
|
||||
}
|
||||
|
||||
val scissor = this.scissor
|
||||
@ -304,10 +305,10 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
stack.pushPose()
|
||||
stack.translate(absoluteX.toDouble(), absoluteY.toDouble(), accumulatedDepth.toDouble())
|
||||
innerRender(stack, mouse_x, mouse_y, flag)
|
||||
stack.popPose()
|
||||
poseStack.pushPose()
|
||||
poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), accumulatedDepth.toDouble())
|
||||
innerRender(poseStack, mouseX, mouseY, partialTick)
|
||||
poseStack.popPose()
|
||||
|
||||
for (child in children) {
|
||||
if (child.isVisible()) {
|
||||
@ -316,7 +317,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
child.absoluteY = absoluteY + child.y + yOffset
|
||||
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
depth = max(depth, child.render(stack, mouse_x, mouse_y, flag))
|
||||
depth = max(depth, child.render(poseStack, mouseX, mouseY, partialTick))
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,11 +383,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun findRoot(): EditablePanel? {
|
||||
var parent = this.parent
|
||||
|
||||
if (parent == null) {
|
||||
return null
|
||||
}
|
||||
var parent: EditablePanel? = this.parent ?: return null
|
||||
|
||||
while (true) {
|
||||
val parent2 = parent!!.parent
|
||||
@ -665,9 +662,9 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return list
|
||||
}
|
||||
|
||||
operator fun get(int: Int): EditablePanel? {
|
||||
if (int < 0 || int >= children.size) return null
|
||||
return children[int]
|
||||
operator fun get(index: Int): EditablePanel? {
|
||||
if (index < 0 || index >= children.size) return null
|
||||
return children[index]
|
||||
}
|
||||
|
||||
fun isTrappingMouseInput(): Boolean {
|
||||
@ -684,27 +681,27 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseMoved(p_94758_: Double, p_94759_: Double) {
|
||||
override fun mouseMoved(x: Double, y: Double) {
|
||||
|
||||
}
|
||||
|
||||
protected open fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
protected open fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun withinBounds(mouse_x: Double, mouse_y: Double): Boolean {
|
||||
fun withinBounds(x: Double, y: Double): Boolean {
|
||||
val pos: ScreenPos = localToScreen()
|
||||
return pos.x <= mouse_x && pos.x + width > mouse_x && pos.y <= mouse_y && pos.y + height > mouse_y
|
||||
return pos.x <= x && pos.x + width > x && pos.y <= y && pos.y + height > y
|
||||
}
|
||||
|
||||
fun withinExtendedBounds(mouse_x: Double, mouse_y: Double): Boolean {
|
||||
fun withinExtendedBounds(x: Double, y: Double): Boolean {
|
||||
val pos: ScreenPos = localToScreen(boundingX, boundingY)
|
||||
return pos.x <= mouse_x && pos.x + boundingWidth > mouse_x && pos.y <= mouse_y && pos.y + boundingHeight > mouse_y
|
||||
return pos.x <= x && pos.x + boundingWidth > x && pos.y <= y && pos.y + boundingHeight > y
|
||||
}
|
||||
|
||||
fun killFocusForEverythingExcept(eclusion: EditablePanel) {
|
||||
fun killFocusForEverythingExcept(except: EditablePanel) {
|
||||
for (child in children) {
|
||||
if (child !== eclusion) {
|
||||
if (child !== except) {
|
||||
child.killFocusForEverythingExceptInner()
|
||||
}
|
||||
}
|
||||
@ -720,30 +717,30 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
final override fun mouseClicked(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (trapMouseInput) return mouseClickedInner(mouse_x, mouse_y, flag)
|
||||
if (trapMouseInput) return mouseClickedInner(x, y, button)
|
||||
|
||||
for (child in children) {
|
||||
if (child.mouseClickedChecked(mouse_x, mouse_y, flag)) {
|
||||
if (child.mouseClickedChecked(x, y, button)) {
|
||||
killFocusForEverythingExcept(child)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return mouseClickedInner(mouse_x, mouse_y, flag)
|
||||
return mouseClickedInner(x, y, button)
|
||||
}
|
||||
|
||||
fun mouseClickedChecked(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
fun mouseClickedChecked(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (isTrappingMouseInput() || withinBounds(mouse_x, mouse_y)) {
|
||||
if (isTrappingMouseInput() || withinBounds(x, y)) {
|
||||
if (acceptMouseInput && parent == null) screen.popup(this)
|
||||
return mouseClicked(mouse_x, mouse_y, flag)
|
||||
} else if (withinExtendedBounds(mouse_x, mouse_y)) {
|
||||
return mouseClicked(x, y, button)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in children) {
|
||||
if (child.mouseClickedChecked(mouse_x, mouse_y, flag)) {
|
||||
if (child.mouseClickedChecked(x, y, button)) {
|
||||
killFocusForEverythingExcept(child)
|
||||
return true
|
||||
}
|
||||
@ -757,32 +754,66 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
protected open fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseReleased(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
final override fun mouseReleased(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (trapMouseInput) return mouseReleasedInner(mouse_x, mouse_y, flag)
|
||||
if (trapMouseInput) return mouseReleasedInner(x, y, button)
|
||||
|
||||
for (child in children) {
|
||||
if (child.mouseReleasedChecked(mouse_x, mouse_y, flag)) {
|
||||
if (child.mouseReleasedChecked(x, y, button)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return mouseReleasedInner(mouse_x, mouse_y, flag)
|
||||
return mouseReleasedInner(x, y, button)
|
||||
}
|
||||
|
||||
fun mouseReleasedChecked(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
fun mouseReleasedChecked(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (isTrappingMouseInput() || withinBounds(mouse_x, mouse_y)) {
|
||||
return mouseReleased(mouse_x, mouse_y, flag)
|
||||
} else if (withinExtendedBounds(mouse_x, mouse_y)) {
|
||||
if (isTrappingMouseInput() || withinBounds(x, y)) {
|
||||
return mouseReleased(x, y, button)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in children) {
|
||||
if (child.mouseReleasedChecked(mouse_x, mouse_y, flag)) {
|
||||
if (child.mouseReleasedChecked(x, y, button)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (trapMouseInput) return mouseDraggedInner(x, y, button, xDelta, yDelta)
|
||||
|
||||
for (child in children) {
|
||||
if (child.mouseDraggedChecked(x, y, button, xDelta, yDelta)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return mouseDraggedInner(x, y, button, xDelta, yDelta)
|
||||
}
|
||||
|
||||
fun mouseDraggedChecked(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (isTrappingMouseInput() || withinBounds(x, y)) {
|
||||
return mouseDragged(x, y, button, xDelta, yDelta)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in children) {
|
||||
if (child.mouseDraggedChecked(x, y, button, xDelta, yDelta)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -792,38 +823,32 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
|
||||
protected open fun mouseDraggedInner(
|
||||
mouse_x: Double,
|
||||
mouse_y: Double,
|
||||
flag: Int,
|
||||
drag_x: Double,
|
||||
drag_y: Double
|
||||
): Boolean {
|
||||
protected open fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseDragged(mouse_x: Double, mouse_y: Double, flag: Int, drag_x: Double, drag_y: Double): Boolean {
|
||||
final override fun mouseScrolled(x: Double, y: Double, scroll: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (trapMouseInput) return mouseDraggedInner(mouse_x, mouse_y, flag, drag_x, drag_y)
|
||||
if (trapMouseInput) return mouseScrolledInner(x, y, scroll)
|
||||
|
||||
for (child in children) {
|
||||
if (child.mouseDraggedChecked(mouse_x, mouse_y, flag, drag_x, drag_y)) {
|
||||
if (child.mouseScrolledChecked(x, y, scroll)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return mouseDraggedInner(mouse_x, mouse_y, flag, drag_x, drag_y)
|
||||
return mouseScrolledInner(x, y, scroll)
|
||||
}
|
||||
|
||||
fun mouseDraggedChecked(mouse_x: Double, mouse_y: Double, flag: Int, drag_x: Double, drag_y: Double): Boolean {
|
||||
fun mouseScrolledChecked(x: Double, y: Double, scroll: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (isTrappingMouseInput() || withinBounds(mouse_x, mouse_y)) {
|
||||
return mouseDragged(mouse_x, mouse_y, flag, drag_x, drag_y)
|
||||
} else if (withinExtendedBounds(mouse_x, mouse_y)) {
|
||||
if (isTrappingMouseInput() || withinBounds(x, y)) {
|
||||
return mouseScrolled(x, y, scroll)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in children) {
|
||||
if (child.mouseDraggedChecked(mouse_x, mouse_y, flag, drag_x, drag_y)) {
|
||||
if (child.mouseScrolledChecked(x, y, scroll)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -832,53 +857,18 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
protected open fun mouseScrolledInner(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseScrolled(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (trapMouseInput) return mouseScrolledInner(mouse_x, mouse_y, scroll)
|
||||
|
||||
for (child in children) {
|
||||
if (child.mouseScrolledChecked(mouse_x, mouse_y, scroll)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return mouseScrolledInner(mouse_x, mouse_y, scroll)
|
||||
}
|
||||
|
||||
fun mouseScrolledChecked(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (isTrappingMouseInput() || withinBounds(mouse_x, mouse_y)) {
|
||||
return mouseScrolled(mouse_x, mouse_y, scroll)
|
||||
} else if (withinExtendedBounds(mouse_x, mouse_y)) {
|
||||
for (child in children) {
|
||||
if (child.mouseScrolledChecked(mouse_x, mouse_y, scroll)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun keyPressedInternal(p_94745_: Int, p_94746_: Int, p_94747_: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
final override fun keyPressed(p_94745_: Int, p_94746_: Int, p_94747_: Int): Boolean {
|
||||
final override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
if (!isVisible() || !acceptKeyboardInput) return false
|
||||
if (!focusedAsParent) return false
|
||||
|
||||
if (isFocused) return keyPressedInternal(p_94745_, p_94746_, p_94747_)
|
||||
if (isFocused) return keyPressedInternal(key, scancode, mods)
|
||||
|
||||
for (child in children) {
|
||||
if (child.keyPressed(p_94745_, p_94746_, p_94747_)) {
|
||||
if (child.keyPressed(key, scancode, mods)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -886,18 +876,18 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun keyReleasedInternal(p_94750_: Int, p_94751_: Int, p_94752_: Int): Boolean {
|
||||
protected open fun keyReleasedInternal(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
final override fun keyReleased(p_94750_: Int, p_94751_: Int, p_94752_: Int): Boolean {
|
||||
final override fun keyReleased(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
if (!isVisible() || !acceptKeyboardInput) return false
|
||||
if (!focusedAsParent) return false
|
||||
|
||||
if (isFocused) return keyReleasedInternal(p_94750_, p_94751_, p_94752_)
|
||||
if (isFocused) return keyReleasedInternal(key, scancode, mods)
|
||||
|
||||
for (child in children) {
|
||||
if (child.keyReleased(p_94750_, p_94751_, p_94752_)) {
|
||||
if (child.keyReleased(key, scancode, mods)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -905,18 +895,18 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun charTypedInternal(p_94732_: Char, p_94733_: Int): Boolean {
|
||||
protected open fun charTypedInternal(codepoint: Char, mods: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
final override fun charTyped(p_94732_: Char, p_94733_: Int): Boolean {
|
||||
final override fun charTyped(codepoint: Char, mods: Int): Boolean {
|
||||
if (!isVisible() || !acceptKeyboardInput) return false
|
||||
if (!focusedAsParent) return false
|
||||
|
||||
if (isFocused) return charTypedInternal(p_94732_, p_94733_)
|
||||
if (isFocused) return charTypedInternal(codepoint, mods)
|
||||
|
||||
for (child in children) {
|
||||
if (child.charTyped(p_94732_, p_94733_)) {
|
||||
if (child.charTyped(codepoint, mods)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -924,19 +914,16 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun changeFocus(p_94756_: Boolean): Boolean {
|
||||
return if (!isVisible()) false else super.changeFocus(p_94756_)
|
||||
override fun changeFocus(state: Boolean): Boolean {
|
||||
return if (!isVisible()) false else super.changeFocus(state)
|
||||
}
|
||||
|
||||
final override fun isMouseOver(
|
||||
mouse_x: Double,
|
||||
mouse_y: Double
|
||||
): Boolean { // called to check whenever we are hovering at this
|
||||
final override fun isMouseOver(x: Double, y: Double): Boolean { // called to check whenever we are hovering at this
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
if (isTrappingMouseInput()) return true
|
||||
|
||||
val pos = localToScreen()
|
||||
return mouse_x >= pos.x && mouse_x <= pos.x + width && mouse_y >= pos.y && mouse_y + height <= pos.y
|
||||
return x >= pos.x && x <= pos.x + width && y >= pos.y && y + height <= pos.y
|
||||
}
|
||||
|
||||
protected var tick = 0
|
||||
|
@ -19,7 +19,7 @@ open class FilterSlotPanel(
|
||||
return slot.get()
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (screen.menu.carried.isEmpty) {
|
||||
MenuNetworkChannel.sendToServer(ItemFilterSlotPacket(slot.networkID, ItemStack.EMPTY))
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ open class FramePanel(
|
||||
}
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (frameTabPosition == Position.TOP) {
|
||||
val width: Float
|
||||
val height: Float
|
||||
@ -114,7 +114,7 @@ open class FramePanel(
|
||||
onClose?.run()
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, flag: Int): Boolean {
|
||||
if (isActive) {
|
||||
return true
|
||||
}
|
||||
@ -199,56 +199,43 @@ open class FramePanel(
|
||||
}
|
||||
|
||||
protected var dragging = false
|
||||
protected var dragMouseX = 0.0
|
||||
protected var dragMouseY = 0.0
|
||||
|
||||
init {
|
||||
setDockPadding(PADDING, PADDING_TOP, PADDING, PADDING)
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
val (_, y1) = screenToLocal(mouse_x, mouse_y)
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
val (_, y1) = screenToLocal(x, y)
|
||||
|
||||
if (parent == null && y1 >= 0 && y1 <= 12) {
|
||||
trapMouseInput = true
|
||||
dragMouseX = mouse_x
|
||||
dragMouseY = mouse_y
|
||||
dragging = true
|
||||
return true
|
||||
}
|
||||
|
||||
return super.mouseClickedInner(mouse_x, mouse_y, flag)
|
||||
return super.mouseClickedInner(x, y, button)
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (dragging) {
|
||||
trapMouseInput = false
|
||||
dragging = false
|
||||
return true
|
||||
}
|
||||
|
||||
return super.mouseReleasedInner(mouse_x, mouse_y, flag)
|
||||
return super.mouseReleasedInner(x, y, button)
|
||||
}
|
||||
|
||||
override fun mouseDraggedInner(
|
||||
mouse_x: Double,
|
||||
mouse_y: Double,
|
||||
flag: Int,
|
||||
drag_x: Double,
|
||||
drag_y: Double
|
||||
): Boolean {
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
if (dragging) {
|
||||
val draggedX = mouse_x - dragMouseX
|
||||
val draggedY = mouse_y - dragMouseY
|
||||
dragMouseX = mouse_x
|
||||
dragMouseY = mouse_y
|
||||
setPos(x + draggedX, y + draggedY)
|
||||
this.x += xDelta.toFloat()
|
||||
this.y += yDelta.toFloat()
|
||||
}
|
||||
|
||||
return super.mouseDraggedInner(mouse_x, mouse_y, flag, drag_x, drag_y)
|
||||
return super.mouseDraggedInner(x, y, button, xDelta, yDelta)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
// background
|
||||
// RenderSystem.disableDepthTest();
|
||||
val bgWidth = width - 4
|
||||
|
@ -23,7 +23,7 @@ open class Label @JvmOverloads constructor(
|
||||
|
||||
var color = RGBAColor.SLATE_GRAY
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
font.draw(stack, text, 0f, 0f, color.toInt())
|
||||
}
|
||||
}
|
||||
|
@ -89,23 +89,27 @@ abstract class MinecraftWidgetPanel<T : AbstractWidget>(
|
||||
return instance
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
getOrCreateWidget().render(stack, mouse_x.toInt(), mouse_y.toInt(), flag)
|
||||
getOrCreateWidget().render(stack, mouseX.toInt(), mouseY.toInt(), partialTick)
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
}
|
||||
|
||||
override fun charTypedInternal(p_94732_: Char, p_94733_: Int) = getOrCreateWidget().charTyped(p_94732_, p_94733_)
|
||||
override fun keyPressedInternal(p_94745_: Int, p_94746_: Int, p_94747_: Int) = getOrCreateWidget().keyPressed(p_94745_, p_94746_, p_94747_)
|
||||
override fun keyReleasedInternal(p_94750_: Int, p_94751_: Int, p_94752_: Int) = getOrCreateWidget().keyReleased(p_94750_, p_94751_, p_94752_)
|
||||
override fun charTypedInternal(codepoint: Char, mods: Int) = getOrCreateWidget().charTyped(codepoint, mods)
|
||||
override fun keyPressedInternal(key: Int, scancode: Int, mods: Int) = getOrCreateWidget().keyPressed(
|
||||
key,
|
||||
scancode,
|
||||
mods
|
||||
)
|
||||
override fun keyReleasedInternal(key: Int, scancode: Int, mods: Int) = getOrCreateWidget().keyReleased(key, scancode, mods)
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
val (x1, y1) = screenToLocal(mouse_x, mouse_y)
|
||||
return getOrCreateWidget().mouseClicked(x1.toDouble(), y1.toDouble(), mouse_click_type)
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
val (x1, y1) = screenToLocal(x, y)
|
||||
return getOrCreateWidget().mouseClicked(x1.toDouble(), y1.toDouble(), button)
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
val (x1, y1) = screenToLocal(mouse_x, mouse_y)
|
||||
return getOrCreateWidget().mouseReleased(x1.toDouble(), y1.toDouble(), flag)
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
val (x1, y1) = screenToLocal(x, y)
|
||||
return getOrCreateWidget().mouseReleased(x1.toDouble(), y1.toDouble(), button)
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ open class ScrollBarPanel(screen: MatteryScreen<*>, parent: EditablePanel?, x: F
|
||||
var isScrolling = false
|
||||
protected set
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (isScrolling) {
|
||||
scroll_bar_button_press.render(stack, 0f, 0f)
|
||||
} else if (isHovered) {
|
||||
@ -26,14 +26,14 @@ open class ScrollBarPanel(screen: MatteryScreen<*>, parent: EditablePanel?, x: F
|
||||
|
||||
protected var lastMouseY = 0.0
|
||||
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, flag: Int): Boolean {
|
||||
isScrolling = true
|
||||
trapMouseInput = true
|
||||
lastMouseY = mouse_y
|
||||
lastMouseY = y
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (isScrolling) {
|
||||
isScrolling = false
|
||||
trapMouseInput = false
|
||||
@ -43,20 +43,20 @@ open class ScrollBarPanel(screen: MatteryScreen<*>, parent: EditablePanel?, x: F
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseScrolledInner(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
return this@ScrollBarPanel.mouseScrolledInner(mouse_x, mouse_y, scroll)
|
||||
override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
return this@ScrollBarPanel.mouseScrolledInner(x, y, scroll)
|
||||
}
|
||||
|
||||
override fun mouseDraggedInner(
|
||||
mouse_x: Double,
|
||||
mouse_y: Double,
|
||||
flag: Int,
|
||||
drag_x: Double,
|
||||
drag_y: Double
|
||||
x: Double,
|
||||
y: Double,
|
||||
button: Int,
|
||||
xDelta: Double,
|
||||
yDelta: Double
|
||||
): Boolean {
|
||||
if (isScrolling) {
|
||||
val diff = mouse_y - lastMouseY
|
||||
lastMouseY = mouse_y
|
||||
val diff = y - lastMouseY
|
||||
lastMouseY = y
|
||||
this@ScrollBarPanel.scroll = (scroll + diff / this@ScrollBarPanel.height).toFloat()
|
||||
updateScrollBarPosition()
|
||||
return true
|
||||
@ -125,13 +125,13 @@ open class ScrollBarPanel(screen: MatteryScreen<*>, parent: EditablePanel?, x: F
|
||||
}
|
||||
|
||||
// public is for emulating input from outside
|
||||
public override fun mouseScrolledInner(mouse_x: Double, mouse_y: Double, scroll: Double): Boolean {
|
||||
public override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean {
|
||||
this.scroll = (this.scroll - scroll * scrollMultiplier.get()).toFloat()
|
||||
updateScrollBarPosition()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
scroll_bar_body.render(stack, y = 2f, height = height - 4)
|
||||
scroll_bar_top.render(stack)
|
||||
scroll_bar_bottom.render(stack, y = height - 2)
|
||||
|
@ -21,24 +21,18 @@ class SlotPanel<T : MatterySlot>(
|
||||
width: Float = 18f,
|
||||
height: Float = 18f
|
||||
) : AbstractSlotPanel(screen, parent, x, y, width, height) {
|
||||
override fun mouseClickedInner(mouse_x: Double, mouse_y: Double, mouse_click_type: Int): Boolean {
|
||||
screen.onSlotClicked(slot, mouse_click_type)
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
screen.returnSlot = slot
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseDraggedInner(
|
||||
mouse_x: Double,
|
||||
mouse_y: Double,
|
||||
flag: Int,
|
||||
drag_x: Double,
|
||||
drag_y: Double
|
||||
): Boolean {
|
||||
screen.onSlotMouseDragged(slot, flag)
|
||||
override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
screen.returnSlot = slot
|
||||
return true
|
||||
}
|
||||
|
||||
override fun mouseReleasedInner(mouse_x: Double, mouse_y: Double, flag: Int): Boolean {
|
||||
screen.onMouseReleasedSlot(slot, mouse_x, mouse_y, flag, false)
|
||||
override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
screen.returnSlot = slot
|
||||
return true
|
||||
}
|
||||
|
||||
@ -46,8 +40,8 @@ class SlotPanel<T : MatterySlot>(
|
||||
return slot.item
|
||||
}
|
||||
|
||||
override fun innerRender(@Nonnull stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
renderSlotBackground(stack, mouse_x, mouse_y, flag)
|
||||
override fun innerRender(@Nonnull stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
renderSlotBackground(stack, mouseX, mouseY, partialTick)
|
||||
|
||||
var itemstack = slot.item
|
||||
val carried = screen.menu.carried
|
||||
|
@ -34,7 +34,7 @@ open class PowerGaugePanel @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
val height = this.height * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, y = this.height - height, height = height, winding = UVWindingOrder.U0_V1_U1_V0)
|
||||
@ -73,7 +73,7 @@ open class MatterGaugePanel @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
val height = this.height * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, y = this.height - height, height = height, winding = UVWindingOrder.U0_V1_U1_V0)
|
||||
@ -112,7 +112,7 @@ open class PatternGaugePanel @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
val height = this.height * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, y = this.height - height, height = height, winding = UVWindingOrder.U0_V1_U1_V0)
|
||||
@ -169,7 +169,7 @@ open class ProgressGaugePanel @JvmOverloads constructor(
|
||||
return tooltip
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (widget.isStuck() && tick % 40 <= 20) {
|
||||
RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f)
|
||||
}
|
||||
|
@ -3,17 +3,35 @@ public-f net.minecraft.client.gui.screens.Screen f_96539_ # title
|
||||
public net.minecraft.server.MinecraftServer f_129744_ # storageSource
|
||||
|
||||
# for accessing and setting from MatteryScreen class
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97738_ # isQuickCrafting
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType
|
||||
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169600_
|
||||
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169605_
|
||||
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169602_
|
||||
|
||||
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97732_ # menu
|
||||
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169604_ # playerInventoryTitle
|
||||
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved
|
||||
|
||||
# for overriding from MatteryScreen class
|
||||
# protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97744_ # findSlot (DD)Lnet/minecraft/world/inventory/Slot;
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97762_(I)V # checkHotbarMouseClicked
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97818_()V # recalculateQuickCraftRemaining
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97744_(DD)Lnet/minecraft/world/inventory/Slot; # findSlot
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97782_(Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem
|
||||
|
Loading…
Reference in New Issue
Block a user