From 484dbb3e78c2d22ba129dbecef49a4314e978036 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Wed, 22 Dec 2021 18:23:42 +0200 Subject: Remove possible null values for ValidatedSlot.filter --- src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java | 8 +++++++- src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main') 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 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 filter; + private Predicate filter = DEFAULT_ITEM_FILTER; protected final Multimap 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 DEFAULT_FILTER = stack -> true; private final List 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 filter = DEFAULT_FILTER; + private Predicate filter = ValidatedSlot.DEFAULT_ITEM_FILTER; private final Set listeners = new HashSet<>(); public WItemSlot(Inventory inventory, int startIndex, int slotsWide, int slotsHigh, boolean big) { -- cgit