No that seems to only work for inventory slots. Is there any way to get an item by its ID? this would be way easier to store the item id rather then the whole item.
False, he wants to store an item in the nbt. Not make a new nbt from an itemstack, and write the nbt to it.
You can store an NBT tag within an NBT tag, so writing the ItemStack to a new tag that you then store in your current ItemStack's NBT is a valid way to achieve the desired result; I've used this same method in my own mod for storing a complete ItemStack within an ItemStack (and that's also how ItemStacks are stored in most inventories: as a list of NBTTagCompounds), though it's overkill if you just need to be able to get the Item and don't care about any of its other traits.
No that seems to only work for inventory slots. Is there any way to get an item by its ID? this would be way easier to store the item id rather then the whole item.
EDIT: I've done it! Thanks for all the help
Looking ahead at 1.8, you may not want to rely on Item.getItemFromID or any other methods using IDs (for Blocks or Items), as I'm pretty sure IDs will be completely gone (and someone please correct me if I'm wrong!). Instead, they will need to be stored as strings such as "yourmodid:items_unlocalized_name" or something to that effect, and retrieved from the game registry using that same string. Just something to consider, though I still use (and prefer) integer IDs in my current mods.
You can store an NBT tag within an NBT tag, so writing the ItemStack to a new tag that you then store in your current ItemStack's NBT is a valid way to achieve the desired result; I've used this same method in my own mod for storing a complete ItemStack within an ItemStack (and that's also how ItemStacks are stored in most inventories: as a list of NBTTagCompounds), though it's overkill if you just need to be able to get the Item and don't care about any of its other traits.
Looking ahead at 1.8, you may not want to rely on Item.getItemFromID or any other methods using IDs (for Blocks or Items), as I'm pretty sure IDs will be completely gone (and someone please correct me if I'm wrong!). Instead, they will need to be stored as strings such as "yourmodid:items_unlocalized_name" or something to that effect, and retrieved from the game registry using that same string. Just something to consider, though I still use (and prefer) integer IDs in my current mods.
Thanks for the advice. I'll cross that bridge when I have to lol
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
False, he wants to store an item in the nbt. Not make a new nbt from an itemstack, and write the nbt to it.
Look at this tutorial for help.
http://www.minecraftforum.net/topic/1959857-162-advanced-minecraft-forge-modding-tutorial-2-inventories/
Thanks man, your helping me a ton! I think i've figured it out.
Meh, it's fine.
EDIT: I've done it! Thanks for all the help
You can store an NBT tag within an NBT tag, so writing the ItemStack to a new tag that you then store in your current ItemStack's NBT is a valid way to achieve the desired result; I've used this same method in my own mod for storing a complete ItemStack within an ItemStack (and that's also how ItemStacks are stored in most inventories: as a list of NBTTagCompounds), though it's overkill if you just need to be able to get the Item and don't care about any of its other traits.
Looking ahead at 1.8, you may not want to rely on Item.getItemFromID or any other methods using IDs (for Blocks or Items), as I'm pretty sure IDs will be completely gone (and someone please correct me if I'm wrong!). Instead, they will need to be stored as strings such as "yourmodid:items_unlocalized_name" or something to that effect, and retrieved from the game registry using that same string. Just something to consider, though I still use (and prefer) integer IDs in my current mods.