Browse Source

1.16 Support part 2

nossr50 5 years ago
parent
commit
1101815f18

+ 10 - 2
src/main/java/com/gmail/nossr50/util/ItemUtils.java

@@ -266,7 +266,7 @@ public final class ItemUtils {
      * @return true if the item is armor, false otherwise
      */
     public static boolean isMinecraftArmor(ItemStack item) {
-        return isLeatherArmor(item) || isGoldArmor(item) || isIronArmor(item) || isDiamondArmor(item) || isChainmailArmor(item);
+        return isLeatherArmor(item) || isGoldArmor(item) || isIronArmor(item) || isDiamondArmor(item) || isNetherriteTool(item) || isChainmailArmor(item);
     }
 
     /**
@@ -345,6 +345,14 @@ public final class ItemUtils {
         }
     }
 
+    public static boolean isNetherriteArmor(ItemStack itemStack) {
+        return mcMMO.getMaterialMapStore().isNetherriteArmor(itemStack.getType());
+    }
+
+    public static boolean isNetherriteTool(ItemStack itemStack) {
+        return mcMMO.getMaterialMapStore().isNetherriteTool(itemStack.getType());
+    }
+
     /**
      * Checks to see if an item is a chainmail armor piece.
      *
@@ -371,7 +379,7 @@ public final class ItemUtils {
      * @return true if the item is a tool, false otherwise
      */
     public static boolean isMinecraftTool(ItemStack item) {
-        return isStoneTool(item) || isWoodTool(item) || isGoldTool(item) || isIronTool(item) || isDiamondTool(item) || isStringTool(item) || item.getType() == Material.TRIDENT;
+        return isStoneTool(item) || isWoodTool(item) || isGoldTool(item) || isIronTool(item) || isDiamondTool(item) || isNetherriteTool(item) || isStringTool(item) || item.getType() == Material.TRIDENT;
     }
 
     /**

+ 26 - 0
src/main/java/com/gmail/nossr50/util/MaterialMapStore.java

@@ -24,6 +24,8 @@ public class MaterialMapStore {
     private HashSet<String> multiBlockPlant;
     private HashSet<String> foodItemWhiteList;
     private HashSet<String> glassBlocks;
+    private HashSet<String> netherriteArmor;
+    private HashSet<String> netherriteTools;
 
     public MaterialMapStore()
     {
@@ -37,6 +39,8 @@ public class MaterialMapStore {
         multiBlockPlant = new HashSet<>();
         foodItemWhiteList = new HashSet<>();
         glassBlocks = new HashSet<>();
+        netherriteArmor = new HashSet<>();
+        netherriteTools = new HashSet<>();
 
         fillHardcodedHashSets();
     }
@@ -93,6 +97,20 @@ public class MaterialMapStore {
         fillMultiBlockPlantSet();
         fillFoodWhiteList();
         fillGlassBlockWhiteList();
+        fillNetherriteWhiteList();
+    }
+
+    private void fillNetherriteWhiteList() {
+        netherriteTools.add("netherrite_sword");
+        netherriteTools.add("netherrite_axe");
+        netherriteTools.add("netherrite_hoe");
+        netherriteTools.add("netherrite_pickaxe");
+        netherriteTools.add("netherrite_shovel");
+
+        netherriteArmor.add("netherrite_helmet");
+        netherriteArmor.add("netherrite_chestplate");
+        netherriteArmor.add("netherrite_leggings");
+        netherriteArmor.add("netherrite_boots");
     }
 
     private void fillGlassBlockWhiteList() {
@@ -171,6 +189,14 @@ public class MaterialMapStore {
         foodItemWhiteList.add("tropical_fish");
     }
 
+    public boolean isNetherriteArmor(Material material) {
+        return netherriteArmor.contains(material.getKey().getKey());
+    }
+
+    public boolean isNetherriteTool(Material material) {
+        return netherriteTools.contains(material.getKey().getKey());
+    }
+
     public boolean isGlass(Material material) {
         return glassBlocks.contains(material.getKey().getKey());
     }

+ 4 - 0
src/main/java/com/gmail/nossr50/util/MaterialUtils.java

@@ -7,6 +7,10 @@ public final class MaterialUtils {
     private MaterialUtils() {}
 
     protected static boolean isOre(Material data) {
+        //Netherrite Ore (Kind of)
+        if(data.getKey().getKey().equalsIgnoreCase("ancient_debris"))
+            return true;
+
         switch (data) {
             case COAL_ORE:
             case DIAMOND_ORE: