Jump to content

[SOLVED] [1.12.2] Block model with random textures on random sides?


Evi1Casul

Recommended Posts

UPD: SOLVED

 

Hi. I've been trying to create a block attaching to adjacent blocks on 6 sides (kinda vines) with random textures. And the problem is... Wait, a quick maths: 11 vine models for 5 sides + additional bottom side = 23 models, and with 6 different textures it reaches 138 (!)  Is it possible to randomize textures on different sides, because 23 * 6^6 models is a little too much?

Example of a model x_1d_1 (1 side + bottom, texture 1):

{
	"ambientocclusion": false,
    "textures": {
        "tex": "modid:blocks/tex_1"
    },
    "elements": [
        {   "from": [ 0, 0.8, 0 ],
            "to": [ 16, 0.8, 16 ],
            "shade": false,
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#tex_1", "tintindex": 0 },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#tex_1", "tintindex": 0 }
            }
        },
        {   "from": [ 0, 0, 15.2 ],
            "to": [ 16, 16, 15.2 ],
            "shade": false,
            "faces": {
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#tex_1", "tintindex": 0 },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#tex_1", "tintindex": 0 }
            }
        }
    ]
}

 

First texture is used on each face here and model x_1d_2 differs only in texture number.

So can I add all the six textures to the model and randomize it? Thanks in advance.

Edited by Evi1Casul
Link to comment
Share on other sites

You can specify multiple textures and Minecraft will grab them at random based on the block's position automatically.

I don't remember exactly how to do it though.

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.

Link to comment
Share on other sites

I tried to use multimodel and submodels system, but it still generates all the possible sets of variants (as I said, with 6 different textures on 6 sides it loads over a million models). Is it possible to override the block renderer so it can pick a random texture dynamically? I found it too dfficult to create an advanced model (using a custom model loader, etc.), it seems there's not even a premde IModel class for block (only ItemBlock and private vanilla wrapper).

Edited by Evi1Casul
Link to comment
Share on other sites

This is how vanilla handles it:

{
    "variants": {
        "": [
            { "model": "block/stone" },
            { "model": "block/stone_mirrored" },
            { "model": "block/stone", "y": 180 },
            { "model": "block/stone_mirrored", "y": 180 }
        ]
    }
}

Notice that each variant is an array. Every blockpos generates a random result from this array.

 

I'm also not sure how you got "over a million variants." 6 sides ^ 6 textures is only 46656.

Edited by Draco18s

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.

Link to comment
Share on other sites

57 minutes ago, Draco18s said:

This is how vanilla handles it:

...

Notice that each variant is an array. Every blockpos generates a random result from this array.

 

Yes, I also used this in my blockstate, like this:

"north": {
  "true": {
    "submodel": {
	  "face0": [
		{ "model": "modid:model_0" },
		{ "model": "modid:model_1" },
		{ "model": "modid:model_2" },
		{ "model": "modid:model_3" },
		{ "model": "modid:model_4" },
		{ "model": "modid:model_5" }
	  ]
	}
  },
  "false": { }
}

 

 

Quote

 

I'm also not sure how you got "over a million variants." 6 sides ^ 6 textures is only 46656.

Because the block can attach to each side (like vine, but with an additional bottom side), so it's 2^6 * 6^6 = 2985984 (3M) variants (if my calculations are correct).

 

P.S. 46k models is a lot too, I think. I can dublicate these 64 (2^6) variants and randomize textures automatically with IO and string replacement to get like few hundred variants, so every texture would be used, and that will give some feel of randomess, but I still want to find a way to do this with all the possible combinations dynamically.

Edited by Evi1Casul
Link to comment
Share on other sites

I could have sworn there was a better way of doing this.

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.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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