Jump to content

[1.19.2/SOLVED] Custom clock-like item renders correctly in player hand, but doesn't render the correct texture in the inventory


SparkyTD

Recommended Posts

I am learning Forge 1.19, and as my first item I wanted to create a moon phase tracker. It is basically a copy of a clock, with eight different textures, and eight different models that are determined by a custom predicate in the base model. The predicate is just a custom ItemProperty that retrieves level.getMoonPhase().

If I hold this item in my hand, or throw it on the ground, it shows the correct moon phase texture, like it should. But if I look at the item in my inventory, or place it in an item frame, it only renders the default texture, and doesn't apply the overrides defined in the model json. What could be causing this behavior? I haven't seen any inventory-specific json files in the Clock or Compass, so I don't know what I have to do.

Here are the relevant files:

Screenshot that demonstrates the issue: https://imgur.com/a/uRAjtEX

Edited by SparkyTD
Solved
Link to comment
Share on other sites

If you look at the code for the clock, it tries to use the LivingEntity's level if the passed level is null.

You are also missing value = Dist.CLIENT for your subscription to client events. 

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

1 hour ago, warjort said:

If you look at the code for the clock, it tries to use the LivingEntity's level if the passed level is null.

You are also missing value = Dist.CLIENT for your subscription to client events. 

That was it, thanks! I didn't know level could be null. The is code works now:
 

ItemProperties.register(this,
                new ResourceLocation(LunarEclipseMod.MODID, "moon_phase"), (stack, level, living, id) -> {
                    if (living != null)
                        return (float) living.level.getMoonPhase();

                    if (level != null)
                        return (float) level.getMoonPhase();

                    return 0;
                });

 

Link to comment
Share on other sites

  • SparkyTD changed the title to [1.19.2/SOLVED] Custom clock-like item renders correctly in player hand, but doesn't render the correct texture in the inventory

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.