aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java29
1 files changed, 28 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 4da52cc..76e72aa 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
@@ -88,6 +88,7 @@ public class WItemSlot extends WWidget {
private BackgroundPainter backgroundPainter = null;
@Nullable
private Icon icon = null;
+ private boolean iconOnlyPaintedForEmptySlots = true;
private Inventory inventory;
private int startIndex = 0;
private int slotsWide = 1;
@@ -251,6 +252,32 @@ public class WItemSlot extends WWidget {
}
/**
+ * Checks whether icons should be rendered when the first slot of this widget
+ * contains an item.
+ *
+ * <p>This property is {@code true} by default.
+ *
+ * @return {@code true} if the icon should always be painted, {@code false} otherwise
+ * @since 9.1.0
+ */
+ public boolean isIconOnlyPaintedForEmptySlots() {
+ return iconOnlyPaintedForEmptySlots;
+ }
+
+ /**
+ * Sets whether icons should be rendered when the first slot of this widget
+ * contains an item.
+ *
+ * @param iconOnlyPaintedForEmptySlots {@code true} if the icon should always be painted, {@code false} otherwise
+ * @return this item slot
+ * @since 9.1.0
+ */
+ public WItemSlot setIconOnlyPaintedForEmptySlots(boolean iconOnlyPaintedForEmptySlots) {
+ this.iconOnlyPaintedForEmptySlots = iconOnlyPaintedForEmptySlots;
+ return this;
+ }
+
+ /**
* Returns true if the contents of this {@code WItemSlot} can be modified by players.
*
* @return true if items can be inserted into or taken from this slot widget, false otherwise
@@ -487,7 +514,7 @@ public class WItemSlot extends WWidget {
backgroundPainter.paintBackground(context, x, y, this);
}
- if (icon != null) {
+ if (icon != null && (iconOnlyPaintedForEmptySlots || inventory.getStack(startIndex).isEmpty())) {
icon.paint(context, x + 1, y + 1, 16);
}
}