aboutsummaryrefslogtreecommitdiff
path: root/src
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:44:55 +0300
commit3ecfadc3ab1ad336438a8079b64b0a2bdc72a5a7 (patch)
tree9f57dafd1796d90c7e455440490143454cf83914 /src
parent16eb60403814d787f3ef5512ecbb51b7001efd71 (diff)
downloadLibGui-3ecfadc3ab1ad336438a8079b64b0a2bdc72a5a7.tar.gz
LibGui-3ecfadc3ab1ad336438a8079b64b0a2bdc72a5a7.tar.bz2
LibGui-3ecfadc3ab1ad336438a8079b64b0a2bdc72a5a7.zip
Delegate WItemSlot peer creation to an overrideable method
This allows users to tweak slot behaviour with custom slot classes :)
Diffstat (limited to 'src')
-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..8d0cf94 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.11.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) {