Bezeram Posted October 20, 2023 Posted October 20, 2023 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? Quote
Luis_ST Posted October 28, 2023 Posted October 28, 2023 Show you code, ideally in a GitHUb repo. Quote
Bezeram Posted April 2, 2024 Author Posted April 2, 2024 (edited) Doesn't matter anymore I was bein dumb. I didn't know I had to use item tags : P Issue closed. Edited April 2, 2024 by Bezeram Quote
Recommended Posts
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.