diff --git a/src/main/java/xyz/prismenetwork/kelpmodloader/Item/ItemUtils.java b/src/main/java/xyz/prismenetwork/kelpmodloader/Item/ItemUtils.java index 38f68e5..4e62a9b 100644 --- a/src/main/java/xyz/prismenetwork/kelpmodloader/Item/ItemUtils.java +++ b/src/main/java/xyz/prismenetwork/kelpmodloader/Item/ItemUtils.java @@ -1,27 +1,34 @@ package xyz.prismenetwork.kelpmodloader.Item; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import xyz.prismenetwork.kelpmodloader.Block.ModdedBlock; import xyz.prismenetwork.kelpmodloader.Constant; public class ItemUtils { public static boolean isModed(ItemStack itemStack) { if (itemStack.hasItemMeta()) { ItemMeta itemMeta = itemStack.getItemMeta(); - if (itemMeta.getCustomModelData() - 1 != 0) { + System.out.println(itemMeta.getCustomModelData()); + if (itemMeta.getCustomModelData() != 0) { return true; } } return false; } + /** + * @param itemStack The itemStack to get the Modded item from + * @return The modded item from this itemStack (Null if not modded or block item) + */ public static ModdedItem getModedItem(ItemStack itemStack) { if (itemStack.hasItemMeta()) { ItemMeta itemMeta = itemStack.getItemMeta(); - assert itemMeta != null; if (itemMeta.getCustomModelData() - 1 != 0) { for (int i = 0; i < Constant.Items.size(); i++) { ModdedItem item = Constant.Items.get(i); + System.out.println(Constant.Items.get(i)); if (itemMeta.getCustomModelData() == item.getId() - 1 && itemStack.getType() == item.ItemMaterial) { return item; } @@ -30,4 +37,24 @@ public static ModdedItem getModedItem(ItemStack itemStack) { } return null; } + + /** + * @param itemStack The itemStack to get the Modded block from + * @return The modded block from this itemStack (Null if not modded or item) + */ + public static ModdedBlock getModedBlockFromItem(ItemStack itemStack) { + if (itemStack.hasItemMeta()) { + ItemMeta itemMeta = itemStack.getItemMeta(); + if (itemMeta.getCustomModelData() - 1 != 0) { + for (int i = 0; i < Constant.Blocks.size(); i++) { + ModdedBlock moddedBlock = Constant.Blocks.get(i); + System.out.println(Constant.Blocks.get(i)); + if (itemMeta.getCustomModelData() == moddedBlock.getId() - 1) { + return moddedBlock; + } + } + } + } + return null; + } } diff --git a/src/main/java/xyz/prismenetwork/kelpmodloader/Pack/GenerateModel.java b/src/main/java/xyz/prismenetwork/kelpmodloader/Pack/GenerateModel.java index 6c1c02b..7c9ba62 100644 --- a/src/main/java/xyz/prismenetwork/kelpmodloader/Pack/GenerateModel.java +++ b/src/main/java/xyz/prismenetwork/kelpmodloader/Pack/GenerateModel.java @@ -79,6 +79,7 @@ public void Generate(File blockModelFile, File itemModelFile) throws IOException //Generate Item models HashMap MaterialsJson = new HashMap<>(); Items.forEach(I -> { + System.out.println(I.Name + " - "+ I.getId()); if (I.ItemMaterial.equals(Material.STONE)) { KelpModLoader.getPlugin(KelpModLoader.class).getLogger().warning("You are using \"STONE\" as a material for item \"" + I.Name + "\". This will cause issue."); }