diff --git a/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java b/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java index 9510e24..055adaa 100644 --- a/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java +++ b/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java @@ -26,6 +26,14 @@ import java.util.UUID; import java.util.concurrent.Callable; import java.util.function.Function; +/** + * Zontreck's ChestGUI Interface + *
+ * This was heavily inspired by some of the ChestGUI's seen in Spigot mods. + * The reason for creating this system is to rapidly prototype interfaces. This is meant to be a helper to add a GUI quickly and easily without all the mess and fuss of making a menu or a screen. This is meant to be a stepping stone, not a permanent replacement to a proper UI. + *
+ * This implementation is unlikely to ever change much, as it is just meant to accomplish the above task, and it does, successfully. + */ public class ChestGUI { private ItemStackHandler container = new ItemStackHandler((9*3)); @@ -104,9 +112,7 @@ public class ChestGUI { ItemStack remStack = new ItemStack(ModItems.CHESTGUI_REM.get(), 1); - ChestGUIButton rem = new ChestGUIButton(remStack, (stack)-> { - onRemove.run(stack); - }, new Vector2i(2, 3)); + ChestGUIButton rem = new ChestGUIButton(remStack, onRemove, new Vector2i(2, 3)); removeBtn = rem; @@ -117,9 +123,7 @@ public class ChestGUI { ItemStack resStack = new ItemStack(ModItems.CHESTGUI_RESET.get(), 1); - ChestGUIButton rem = new ChestGUIButton(resStack, (stack)-> { - onReset.run(stack); - }, new Vector2i(2, 4)); + ChestGUIButton rem = new ChestGUIButton(resStack, onReset, new Vector2i(2, 4)); resetBtn = rem; @@ -132,9 +136,7 @@ public class ChestGUI ItemStack remStack = new ItemStack(ModItems.CHESTGUI_ADD.get(), 1); - ChestGUIButton rem = new ChestGUIButton(remStack, (stack)-> { - onAdd.run(stack); - }, new Vector2i(2, 5)); + ChestGUIButton rem = new ChestGUIButton(remStack, onAdd, new Vector2i(2, 5)); addBtn = rem; diff --git a/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUIButton.java b/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUIButton.java index 17763d5..42ae498 100644 --- a/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUIButton.java +++ b/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUIButton.java @@ -29,12 +29,18 @@ public class ChestGUIButton private Vector2i position; private ItemStack built; + /** + * Sets the name of the ChestGUI Button (Item Name) + * @param name Name to set + * @return Button instance + */ public ChestGUIButton withName(String name) { this.name=name; return this; } + public ChestGUIButton(Item icon, String name, IChestGUIButtonCallback callback, Vector2i position) { this.icon = icon; diff --git a/src/main/java/dev/zontreck/libzontreck/chestgui/IChestGUIButtonCallback.java b/src/main/java/dev/zontreck/libzontreck/chestgui/IChestGUIButtonCallback.java index 77dbf10..a92753a 100644 --- a/src/main/java/dev/zontreck/libzontreck/chestgui/IChestGUIButtonCallback.java +++ b/src/main/java/dev/zontreck/libzontreck/chestgui/IChestGUIButtonCallback.java @@ -1,9 +1,18 @@ package dev.zontreck.libzontreck.chestgui; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.ItemStackHandler; +/** + * This should be used in place of Runnable for ChestGUI + */ @FunctionalInterface public interface IChestGUIButtonCallback { - void run(ItemStack stack); + /** + * A callback function that when invoked will pass the ChestGUI ItemStack + * @param stack A temporary itemstack that is used for the ChestGUI + * @param container The container object for manipulating other items when this is invoked + */ + void run(ItemStack stack, ItemStackHandler container); } diff --git a/src/main/java/dev/zontreck/libzontreck/commands/CreditsCommand.java b/src/main/java/dev/zontreck/libzontreck/commands/CreditsCommand.java index 9043fc6..9e90b73 100644 --- a/src/main/java/dev/zontreck/libzontreck/commands/CreditsCommand.java +++ b/src/main/java/dev/zontreck/libzontreck/commands/CreditsCommand.java @@ -35,7 +35,7 @@ public class CreditsCommand { int y = 0; for(CreditsEntry entry : HeadCache.CREDITS) { - gui = gui.withButton(new ChestGUIButton(entry.compile(), (stack)->{ + gui = gui.withButton(new ChestGUIButton(entry.compile(), (stack, container)->{ }, new Vector2i(x,y))); //LibZontreck.LOGGER.info("Add gui button : " + entry.name);