Using custom nbt for a model predicate provider. #2366
-
I'm currently trying to make an item that can store experience display a different model depending on how full it is of experience. The experience is stored in them item under the an integer nbt tag known as There are going to be 3 different models used, one for when it is under 33% full, one for between 33% and 66% full, and one for 66% or greater full. Looking at Mojang's implementation of the I've tried implementing said code while also using Here is the current code: ModelPredicateProviderRegistry.register(ModItems.EXPERIENCE_CRYSTAL, new Identifier("fill"), (stack, world, entity, seed) -> {
if (entity == null) {
return 0.0f;
}
if (entity.getActiveItem() != stack) {
return 0.0f;
}
return (float) stack.getOrCreateNbt().getInt("StoredExperience") / 3000.0f;
}); This is within a It currently does not work and I'm wondering if I can get some feedback or help on how |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I have never used this feature myself, but a quick search on github shows this small mod using it. Here's what the model looks like which seems to be similar to what you want? BTW I think your 2 if statements are not relevant for your use case? In the code you copied, they represent forcing the uncharged bow to be drawn if there is no entity actively holding it. If you are interested, it also shows how to draw a filled bar next to the item using a mixin: |
Beta Was this translation helpful? Give feedback.
-
Sidenote: Using the
|
Beta Was this translation helpful? Give feedback.
I have never used this feature myself, but a quick search on github shows this small mod using it.
https://github.com/AmyMialeeMods/icy-incitement/blob/main/src/main/java/amymialee/icyincitement/IcyIncitementClient.java
Here's what the model looks like which seems to be similar to what you want?
https://github.com/AmyMialeeMods/icy-incitement/blob/main/src/main/resources/assets/icyincitement/models/item/snowball_sprinkler.json
BTW I think your 2 if statements are not relevant for your use case? In the code you copied, they represent forcing the uncharged bow to be drawn if there is no entity actively holding it.
If you are interested, it also shows how to draw a filled bar next to the ite…