Moderately working panels
This commit is contained in:
parent
38495e59c1
commit
483b26449b
@ -5,7 +5,7 @@ import net.minecraft.network.chat.Component;
|
|||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import ru.dbotthepony.mc.otm.menu.MatterDecomposerMenu;
|
import ru.dbotthepony.mc.otm.menu.MatterDecomposerMenu;
|
||||||
|
|
||||||
public class MatterDecomposerScreen extends PoweredMachineScreen<MatterDecomposerMenu> {
|
public class MatterDecomposerScreen extends MatteryScreen<MatterDecomposerMenu> {
|
||||||
public MatterDecomposerScreen(MatterDecomposerMenu p_97741_, Inventory p_97742_, Component p_97743_) {
|
public MatterDecomposerScreen(MatterDecomposerMenu p_97741_, Inventory p_97742_, Component p_97743_) {
|
||||||
super(p_97741_, p_97742_, p_97743_);
|
super(p_97741_, p_97742_, p_97743_);
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,7 @@ import net.minecraft.Util;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.components.Widget;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@ -23,10 +21,7 @@ import net.minecraft.world.inventory.Slot;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
||||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu;
|
import ru.dbotthepony.mc.otm.menu.MatteryMenu;
|
||||||
import ru.dbotthepony.mc.otm.menu.slot.BatterySlot;
|
|
||||||
import ru.dbotthepony.mc.otm.menu.slot.MatterySlot;
|
import ru.dbotthepony.mc.otm.menu.slot.MatterySlot;
|
||||||
import ru.dbotthepony.mc.otm.menu.slot.MachineOutputSlot;
|
|
||||||
import ru.dbotthepony.mc.otm.menu.slot.MatterContainerInputSlot;
|
|
||||||
import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget;
|
import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget;
|
||||||
import ru.dbotthepony.mc.otm.screen.panels.EditablePanel;
|
import ru.dbotthepony.mc.otm.screen.panels.EditablePanel;
|
||||||
import ru.dbotthepony.mc.otm.screen.panels.FramePanel;
|
import ru.dbotthepony.mc.otm.screen.panels.FramePanel;
|
||||||
@ -34,7 +29,6 @@ import ru.dbotthepony.mc.otm.screen.panels.SlotPanel;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.awt.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -50,7 +44,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @param <T> type of menu, which extends MatteryMenu
|
* @param <T> type of menu, which extends MatteryMenu
|
||||||
*/
|
*/
|
||||||
public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScreen<T> {
|
public abstract class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScreen<T> {
|
||||||
protected static final ResourceLocation CONTAINER_BASE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/generic_machine.png");
|
protected static final ResourceLocation CONTAINER_BASE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/generic_machine.png");
|
||||||
public static final ResourceLocation WIDGETS = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets.png");
|
public static final ResourceLocation WIDGETS = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets.png");
|
||||||
|
|
||||||
@ -108,8 +102,9 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
return CONTAINER_BASE;
|
return CONTAINER_BASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayList<EditablePanel> panels = new ArrayList<>();
|
protected final ArrayList<EditablePanel> panels = new ArrayList<>();
|
||||||
public FramePanel inventory;
|
public FramePanel inventory_frame;
|
||||||
|
public FramePanel main_frame;
|
||||||
|
|
||||||
public MatteryScreen(T menu, Inventory inventory, Component title) {
|
public MatteryScreen(T menu, Inventory inventory, Component title) {
|
||||||
super(menu, inventory, title);
|
super(menu, inventory, title);
|
||||||
@ -117,19 +112,36 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
playerInventoryTitle = inventory.getDisplayName();
|
playerInventoryTitle = inventory.getDisplayName();
|
||||||
|
|
||||||
if (menu.inventory_slots.size() != 0) {
|
if (menu.inventory_slots.size() != 0) {
|
||||||
this.inventory = new FramePanel(this, null, 0, 0, 18 * 9 + 16, 3 * 18 + 18 + 24, inventory.getDisplayName());
|
inventory_frame = new FramePanel(this, null, 0, 0, 18 * 9 + 16, 3 * 18 + 18 + 24, inventory.getDisplayName());
|
||||||
panels.add(this.inventory);
|
panels.add(inventory_frame);
|
||||||
|
|
||||||
for (var slot : menu.inventory_slots) {
|
for (var slot : menu.inventory_slots) {
|
||||||
new SlotPanel<>(
|
new SlotPanel<>(
|
||||||
this,
|
this,
|
||||||
this.inventory,
|
inventory_frame,
|
||||||
slot.x,
|
slot.x,
|
||||||
slot.y,
|
slot.y,
|
||||||
18, 18,
|
18, 18,
|
||||||
slot);
|
slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main_frame = makeMainFrame();
|
||||||
|
|
||||||
|
if (main_frame != null)
|
||||||
|
addPanel(main_frame);
|
||||||
|
|
||||||
|
movePanels();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPanel(EditablePanel panel) {
|
||||||
|
if (!panels.contains(panel))
|
||||||
|
panels.add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected FramePanel makeMainFrame() {
|
||||||
|
return new FramePanel(this, null, 0, 0, 200, 100, getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemRenderer getItemRenderer() {
|
public ItemRenderer getItemRenderer() {
|
||||||
@ -140,9 +152,56 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 (inventory_frame != null) {
|
||||||
|
top -= inventory_frame.getHeight() / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (main_frame != null) {
|
||||||
|
main_frame.setPos(width / 2 - main_frame.getWidth() / 2, top);
|
||||||
|
top += main_frame.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventory_frame != null) {
|
||||||
|
inventory_frame.setPos(width / 2 - inventory_frame.getWidth() / 2, top);
|
||||||
|
top += inventory_frame.getHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
movePanels();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double p_97748_, double p_97749_, int p_97750_) {
|
public boolean mouseClicked(double p_97748_, double p_97749_, int p_97750_) {
|
||||||
for (var panel : panels) {
|
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||||
|
var panel = panels.get(i);
|
||||||
|
|
||||||
if (panel.mouseClickedChecked(p_97748_, p_97749_, p_97750_)) {
|
if (panel.mouseClickedChecked(p_97748_, p_97749_, p_97750_)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -155,7 +214,9 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(double p_97752_, double p_97753_, int p_97754_, double p_97755_, double p_97756_) {
|
public boolean mouseDragged(double p_97752_, double p_97753_, int p_97754_, double p_97755_, double p_97756_) {
|
||||||
for (var panel : panels) {
|
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||||
|
var panel = panels.get(i);
|
||||||
|
|
||||||
if (panel.mouseDraggedChecked(p_97752_, p_97753_, p_97754_, p_97755_, p_97756_)) {
|
if (panel.mouseDraggedChecked(p_97752_, p_97753_, p_97754_, p_97755_, p_97756_)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -166,7 +227,9 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) {
|
public boolean mouseReleased(double p_97812_, double p_97813_, int p_97814_) {
|
||||||
for (var panel : panels) {
|
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||||
|
var panel = panels.get(i);
|
||||||
|
|
||||||
if (panel.mouseReleasedChecked(p_97812_, p_97813_, p_97814_)) {
|
if (panel.mouseReleasedChecked(p_97812_, p_97813_, p_97814_)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -180,7 +243,9 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double p_94686_, double p_94687_, double p_94688_) {
|
public boolean mouseScrolled(double p_94686_, double p_94687_, double p_94688_) {
|
||||||
for (var panel : panels) {
|
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||||
|
var panel = panels.get(i);
|
||||||
|
|
||||||
if (panel.mouseScrolledChecked(p_94686_, p_94687_, p_94688_)) {
|
if (panel.mouseScrolledChecked(p_94686_, p_94687_, p_94688_)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -193,7 +258,9 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) {
|
public boolean keyPressed(int p_97765_, int p_97766_, int p_97767_) {
|
||||||
InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_);
|
InputConstants.Key mouseKey = InputConstants.getKey(p_97765_, p_97766_);
|
||||||
|
|
||||||
for (var panel : panels) {
|
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||||
|
var panel = panels.get(i);
|
||||||
|
|
||||||
if (panel.keyPressed(p_97765_, p_97766_, p_97767_)) {
|
if (panel.keyPressed(p_97765_, p_97766_, p_97767_)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -266,8 +333,23 @@ public class MatteryScreen<T extends MatteryMenu> extends AbstractContainerScree
|
|||||||
widget.renderBackground(this, pose, leftPos, topPos, mouse_x, mouse_y);
|
widget.renderBackground(this, pose, leftPos, topPos, mouse_x, mouse_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hovered = false;
|
||||||
|
|
||||||
|
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||||
|
var panel = panels.get(i);
|
||||||
|
|
||||||
|
if (hovered) {
|
||||||
|
panel.unsetHover();
|
||||||
|
} else if (panel.tickHover(mouse_x, mouse_y)) {
|
||||||
|
hovered = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float depth = 0;
|
||||||
|
|
||||||
for (var panel : panels) {
|
for (var panel : panels) {
|
||||||
panel.render(pose, mouse_x, mouse_y, flag);
|
panel.set3DDepth(depth);
|
||||||
|
depth = Math.max(depth, panel.render(pose, mouse_x, mouse_y, flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, pose, mouse_x, mouse_y));
|
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, pose, mouse_x, mouse_y));
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package ru.dbotthepony.mc.otm.screen;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.FormattedText;
|
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
|
||||||
import ru.dbotthepony.mc.otm.menu.PoweredMatteryMenu;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PoweredMachineScreen<T extends PoweredMatteryMenu> extends MatteryScreen<T> {
|
|
||||||
public PoweredMachineScreen(T p_97741_, Inventory p_97742_, Component p_97743_) {
|
|
||||||
super(p_97741_, p_97742_, p_97743_);
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ import javax.annotation.Nullable;
|
|||||||
public class EditBoxPanel extends MinecraftWidgetPanel<EditBox> {
|
public class EditBoxPanel extends MinecraftWidgetPanel<EditBox> {
|
||||||
public EditBoxPanel(@Nonnull MatteryScreen<?> screen, @Nullable EditablePanel parent, float x, float y, float width, float height, Component component) {
|
public EditBoxPanel(@Nonnull MatteryScreen<?> screen, @Nullable EditablePanel parent, float x, float y, float width, float height, Component component) {
|
||||||
super(screen, parent, x, y, width, height, (panel) -> {
|
super(screen, parent, x, y, width, height, (panel) -> {
|
||||||
return new EditBox(screen.getFont(), (int) panel.getRenderX(), (int) panel.getRenderY(), (int) panel.getWidth(), (int) panel.getHeight(), component);
|
return new EditBox(screen.getFont(), 0, 0, (int) panel.getWidth(), (int) panel.getHeight(), component);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,26 @@ public class EditablePanel implements GuiEventListener {
|
|||||||
protected float parent_x;
|
protected float parent_x;
|
||||||
protected float parent_y;
|
protected float parent_y;
|
||||||
|
|
||||||
|
protected float accumulated_depth = 0;
|
||||||
|
|
||||||
|
public float getMost3DHeight() {
|
||||||
|
var depth = accumulated_depth;
|
||||||
|
|
||||||
|
for (var child : children) {
|
||||||
|
depth = Math.max(child.getMost3DHeight(), depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void accumulate3DHeight(float value) {
|
||||||
|
accumulated_depth += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set3DDepth(float value) {
|
||||||
|
accumulated_depth = value;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean needs_invalidation = false;
|
private boolean needs_invalidation = false;
|
||||||
|
|
||||||
private final ArrayList<EditablePanel> children = new ArrayList<>();
|
private final ArrayList<EditablePanel> children = new ArrayList<>();
|
||||||
@ -89,10 +109,12 @@ public class EditablePanel implements GuiEventListener {
|
|||||||
* @param mouse_x
|
* @param mouse_x
|
||||||
* @param mouse_y
|
* @param mouse_y
|
||||||
* @param flag
|
* @param flag
|
||||||
|
*
|
||||||
|
* @return float representing the most high depth
|
||||||
*/
|
*/
|
||||||
public void render(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
public float render(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
||||||
if (!getVisible()) {
|
if (!getVisible()) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needs_invalidation) {
|
if (needs_invalidation) {
|
||||||
@ -104,21 +126,36 @@ public class EditablePanel implements GuiEventListener {
|
|||||||
parent_x = x;
|
parent_x = x;
|
||||||
parent_y = y;
|
parent_y = y;
|
||||||
|
|
||||||
is_hovered = mouse_x >= x && mouse_x <= x + width && mouse_y >= y && mouse_y <= y + height;
|
|
||||||
} else {
|
} else {
|
||||||
is_hovered = parent.is_hovered && mouse_x >= parent_x && mouse_x <= parent_x + width && mouse_y >= parent_y && mouse_y <= parent_y + height;
|
is_hovered = parent.is_hovered && mouse_x >= parent_x && mouse_x <= parent_x + width && mouse_y >= parent_y && mouse_y <= parent_y + height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stack.pushPose();
|
||||||
|
stack.translate(parent_x, parent_y, accumulated_depth);
|
||||||
innerRender(stack, mouse_x, mouse_y, flag);
|
innerRender(stack, mouse_x, mouse_y, flag);
|
||||||
|
stack.popPose();
|
||||||
|
|
||||||
|
var most_depth = accumulated_depth;
|
||||||
|
|
||||||
for (var child : children) {
|
for (var child : children) {
|
||||||
if (child.getVisible()) {
|
if (child.getVisible()) {
|
||||||
|
child.accumulated_depth = accumulated_depth + 1;
|
||||||
child.parent_x = parent_x + child.x;
|
child.parent_x = parent_x + child.x;
|
||||||
child.parent_y = parent_y + child.y;
|
child.parent_y = parent_y + child.y;
|
||||||
|
|
||||||
child.render(stack, mouse_x, mouse_y, flag);
|
most_depth = Math.max(most_depth, child.render(stack, mouse_x, mouse_y, flag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return most_depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean tickHover(float mouse_x, float mouse_y) {
|
||||||
|
return is_hovered = mouse_x >= x && mouse_y >= y && mouse_x <= x + width && mouse_y <= y + height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unsetHover() {
|
||||||
|
is_hovered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -625,6 +662,9 @@ public class EditablePanel implements GuiEventListener {
|
|||||||
var pos = localToScreen();
|
var pos = localToScreen();
|
||||||
|
|
||||||
if (getIgnoreMouseEventBoundaries() || pos.x <= mouse_x && pos.x + width >= mouse_x && pos.y <= mouse_y && pos.y + height >= mouse_y) {
|
if (getIgnoreMouseEventBoundaries() || pos.x <= mouse_x && pos.x + width >= mouse_x && pos.y <= mouse_y && pos.y + height >= mouse_y) {
|
||||||
|
if (getMouseInputEnabled() && parent == null)
|
||||||
|
screen.popup(this);
|
||||||
|
|
||||||
mouseClicked(mouse_x, mouse_y, flag);
|
mouseClicked(mouse_x, mouse_y, flag);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.dbotthepony.mc.otm.screen.panels;
|
package ru.dbotthepony.mc.otm.screen.panels;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
@ -68,10 +69,12 @@ public class FramePanel extends EditablePanel implements NarratableEntry {
|
|||||||
@Override
|
@Override
|
||||||
protected void innerRender(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
protected void innerRender(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
||||||
// background
|
// background
|
||||||
RenderHelper.drawWindowBackground(stack, parent_x, parent_y, getWidth(), getHeight());
|
// RenderSystem.disableDepthTest();
|
||||||
|
RenderHelper.drawWindowBackground(stack, 0, 0, getWidth(), getHeight());
|
||||||
|
// RenderSystem.enableDepthTest();
|
||||||
|
|
||||||
// title
|
// title
|
||||||
screen.getFont().draw(stack, title, parent_x + 4, parent_y + 5, 4210752);
|
screen.getFont().draw(stack, title, 8, 5, 4210752);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,9 +57,6 @@ public class MinecraftWidgetPanel<T extends AbstractWidget> extends EditablePane
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void innerRender(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
protected void innerRender(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
||||||
widget.x = (int) parent_x;
|
|
||||||
widget.y = (int) parent_y;
|
|
||||||
|
|
||||||
widget.render(stack, (int) mouse_x, (int) mouse_y, flag);
|
widget.render(stack, (int) mouse_x, (int) mouse_y, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class SlotPanel<T extends MatterySlot> extends EditablePanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void renderSlotBackground(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
protected void renderSlotBackground(PoseStack stack, float mouse_x, float mouse_y, float flag) {
|
||||||
RenderHelper.drawRegularSlot(stack, parent_x, parent_y);
|
RenderHelper.drawRegularSlot(stack, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,7 +87,7 @@ public class SlotPanel<T extends MatterySlot> extends EditablePanel {
|
|||||||
|
|
||||||
if (drag_hit) {
|
if (drag_hit) {
|
||||||
RenderHelper.setDrawColor(SLOT_HIGHLIGHT_DRAG);
|
RenderHelper.setDrawColor(SLOT_HIGHLIGHT_DRAG);
|
||||||
RenderHelper.drawRect(stack, parent_x + 1, parent_y + 1, getWidth() - 1, getHeight() - 1);
|
RenderHelper.drawRect(stack, 1, 1, getWidth() - 1, getHeight() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
@ -102,9 +102,12 @@ public class SlotPanel<T extends MatterySlot> extends EditablePanel {
|
|||||||
// Thanks Mojang
|
// Thanks Mojang
|
||||||
// Very cool
|
// Very cool
|
||||||
// (for int x, int y, which are then cast into doubles anyway)
|
// (for int x, int y, which are then cast into doubles anyway)
|
||||||
screen.getItemRenderer().renderAndDecorateItem(Minecraft.getInstance().player, itemstack, 0, 0, 10 /* Z Pos ? */);
|
screen.getItemRenderer().blitOffset = accumulated_depth;
|
||||||
|
screen.getItemRenderer().renderAndDecorateItem(Minecraft.getInstance().player, itemstack, 0, 0, (int) (parent_x + parent_y * 1000) /* some kind of indexing ? */);
|
||||||
screen.getItemRenderer().renderGuiItemDecorations(screen.getFont(), itemstack, 0, 0, count_override);
|
screen.getItemRenderer().renderGuiItemDecorations(screen.getFont(), itemstack, 0, 0, count_override);
|
||||||
|
|
||||||
|
accumulate3DHeight(300);
|
||||||
|
|
||||||
system_stack.popPose();
|
system_stack.popPose();
|
||||||
RenderSystem.applyModelViewMatrix();
|
RenderSystem.applyModelViewMatrix();
|
||||||
}
|
}
|
||||||
@ -112,10 +115,11 @@ public class SlotPanel<T extends MatterySlot> extends EditablePanel {
|
|||||||
if (is_hovered) {
|
if (is_hovered) {
|
||||||
screen.hoveredSlot = slot;
|
screen.hoveredSlot = slot;
|
||||||
|
|
||||||
RenderSystem.disableDepthTest();
|
stack.pushPose();
|
||||||
|
stack.translate(0, 0, 300);
|
||||||
RenderHelper.setDrawColor(SLOT_HIGHLIGHT);
|
RenderHelper.setDrawColor(SLOT_HIGHLIGHT);
|
||||||
RenderHelper.drawRect(stack, parent_x + 1, parent_y + 1, getWidth() - 1, getHeight() - 1);
|
RenderHelper.drawRect(stack, 1, 1, getWidth() - 1, getHeight() - 1);
|
||||||
RenderSystem.enableDepthTest();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user