Jump to content

[Solved][1.8.9] Changing Item texture based on an NBT flag


Recommended Posts

Posted

Hello, I am messing around with creating various things in 1.8.9 in an attempt to get a better feel for the new model system. Right now I am trying to create a basic helmet which changes the armor texture and the item texture depending on the value of the design tag in the ItemStack NBT. I have read through a few other topics on changing the item texture/model depending on the NBT or other conditions, and have found a way to do what I am trying to achieve. The way I am attempting makes use of a custom ItemMeshDefinition which allows me to change the ModelResourceLocation based on an ItemStack. The other topics I have read, along with the 1.8.9 Rendering Primer document that has been going around say that I must first bake the models using ModelLoader#registerItemVariants and passing it all the ResourceLocations pointing to my variants, and then I must use  ModelLoader#setCustomMeshDefinition to apply my custom ItemMeshDefinition. I believe that I have done both of those things correctly, however my item still has the over sized block model, and the purple/black missing texture look. I have also compared my code against code found in the 1.8 port of Botania (the mana gun and other items use the same approach) however I couldn't find any differences or things I might have left out. This issue has really stumped me, and I would really appreciate it if someone could give my code a look over.

 

Some important notes

-Right now I have only creates json models for 3/16 of my current designs.

-The 3 designs that have json models are not listed in the console output of missing models, the other 13 are.

-The models I am using use a custom parent model to cut down on the size of my json files. This seems to be a common thing, however it is worth mentioning.

 

The entire source for this mod is public on GitHub however here are some other important files

Mod Class

Main Mod Class

Mesh Definition

Model Files

Item Class

Posted

You have a few problems:

  • Your item textures are in textures/item instead of textures/item.
  • You're registering your models in init.
    ModelLoader.setCustomMeshDefinition

    only works if called before init.

  • You're returning a
    ModelResourceLocation

    with the default

    "normal"

    variant from your

    Deadmau5MeshDefinition

    , but the

    builtin/generated

    model only provides the 

    "inventory"

    variant.

 

I've forked your mod on GitHub and fixed these problems. You can see what I changed and/or merge the changes here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Thank you for having a look at the project, you were spot on with the problems you found. Some of them such as the textures being in the wrong directory were pretty foolish on my part :P Also, thank you for creating a fork of the repository, that was far more then I could have hoped for, and I really appreciate it.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I created a modded Minecraft pack and subsequent server for My Fiance and I to play on, we are both new to modding, and have no experience of what mods go together. We gave it a shot and made a pretty good pack, based on some mods we saw previously in All The Mods 9, plus some other building and fun mods. Everything was great, server was running for 10 days(?) and went through multiple subsequent restart cycles (wasn't online 24/7). We were wrapping up for the night, I did /saveall in game, and the command said the world was finished saving. I then did /stop. Following morning we attempted to start the server and it will not get past: [19:25:04] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing start region for dimension minecraft:overworld I attempted to take out the world, and load it on Singleplayer, however same issue, world wont load. I deleted the "serverconfig" directory and it will also not load. I removed the world from the server, thus allowing it to generate a new world, and that worked fine. But our current world will not load anywhere. I am aware of some errors in the logs due to some mismatching, and incompatibilities; I didn't know what was strictly client-side, and what needed to go onto the server, I also didn't know what performance mods did what, so there is a potential multiple were doing the same thing, however this shouldn't be responsible for the crash, as no new mods have been added for atleast 10 restart cycles and everything worked smoothly. I know there is an error about Canary conflicting with Better Chunk Loading, however that error has occured since the beginning of the server and nothing new. It is to be noted that there isn't actually a crash happening. ---> Full Log <--- If this world is corrupted, is there any way to fix it? I have a backup of the world from 4 days ago, but I also dont want to have to roll back that far, I would really like to deal with the issue at hand.
    • Can be anything - start with mods having some addons like Create etc
    • Hello everyone!   I recently switched my broadband provider from BT to Hey, and I ran into a frustrating issue when trying to connect to Minecraft. I kept receiving the error message:   “Failed to connect to the server. Please disconnect from your VPN or proxy and rejoin.”   This was strange since I wasn’t using a VPN or proxy at the time. After some troubleshooting, I discovered that my new ISP might have been flagging my connection incorrectly.   To resolve this, I used a tool called Home page, which helped me manage my online profiles more effectively. By setting up a new profile, I was able to bypass the detection issue and connect to Minecraft without any problems.   If you’re facing similar issues after switching ISPs or encountering connection errors, I recommend exploring tools like Multilogin to help manage your connections.   Hope this helps someone out there!
    • do yk what kinds of mods i should test removing first? Like world generation mods first right?
  • Topics

×
×
  • Create New...

Important Information

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