Jump to content

Simplifying blockstate rotations


Heliarco

Recommended Posts

Hi guys, i am learning to develop forge mods on 1.16.3 and i am wondering if you have any idea of how i can simplify this blockstate file.

Currently i have a miniframe item, that can be attached on a block in all 6 directions, with a custom model.

Furthermore it can then be rotated depending on the player position. The code for setting the blockstates etc. all work out and the block is behaving exactly how it should. However currently i have the model pre-transformed in all 24 versions of blockstates. Is there a smarter way to do this? I Tried using the built in X and Y parameters in the JSON, but could not achieve all the needed mutations. 

Ideally i would like to just have one render of the model, since it only differs in rotation and reexporting it quickly becomes a chore.

 

{
  "variants": {
    "facing=up,rotated=0": { "model": "testmod:block/miniframe_up_n"},
    "facing=up,rotated=1": { "model": "testmod:block/miniframe_up_s"},
    "facing=up,rotated=2": { "model": "testmod:block/miniframe_up_e"},
    "facing=up,rotated=3": { "model": "testmod:block/miniframe_up_w"},

    "facing=down,rotated=0": { "model": "testmod:block/miniframe_down_n"},
    "facing=down,rotated=1": { "model": "testmod:block/miniframe_down_s"},
    "facing=down,rotated=2": { "model": "testmod:block/miniframe_down_e"},
    "facing=down,rotated=3": { "model": "testmod:block/miniframe_down_w"},

    "facing=north,rotated=0": { "model": "testmod:block/miniframe_north_u" },
    "facing=north,rotated=1": { "model": "testmod:block/miniframe_north_d" },
    "facing=north,rotated=2": { "model": "testmod:block/miniframe_north_e" },
    "facing=north,rotated=3": { "model": "testmod:block/miniframe_north_w" },

    "facing=south,rotated=0": { "model": "testmod:block/miniframe_south_u"},
    "facing=south,rotated=1": { "model": "testmod:block/miniframe_south_d"},
    "facing=south,rotated=2": { "model": "testmod:block/miniframe_south_e"},
    "facing=south,rotated=3": { "model": "testmod:block/miniframe_south_w"},

    "facing=west,rotated=0": { "model": "testmod:block/miniframe_west_u"},
    "facing=west,rotated=1": { "model": "testmod:block/miniframe_west_d"},
    "facing=west,rotated=2": { "model": "testmod:block/miniframe_west_n"},
    "facing=west,rotated=3": { "model": "testmod:block/miniframe_west_s"},

    "facing=east,rotated=0": { "model": "testmod:block/miniframe_east_u"},
    "facing=east,rotated=1": { "model": "testmod:block/miniframe_east_d"},
    "facing=east,rotated=2": { "model": "testmod:block/miniframe_east_n"},
    "facing=east,rotated=3": { "model": "testmod:block/miniframe_east_s"}
  }
}

 

 

Link to comment
Share on other sites

That would still leavy me having to export multiple versions of the model in different rotations, as the X and Y rotations allo 0, 90, 180 and 270 each, giving me at max 16 combinations out of the 24 needed. Is there any way to use the transform property? I have tried adding it but it seems to have little effect (and its documentation is barely existing)

Link to comment
Share on other sites

1 hour ago, Heliarco said:

That would still leavy me having to export multiple versions of the model in different rotations, as the X and Y rotations allo 0, 90, 180 and 270 each, giving me at max 16 combinations out of the 24 needed. Is there any way to use the transform property? I have tried adding it but it seems to have little effect (and its documentation is barely existing)

Damn after stepping through the MC Code i can now 100% confirm that for model variants the ONLY properties that are used for rotation are the X and Y, nothing else, the transform field referred to here: https://gist.github.com/RainWarrior/0618131f51b8d37b80a6 

specifically does not apply to the main model. only to models in hand etc.

 

the relevant mc code (MASSIVELY abbreviated) basically does this when it encounters the transform element.

int i = JSONUtils.getInt(json, "x", 0);
int j = JSONUtils.getInt(json, "y", 0);
ModelRotation modelrotation = ModelRotation.getModelRotation(i, j);

 

I think my conclusion here is to just write a small script for Blockbench (the modelling tool i use) and have it generate all the models that way :/

 

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.