Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Borrowed this from forestry
- * @param itemStack
- * @return
- */
- @Nullable
- public static String getStringForItemStack(ItemStack itemStack) {
- if (itemStack.isEmpty()) {
- return null;
- }
- Item item = itemStack.getItem();
- String itemStackString = getItemNameFromRegistryAsString(item);
- if (itemStackString == null) {
- return null;
- }
- int meta = itemStack.getItemDamage();
- if (meta != OreDictionary.WILDCARD_VALUE) {
- return itemStackString + ':' + meta;
- } else {
- return itemStackString;
- }
- }
- /**
- * @return The registry name of the item as {@link String}
- */
- @Nullable
- public static String getItemNameFromRegistryAsString(Item item) {
- ResourceLocation rl = item.getRegistryName();
- return rl == null ? null : rl.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment