Jump to content

Custom item private fields are not initialised when using CompassItemPropertyFunction


Bezeram

Recommended Posts

Hello!

I am new to modding in Minecraft.

I have created a custom compass item which basically points towards a target player, along with other logic.
More or less, I have copied the vanilla implementation, apart from the class Item derived class, which contains several private non-static fields.
Crucially however, those fields are not initialised when I register the Item using a DeferredRegister.

For the client rendering I have attempted to use the vanilla CompassItemPropertyFunction, in which I have passed a lambda function which is supposed to get data from the custom compass item stored in its fields.
The lambda function looks like this: (clientLevel, itemStack, entity) -> GlobalPos
The compass has its private non-static fields initialised when the compass is given to the player via a game command.

The problem: those fields are not initialised when attempting to return the target player's position in the getPos() function found in CompassItemPropertyFunction, even though they are in fact initialised as part of an ItemStack stored in a player's inventory.

My question: why is the additional data I added in my custom compass item class all null, but the ItemStack instance might still contain tags for example?

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

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.