aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java3
2 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java
index 16efebd..6d1475c 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java
@@ -14,11 +14,17 @@ import java.util.Objects;
import java.util.function.Predicate;
public class ValidatedSlot extends Slot {
+ /**
+ * The default {@linkplain #setFilter(Predicate) item filter} that allows all items.
+ *
+ * @since 5.1.1
+ */
+ public static final Predicate<ItemStack> DEFAULT_ITEM_FILTER = stack -> true;
private static final VisualLogger LOGGER = new VisualLogger(ValidatedSlot.class);
private final int slotNumber;
private boolean insertingAllowed = true;
private boolean takingAllowed = true;
- private Predicate<ItemStack> filter;
+ private Predicate<ItemStack> filter = DEFAULT_ITEM_FILTER;
protected final Multimap<WItemSlot, WItemSlot.ChangeListener> listeners = HashMultimap.create();
private boolean visible = true;
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 a05b364..288c922 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
@@ -67,7 +67,6 @@ import java.util.function.Predicate;
*/
public class WItemSlot extends WWidget {
private static final VisualLogger LOGGER = new VisualLogger(WItemSlot.class);
- private static final Predicate<ItemStack> DEFAULT_FILTER = stack -> true;
private final List<ValidatedSlot> peers = new ArrayList<>();
@Nullable
@Environment(EnvType.CLIENT)
@@ -83,7 +82,7 @@ public class WItemSlot extends WWidget {
private boolean takingAllowed = true;
private int focusedSlot = -1;
private int hoveredSlot = -1;
- private Predicate<ItemStack> filter = DEFAULT_FILTER;
+ private Predicate<ItemStack> filter = ValidatedSlot.DEFAULT_ITEM_FILTER;
private final Set<ChangeListener> listeners = new HashSet<>();
public WItemSlot(Inventory inventory, int startIndex, int slotsWide, int slotsHigh, boolean big) {