Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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.

  • Author
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;
                });

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.