This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
Subj.
I need to detect player, who created (crafted) the Item/BlockItem, and add hes UUID to NBT as a 'owner' tag.
Hello Johnson,
I can think of two different places where you could detect the player who crafted the Item and set the owner tag.
The place you wanna use depends, if you want to set the owner only for your own Items or for others as well.
1. Override Item#onCreated
2. Subscribe to PlayerEvent::ItemCraftedEvent
Both give you access to the crafted ItemStack as well as the Player who performed the crafting operation.
You can get the UUID from EntityPlayer#getUniqueID()
FIY: Check out the official Forge Modder Support for faster response time
Nice Greetings
TechMage
Thanks for the answer and the link!
Subj.
I need to detect player, who created (crafted) the Item/BlockItem, and add hes UUID to NBT as a 'owner' tag.
Hello Johnson,
I can think of two different places where you could detect the player who crafted the Item and set the owner tag.
The place you wanna use depends, if you want to set the owner only for your own Items or for others as well.
1. Override Item#onCreated
2. Subscribe to PlayerEvent::ItemCraftedEvent
Both give you access to the crafted ItemStack as well as the Player who performed the crafting operation.
You can get the UUID from EntityPlayer#getUniqueID()
FIY: Check out the official Forge Modder Support for faster response time
Nice Greetings
TechMage
Thanks for the answer and the link!