diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2022-05-19 15:53:47 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2022-05-19 15:53:47 -0700 |
commit | fd1948939a5978832ce5da5bb2dbbd0df49a2ac3 (patch) | |
tree | 7856ada82a27bb0cf136fbbd9296aa351a85f22a /src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java | |
parent | 312cf6b1d2990d7632807dfa5ef93b8dd2cbb865 (diff) | |
download | Iceberg-fd1948939a5978832ce5da5bb2dbbd0df49a2ac3.tar.gz Iceberg-fd1948939a5978832ce5da5bb2dbbd0df49a2ac3.tar.bz2 Iceberg-fd1948939a5978832ce5da5bb2dbbd0df49a2ac3.zip |
Bumped required forge version to 40.1, fixed IcebergConfig crash.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java b/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java index 5099644..7c12330 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java +++ b/src/main/java/com/anthonyhilyard/iceberg/util/Selectors.java @@ -1,15 +1,15 @@ package com.anthonyhilyard.iceberg.util; -import net.minecraft.world.item.ItemStack; - import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.function.BiPredicate; import java.util.List; import net.minecraft.client.Minecraft; +import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NumericTag; import net.minecraft.nbt.Tag; @@ -17,9 +17,11 @@ import net.minecraft.nbt.ListTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextColor; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Rarity; import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; public class Selectors { @@ -31,7 +33,9 @@ public class Selectors }}; private static Map<String, BiPredicate<Tag, String>> nbtComparators = new HashMap<String, BiPredicate<Tag, String>>() {{ - put("=", (tag, value) -> tag.getAsString().contentEquals(value)); + put("=", (tag, value) -> { + return tag.getAsString().contentEquals(value); + }); put("!=", (tag, value) -> !tag.getAsString().contentEquals(value)); @@ -143,6 +147,7 @@ public class Selectors * @param selector A selector string to check against. * @return True if the item matches, false otherwise. */ + @SuppressWarnings("deprecation") public static boolean itemMatches(ItemStack item, String selector) { String itemResourceLocation = item.getItem().getRegistryName().toString(); @@ -179,7 +184,8 @@ public class Selectors // Item tag else if (selector.startsWith("$")) { - if (ItemTags.getAllTags().getTagOrEmpty(new ResourceLocation(selector.substring(1))).getValues().contains(item.getItem())) + Optional<TagKey<Item>> matchingTag = Registry.ITEM.getTagNames().filter(tagKey -> tagKey.location().equals(new ResourceLocation(selector.substring(1)))).findFirst(); + if (matchingTag.isPresent() && item.is(matchingTag.get())) { return true; } @@ -298,4 +304,4 @@ public class Selectors } return false; } -}
\ No newline at end of file +} |