Get the menu working, button click broken
This commit is contained in:
parent
848b6f495b
commit
01a6f1ddc7
8 changed files with 86 additions and 24 deletions
|
@ -2,6 +2,7 @@ package dev.zontreck.libzontreck.menus;
|
|||
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUI;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIButton;
|
||||
import dev.zontreck.libzontreck.dynamicchest.ChestGUIReadOnlyStackHandler;
|
||||
import dev.zontreck.libzontreck.dynamicchest.ReadOnlyItemStackHandler;
|
||||
import dev.zontreck.libzontreck.types.ModMenuTypes;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2i;
|
||||
|
@ -20,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
public class ChestGUIMenu extends AbstractContainerMenu
|
||||
{
|
||||
public final ChestGUI gui;
|
||||
public final ItemStackHandler slots;
|
||||
|
||||
public ChestGUIMenu(int id, Inventory playerInv, FriendlyByteBuf buf)
|
||||
{
|
||||
|
@ -32,7 +34,8 @@ public class ChestGUIMenu extends AbstractContainerMenu
|
|||
|
||||
this.gui = gui;
|
||||
|
||||
if(gui == null)return;
|
||||
slots = new ChestGUIReadOnlyStackHandler(gui);
|
||||
|
||||
|
||||
int slotSize = 18;
|
||||
int startX = 15;
|
||||
|
@ -42,12 +45,7 @@ public class ChestGUIMenu extends AbstractContainerMenu
|
|||
{
|
||||
for(int column=0;column<9;column++)
|
||||
{
|
||||
Vector2i slot = new Vector2i(row, column);
|
||||
ChestGUIButton btn = gui.getSlot(slot);
|
||||
if(gui.hasSlot(slot))
|
||||
{
|
||||
addSlot(new SlotItemHandler(new ReadOnlyItemStackHandler(btn.buildIconStack(), btn::clicked), row*9 + column, startX + column * slotSize, startY + row * slotSize));
|
||||
}
|
||||
addSlot(new SlotItemHandler(slots, row*9 + column, startX + column * slotSize, startY + row * slotSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ public class ChestGUIScreen extends AbstractContainerScreen<ChestGUIMenu> {
|
|||
|
||||
this.imageWidth = 191;
|
||||
this.imageHeight = 82;
|
||||
|
||||
this.titleLabelX = 32;
|
||||
this.titleLabelY =5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,6 +61,6 @@ public class ChestGUIScreen extends AbstractContainerScreen<ChestGUIMenu> {
|
|||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY) {
|
||||
pGuiGraphics.drawString(font, title.getString(), 32, 5, 0x000000);
|
||||
pGuiGraphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY, 4210752, false);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue