aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-05-16 17:44:55 +0300
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-05-16 17:57:12 +0300
commit5f099b105c448d4685ffb96faa95b10c06c31f28 (patch)
treeffd69d41e6e3cc908db7cc8268c2fac22cdc45b7 /src/main
parent8b895e25e0b7a087616782f5b4d4ffa1e56c7688 (diff)
downloadLibGui-5f099b105c448d4685ffb96faa95b10c06c31f28.tar.gz
LibGui-5f099b105c448d4685ffb96faa95b10c06c31f28.tar.bz2
LibGui-5f099b105c448d4685ffb96faa95b10c06c31f28.zip
Delegate WItemSlot peer creation to an overrideable method
This allows users to tweak slot behaviour with custom slot classes :) (cherry picked from commit 3ecfadc3ab1ad336438a8079b64b0a2bdc72a5a7)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
index 7af7b29..c6f0282 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
@@ -111,7 +111,7 @@ public class WItemSlot extends WWidget {
for (int y = 0; y < slotsHigh; y++) {
for (int x = 0; x < slotsWide; x++) {
- ValidatedSlot slot = new ValidatedSlot(inventory, index, this.getAbsoluteX() + (x * 18), this.getAbsoluteY() + (y * 18));
+ ValidatedSlot slot = createSlotPeer(inventory, index, this.getAbsoluteX() + (x * 18), this.getAbsoluteY() + (y * 18));
slot.setModifiable(modifiable);
peers.add(slot);
c.addSlotPeer(slot);
@@ -119,6 +119,20 @@ public class WItemSlot extends WWidget {
}
}
}
+
+ /**
+ * Creates a slot peer for this slot widget.
+ *
+ * @param inventory the slot inventory
+ * @param index the index in the inventory
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @return the created slot instance
+ * @since 1.10.0
+ */
+ protected ValidatedSlot createSlotPeer(Inventory inventory, int index, int x, int y) {
+ return new ValidatedSlot(inventory, index, x, y);
+ }
@Environment(EnvType.CLIENT)
public void setBackgroundPainter(BackgroundPainter painter) {