#Block Rotating Incorrectly

1 messages · Page 1 of 1 (latest)

remote eagle
#
    "format_version": "1.19.50",
    "minecraft:block": {
        "description": {
            "identifier": "agentt:large_keg",
            "menu_category": {
                "category": "construction"
            },
            "properties": {
                "agentt:block_rotation": [
                    0,
                    1,
                    2,
                    3
                ]
            }
        },
        "permutations": [
            {
                "condition": "query.block_property('agentt:block_rotation') == 0",
                "components": {
                    "minecraft:rotation": [
                        0,
                        0,
                        0
                    ]
                }
            },
            {
                "condition": "query.block_property('agentt:block_rotation') == 1",
                "components": {
                    "minecraft:rotation": [
                        0,
                        90,
                        0
                    ]
                }
            },
            {
                "condition": "query.block_property('agentt:block_rotation') == 2",
                "components": {
                    "minecraft:rotation": [
                        0,
                        180,
                        0
                    ]
                }
            },
            {
                "condition": "query.block_property('agentt:block_rotation') == 3",
                "components": {
                    "minecraft:rotation": [
                        0,
                        270,
                        0
                    ]
                }
            },
            {
                "condition": "query.block_property('agentt:block_rotation') == 3",
                "components": {
                    "minecraft:rotation": [
                        0,
                        270,
                        0
                    ]
                }
            }
        ],
        "components": {
            "minecraft:on_player_placing": {
                "event": "agentt:update_rotation"
            },
            "minecraft:geometry": "geometry.large_keg",
            "minecraft:material_instances": {
                "*": {
                    "texture": "agentt_large_keg",
                    "render_method": "alpha_test"
                }
            }
        },
        "events": {
            "agentt:update_rotation": {
                "set_block_property": {
                    "agentt:block_rotation": "math.floor(query.block_face/2)"
                }
            }
        }
    }
}```
distant owl
#

In your events you use math.floor which will round down the value you'll get to the nearest integer. Then you have query.block_face / 2, what you did here is you divide by 2 the value it'll return. For example you get the value of 1 (which is up) it'll return to 1 / 2 which is 0.5, then rounding it down you'll get 0.

So basically your Molang is wrong. In what you're trying to achieve, you need query.cardinal_facing_2d this query ignores up/down, and it'll place depend on where the player is facing. query.block_face depend on which face of block the player place it at.

This is what you only need query.cardinal_facing_2d

#

Also, in format_version 1.20.10+, we have traits. Use it instead, it's better and easier.

remote eagle
distant owl
#

Remove math.floor, you don't need to round down

remote eagle
#

oh ok

#

do i have to change the rotations

remote eagle
distant owl
#

Maybe your rotation in permutation is wrong. By default where your block is facing at?

#

Your geometry model, where it is facing?

abstract imp
#

default north (X+ ig)

remote eagle
distant owl
#

In that case your default is north. So the rotation for north should be [ 0, 0, 0], its opposite is south so [ 0, 180, 0 ] for south. For west [ 0, 90, 0], and for east is [ 0, -90, 0 ]

#

Hence you use query.cardinal_facing_2d remember these values.

0 = down
1 = up
2 = north
3 = south
4 = west
5 = east
6 = undefined

Hence that query ignores up and down, so you can remove 0 and 1, you only need 2, 3, 4, 5.

#

@remote eagle

#

Making rotation for block is much easier when you use traits instead.

remote eagle
#

for traits

distant owl
#

Yes, but I recommend to always use the latest format_version which is 1.20.30.