Jump to content

[1.10.2] display section in Forge Blockstate file doesn't work


Guest

Recommended Posts

In my mod I am using OBJ models for the guns which means that I have to use a Forge Blockstate file to apply transformations to the model. To find the best values I used the ItemTransformHelper mod. When I put the display section it generated into the Blockstate file, the model does load but it is not translated, scaled or rotated in any way. Do I need to create a custom implementation of the OBJModel class to be able to do this or is there a dumb mistake in the Blockstate file?

 

This is the important part of my Blockstate file:

{
    "forge_marker": 1,
    "defaults": {

    },
    "variants": {
        "gun":
        {
            ...,
            "mp7":           {
                "model": "rssmc:gun/item_gun_mp7.obj",
                "display": {
                    "thirdperson_righthand": {
                        "rotation": [ 0, 180, 0 ],
                        "translation": [ -1.25, -1.50, -3.25 ],
                        "scale": [ 0.20, 0.20, 0.20 ]
                    },
                    "thirdperson_lefthand": {
                        "rotation": [ 0, 0, 0 ],
                        "translation": [ 0.00, 0.00, 0.00 ],
                        "scale": [ 1.00, 1.00, 1.00 ]
                    },
                    "firstperson_righthand": {
                        "rotation": [ 0, 180, 0 ],
                        "translation": [ -3.75, -0.75, -6.75 ],
                        "scale": [ 0.30, 0.30, 0.30 ]
                    },
                    "firstperson_lefthand": {
                        "rotation": [ 0, 0, 0 ],
                        "translation": [ 0.00, 0.00, 0.00 ],
                        "scale": [ 1.00, 1.00, 1.00 ]
                    },
                    "gui": {
                        "rotation": [ 26, 218, 0 ],
                        "translation": [ -4.50, -0.25, 0.00 ],
                        "scale": [ 0.20, 0.20, 0.20 ]
                    },
                    "head": {
                        "rotation": [ 0, 0, 0 ],
                        "translation": [ 0.00, 0.00, 0.00 ],
                        "scale": [ 1.00, 1.00, 1.00 ]
                    },
                    "fixed": {
                        "rotation": [ 0, 90, 0 ],
                        "translation": [ 4.75, -1.00, -0.75 ],
                        "scale": [ 0.15, 0.15, 0.15 ]
                    },
                    "ground": {
                        "rotation": [ 0, 0, 0 ],
                        "translation": [ 1.75, 2.50, 5.00 ],
                        "scale": [ 0.20, 0.20, 0.20 ]
                    }
                }
            },
          ...
        }
    }
}

 

Link to comment
Share on other sites

Forge's blockstates file doesn't use that format for display transformations, only Vanilla item models do.

 

I briefly explain display transformations in Forge's blockstates format here:

On 15/08/2017 at 0:02 PM, Choonster said:

I think you can specify a base TRSRTransformation for a model using Forge's blockstates format. Set the "transform" key of a variant to an object with either a single "matrix" key or some combination of "translation", "rotation", "scale" and/or "post-rotation" keys. You can see a simple example here in RFTools and a slightly more complex example here in a Forge test mod.

 

Look at ForgeBlockStateV1.TRSRDeserializer to see how Forge deserialises TRSRTransformations.

 

In addition to specifying a base TRSRTransformation in the "transform" object, you can specify a TRSRTransformation for each ItemCameraTransforms.TransformType ("thirdperson_righthand", "firstperson_lefthand", "gui", etc.). The complex example I linked in the quoted post uses this to specify a TRSRTransformation for "thirdperson" (which Forge treats as an alias of "thirdperson_righthand") and "gui".

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.

Link to comment
Share on other sites

I tried it and the transforms seem really off. When I use the data I would have used inside the model if it was a json model, the scaling, translation and rotation are completely off. Does the Forge Blockstate transform the item differently or am I making a dumb mistake again?

 

This is the new Blockstate file:

{
    "forge_marker": 1,
    "defaults": {

    },
    "variants": {
        "gun":
        {
            ...,
            "mp7":           {
                "model": "rssmc:gun/item_gun_mp7.obj",
                "transform": {
                    "thirdperson_righthand": {
                        "rotation": [ {"x": 0}, {"y": 180}, {"z": 0} ],
                        "translation": [ -1.25, -1.50, -3.25 ],
                        "scale": 0.20
                    },
                    "firstperson_righthand": {
                        "rotation": [ {"x": 0}, {"y": 180}, {"z": 0} ],
                        "translation": [ -3.75, -0.75, -6.75 ],
                        "scale": 0.30
                    },
                    "gui": {
                        "rotation": [ {"x": 26}, {"y": 218}, {"z": 0} ],
                        "translation": [ -4.50, -0.25, 0.00 ],
                        "scale": 0.20
                    },
                    "fixed": {
                        "rotation": [ {"x": 0}, {"y": 90}, {"z": 0} ],
                        "translation": [ 4.75, -1.00, -0.75 ],
                        "scale": 0.15
                    },
                    "ground": {
                        "rotation": [ {"x": 0}, {"y": 0}, {"z": 0} ],
                        "translation": [ 1.75, 2.50, 5.00 ],
                        "scale": 0.20
                    }
                }
            },
            ...
        }
    }
}

 

This is what I expect it to look like:

2017-09-09_14_55_43.thumb.png.677f6b7ab421342791d9b8fdb0c18831.png

 

This is what it looks like:

2017-09-09_14_55_55.thumb.png.b34359602dbca19b5b1ac69069f35c2c.png

Link to comment
Share on other sites

Yes, Forge's TRSRTransformation (used in Forge's blockstates format) is different to Vanilla's ItemTransformVec3f (used in Vanilla item models).

 

I don't fully understand the model system, but I think you can use the TRSRTransformation(ItemTransformVec3f) constructor to convert an ItemTransformVec3f to a TRSRTransformation. You can then use TRSRTransformation#getTranslationTRSRTransformation#getLeftRotTRSRTransformation#getScale and TRSRTransformation#getRightRot to get the values for the "translation", "rotation", "scale" and "post-rotation" keys in the blockstates file.

 

Forge has a method to convert an entire ItemCameraTransforms object into a Map<ItemCameraTransforms.TransformType, TRSRTransformation> (PerspectiveMapWrapper.getTransforms(ItemCameraTransforms)), but I don't think you want to use this because it converts each TRSRTransformation from centre-block to corner-block and Forge's blockstates loader applies the same conversion when loading the TRSRTransformations from the blockstates file (so you'd apply the conversion twice, probably resulting in incorrect values).

Edited by Choonster

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.

Link to comment
Share on other sites

This makes no sense to me. I tried simply calculating the correct values the way you suggested by doing

TRSRTransformation trsr = new TRSRTransformation(new ItemTransformVec3f(new Vector3f(0, 180, 0), new Vector3f(-1.25F, -1.5F, -3.25F), new Vector3f(.2F, .2F, .2F)));

but that did not work whatsoever. The translation and scale values I get out of this are the same as those I put in and the rotation value I get out of this is a strange negative value with a high negative exponent. Those values don't get me anywhere so it looks like I have to get the correct values by changing them in the file and reloading it over and over again which is really annoying.

Link to comment
Share on other sites

I remember having similar issues converting the Vanilla transform format to the Forge format back in 1.8.9, I never fully figured out how to solve them.

 

You could try calling TRSRTransformation.blockCenterToCorner or TRSRTransformation.blockCornerToCenter on the TRSRTransformation to see if that produces the correct values, but I'm not sure if it will.

 

Maybe someone with more knowledge of the model system can help 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.

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.