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?