-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
getTag() only exists on 1.17 version.
public static Optional<Integer> getInt(ItemStack item, String key) {
Optional<net.minecraft.world.item.ItemStack> item1;
try {
item1 = getItem(item);
} catch (NoSuchFieldException | IllegalAccessException e) {
return Optional.empty();
}
if (item1.isEmpty()) return Optional.empty();
NBTTagCompound tag = item1.get().getTag(); // exception
if (tag == null) return Optional.empty();
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getInt(key));
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels