Posted January 7, 20232 yr I'm guessing onCraftedBy is only called when it's crafted and not called when, for instance, you get an item through commands or the creative tab. Is there another method that gets called every time when an item is created or is there another way I should go in order to do some stuff when an item is created?
January 7, 20232 yr There is no such method. ItemStacks are created by the game all the time for many reasons. e.g. copying, deserializing from the disk or network, etc. If this is another part of your NBT questions, NBT is meant to be "optional" data. If your data is not present you need to provide a default value. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
January 7, 20232 yr Capabilities have some support for initializing data. See ItemStack.forgeInit() and Item.initCapabilities() Edited January 7, 20232 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
January 7, 20232 yr Author 9 minutes ago, warjort said: If this is another part of your NBT questions, NBT is meant to be "optional" data. If your data is not present you need to provide a default value. It is indeed. I needed that info as I needed to create the tag element and put the starting value but couldn't do it in hurtEnemy cause it would get called continously. Gotcha, thanks. I was asking because I remember in some older version there was an onCreated method somewhere, can't recall exactly where though
January 7, 20232 yr Author 7 minutes ago, warjort said: Capabilities have some support for initializing data. See ItemStack.forgeInit() and Item.initCapabilities() Capabilities seem pretty complex and unnecessary for what I'm doing, I'll check it out though if I feel like I need it, thank you
January 9, 20232 yr i do something similar in 1.8 the only efective way i found was to add boolean tag initialized then in every get funtion i check if initialized == true if not the initialize it
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.