ICustomGui:

-Added IDs to custom GUI slots.
This commit is contained in:
Luis C.M committed 2023-03-18 03:04:46 -05:00
1 parent 2c012f2693
commit 586c451f06
7 files changed
+52 -19

No files matched your search

@@ -143,13 +143,25 @@ public class ScriptGui implements ICustomGui {
}
public IItemSlot addItemSlot(int x, int y) {
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(x, y);
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(this.getMaxId() + 1, x, y);
this.slots.add(slot);
return (IItemSlot)this.slots.get(this.slots.size() - 1);
}
public IItemSlot addItemSlot(int x, int y, IItemStack stack) {
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(x, y, stack);
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(this.getMaxId() + 1, x, y, stack);
this.slots.add(slot);
return (IItemSlot)this.slots.get(this.slots.size() - 1);
}
public IItemSlot addItemSlot(int id, int x, int y) {
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(id, x, y);
this.slots.add(slot);
return (IItemSlot)this.slots.get(this.slots.size() - 1);
}
public IItemSlot addItemSlot(int id, int x, int y, IItemStack stack) {
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(id, x, y, stack);
this.slots.add(slot);
return (IItemSlot)this.slots.get(this.slots.size() - 1);
}
@@ -230,6 +242,16 @@ public class ScriptGui implements ICustomGui {
return this.playerInvY;
}
private int getMaxId() {
int max = 0;
for (ICustomGuiComponent component : this.getComponents()) {
if (component.getID() >= max) {
max = component.getID();
}
}
return max;
}
public ICustomGui fromNBT(NBTTagCompound tag) {
this.id = tag.getInteger("id");
this.width = tag.getIntArray("size")[0];