Using predicates in ".json" files to dynamically change a texture

Started by Keter_Nihilo on Tue, 07/07/2020 - 19:47

Topic category: Help with modding (Java Edition)

Last seen on 01:29, 21. Mar 2021
Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Using predicates in ".json" files to dynamically change a texture
Tue, 07/07/2020 - 19:47

I'm currently working on a bionicle mod, and I'm hoping to make it so that a single mask item can have multiple textures that can be changed via nbt tags (Probably damage) without having to create individual items where only the texture is different, I think the only issue that I'm coming across currently is the path of which a texture is called

{
  "parent": "item/generated",
  "textures": {
    "layer0": "kanohimc:items/kanohi_hau"
  },
 
  "overrides": [
        { “predicate”: { “custom_model_data”: 1}, “model”: "item/kanohi_hau_blank” },
        { “predicate”: { “custom_model_data”: 2}, “model”: "item/kanohi_hau_tahu” }
      ]
}

Last seen on 01:29, 21. Mar 2021
Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I've figured out a solution!…
Sun, 07/19/2020 - 14:17

I've figured out a solution! It's a bit messy, but it's a bit cleaner and feels nicer than having to make unique items for each texture.

I'll post a small tutorial here later for anybody who's interested.

Pros: Dynamic texture changes in game, single item to contain multiple textures

Cons: Only works with existing predicates, textures need both a json file and a texture file, requires an additional resource pack along with the mod (may be a work around), if using damage it shows damage bar(can be fixed with unbreakable tag, which is still a bit ugly) which interferes with damagable items

Last seen on 13:57, 2. Apr 2021
Joined Aug 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I would like to follow this…
Sun, 07/19/2020 - 14:23

I would like to follow this case :D

Last seen on 16:48, 17. Dec 2020
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How did you end up doing it?
Thu, 08/13/2020 - 18:40

How did you end up doing it?

Last seen on 01:29, 21. Mar 2021
Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Hey, super sorry for the…
Wed, 10/21/2020 - 22:07

Hey, super sorry for the late reply (Lots of stuff going on in my personal life) but my theory was correct! Minecraft has a built in "Dynamic texture changing mechanic" through resource packs (I believe it's also how the bow and fishingline work), where you add a few json files to change the texture, either using an nbt "CustomModelData" tag or through the damage tag (There may be others that work better, but these worked best for me) The problem is it requires a lot of tweaking/trial and error to get the right results. I made a seperate resource pack and figured out where the item texture was by using a seperate texture in the resource pack, then I followed a few tutorials on YouTube to figure out how to redirect the texture with a json file (Same name as the json file used to load the initial texture, not necessarily the same name as the png file) then you can basically make it branch off into different files based on damage, tag and probably a few other things. Honestly, it's not too complicated once you understand, but it's kinda messy and hard to get your head around when you're working on your first texture change. I recommend taking it step by step and looking into making a resource pack with changing textures (Or do what I did, and download a resource pack and reverse engineer it) if people are really struggling I'll try and make a follow up

 

Last seen on 14:40, 2. Apr 2021
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
did this all work? a little…
Tue, 11/17/2020 - 19:59

did this all work? a little more direction would be grreatly appreciatet.

Last seen on 19:28, 9. Apr 2021
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
my guy a few months later…
Wed, 03/03/2021 - 20:34

my guy a few months later and im begging ya, youtube video on your process