Jump to content

Method that gets called once when an item is created?


DrNickenstein

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Capabilities have some support for initializing data. See ItemStack.forgeInit() and Item.initCapabilities()

Edited 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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.