Jump to content

Recommended Posts

Posted (edited)

Hello. I think I get how basic json block models work by default just matching on name essentially (?). How would I go about inserting a condition into my code to provide an alternative different model though? I have created two different json model files, each pointing to a different set of textures:

bbb.json + 32bbb.json
 

I tried this simple code here in the public block class for the block called bbb, but this does not result in the 32bbb model ever being used, and the bbb model is used in both cases:

 

    @SideOnly(Side.CLIENT)
    @Override
    public void registerModels(ModelRegistryEvent event) {
        if (somecondition) {
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation("aaa:bbb", "inventory"));
        }
        else {
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation("aaa:32bbb", "inventory"));

        }
    }

 

Is this something to do with having to force a registration of the 32bbb model somehow to make it visible to the bbb block? If so, how and where do I do this so that the block class can see it? Or is it something else completely? (The condition itself is coming from a static config file, and is not dynamic so I reason can be applied at the point of creating the block like this).

 

Thanks for any help - greatly appreciated.

Edited by Aecht_Rob
Posted

1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted

Thanks - I think this the same issue presents itself with the same code in later versions - this is not specific to 1.12.2 (?)

 

My mod is versioned over 1.12 through to 1.15 with the various code variants, and the same question applies.

 

Thanks!

Posted
34 minutes ago, Aecht_Rob said:

I think this the same issue presents itself with the same code in later versions

Do you think or do you know? Post updated 1.15 code.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted
40 minutes ago, Aecht_Rob said:

Thanks - I think this the same issue presents itself with the same code in later versions - this is not specific to 1.12.2 (?)

 

My mod is versioned over 1.12 through to 1.15 with the various code variants, and the same question applies.

 

Thanks!

1.15 (well, 1.13+) does not have ModelLoader.setCustomModelResourceLocation because its functionality is no longer required because vanilla model systems are smarter.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

 

55 minutes ago, Novârch said:

Do you think or do you know? Post updated 1.15 code.

Apologies, no, I don't know at all. :) All I know is that the problem to solve is the same and I don't know how it's done, and assumed it would be code along the same lines. I don't have anything like the 1.12 code specifically referencing models inside the later version code. It just seems finds the right model as if by magic, and I don't know how it is doing it, unless its the text match between block and json names. My code is largely cut-and-paste from tutorials and examples, and then edited to what I need, and I'm looking for some basic help on how to make this next edit.

 

For 1.13+, does that mean it's impossible to circumvent the "intelligent" handling? I know I can do things like use blockstates, but what I am looking for is to assign different textures (via two different models) for the same block and blockstate, depending on the value of a variable passed by a config file. Like an embedded texture resourcepack.

 

I don't know if I am looking for a solution in the block definitions, or to pass the variable to the jsons for deal with there (and I don't know how I would do that unless I know where in the code the jsons are even referenced). Or maybe I can override the global models filepath and store the alternate models in a different folder, but have no idea how I would do that.

Edited by Aecht_Rob
Posted
4 minutes ago, Aecht_Rob said:

All I know is that the problem to solve is the same and I don't know how it's done, and assumed it would be code along the same lines

Read Draco's comment, the code is completely different in 1.15, try to make something on your own and come back here if you fail.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

  • 3 months later...
Posted

As no-one wanted to help me, I thought I'd update this in case anyone else wants to do something like this (which was to pseudo-embed a texturepack inside a mod to enable a user to toggle specific changed blocks textures on/off via a config). The answer I used is the extremely simple blockstate, via the getActualState method of the block to check the config setting and apply the blockstate and model as required.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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