Skip to content

Commit

Permalink
Added ItemUtils.java to know if an item is modded and get the modded …
Browse files Browse the repository at this point in the history
…item that come with that itemStack
  • Loading branch information
tbvns committed Jan 21, 2024
1 parent 9b50a8a commit 08ea99f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/xyz/prismenetwork/kelpmodloader/Item/ItemUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package xyz.prismenetwork.kelpmodloader.Item;

import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
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) {
return true;
}
}
return false;
}

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);
if (itemMeta.getCustomModelData() == item.getId() - 1 && itemStack.getType() == item.ItemMaterial) {
return item;
}
}
}
}
return null;
}
}

0 comments on commit 08ea99f

Please sign in to comment.