{
    "format_version": "1.16.100",
    "minecraft:block": {
        "description": {
            "identifier": "furnicraft:puerta_negro_2",
            "properties": {
                "door:direction": [ 2, 3, 4, 5 ],
                "door:toggle": [true, false],
                "door:log_side": [true, false]
            }
        },
        "components": {
		    "minecraft:creative_category": {
            "group": "itemGroup.name.furnicraft_puerta2",
            "category": "items"
		    },
            "minecraft:material_instances": {
                "*": {
                    "texture": "auto_negro",
                    "render_method": "alpha_test"
                }
            },
            "tag:door": {},
            "minecraft:pick_collision": {
                "origin": [-8, 0, -8],
                "size": [16, 16, 1]
            },
            "minecraft:entity_collision": {
                "origin": [-8, 0, -8],
                "size": [16, 16, 1]
            },
            "minecraft:loot": "loot_tables/blocks/puerta2/negro.json",
            "minecraft:geometry": "geometry.puerta_norte",
            "minecraft:destroy_time": 2,
            "minecraft:breakonpush": true,
            "minecraft:on_player_placing": {
                "event": "facing_direction"
            },
            "minecraft:flammable": {
                "flame_odds": 0,
                "burn_odds": 0
            },
            "minecraft:block_light_emission": 0.0,
            "minecraft:block_light_absorption": 0.2
        },
        "events": {
            "facing_direction": {
                "sequence": [
                    {
                        "set_block_property": {
                            "door:direction": "(query.cardinal_facing_2d)"
                        }
                    },
                    {
                        "condition": "query.is_sneaking",
                        "set_block_property": {
                            "door:log_side": false
                        }
                    },
                    {
                        "trigger": {
                            "event": "close_collision",
                            "target": "self"
                        }
                    }
                ]
            },
            "door_open": {
                "sequence": [
                    {
                        "set_block_property": {
                            "door:toggle": "query.block_property('door:toggle') ? false : true"
                        }
                    },
                    {
                        "run_command": {
                            "command": [ "playsound random.door_open @a[r=5] ~ ~ ~ 0.4 1.0" ]
                        }
                    },
                    {
                        "trigger": {
                            "event": "open_collision",
                            "target": "self"
                        }
                    }
                ]
            },
            "door_close": {
                "sequence": [
                    {
                        "set_block_property": {
                            "door:toggle": "query.block_property('door:toggle') ? false : true"
                        }
                    },
                    {
                        "run_command": {
                            "command": [ "playsound random.door_close @a[r=5] ~ ~ ~ 0.4 1.0" ]
                        }
                    },
                    {
                        "trigger": {
                            "event": "close_collision",
                            "target": "self"
                        }
                    }
                ]
            },
            "close_collision": {
                "sequence": [
                    {
                        "condition": "query.block_property('door:direction') == 2",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_south",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    },
                    {
                        "condition": "query.block_property('door:direction') == 3",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_north",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    },
                    {
                        "condition": "query.block_property('door:direction') == 4",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_east",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    },
                    {
                        "condition": "query.block_property('door:direction') == 5",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_west",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    }
                ]
            },
            "open_collision": {
                "sequence": [
                    {
                        "condition": "query.block_property('door:direction') == 2",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_west_2",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    },
                    {
                        "condition": "query.block_property('door:direction') == 3",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_east_2",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    },
                    {
                        "condition": "query.block_property('door:direction') == 4",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_south_2",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    },
                    {
                        "condition": "query.block_property('door:direction') == 5",
                        "set_block_at_pos": {
                            "block_type": "furnicraft:door_north_2",
                            "block_offset": [ 0, 1, 0 ]
                        }
                    }
                ]
            }
        },
        "permutations": [
            {
                "condition": "query.block_property('door:direction') == 2",
                "components": {
                    "minecraft:pick_collision": {
                        "origin": [-8, 0, 7],
                        "size": [16, 16, 1]
                    },
                    "minecraft:entity_collision": {
                        "origin": [-8, 0, 7],
                        "size": [16, 16, 1]
                    },
                    "minecraft:geometry":"geometry.puerta_sur"
                }
            },
            {
                "condition":"query.block_property('door:direction') == 3",
                "components": {
                    "minecraft:pick_collision": {
                        "origin": [-8, 0, -8],
                        "size": [16, 16, 1]
                    },
                    "minecraft:entity_collision": {
                        "origin": [-8, 0, -8],
                        "size": [16, 16, 1]
                    },
                    "minecraft:geometry":"geometry.puerta_norte"
                }
            },
            {
                "condition":"query.block_property('door:direction') == 4",
                "components": {
                    "minecraft:pick_collision": {
                        "origin": [-8, 0, -8],
                        "size": [1, 16, 16]
                    },
                    "minecraft:entity_collision": {
                        "origin": [-8, 0, -8],
                        "size": [1, 16, 16]
                    },
                    "minecraft:geometry": "geometry.puerta_este"
                }
            },
            {
                "condition":"query.block_property('door:direction') == 5",
                "components": {
                    "minecraft:pick_collision": {
                        "origin": [7, 0, -8],
                        "size": [1, 16, 16]
                    },
                    "minecraft:entity_collision": {
                        "origin": [7, 0, -8],
                        "size": [1, 16, 16]
                    },
                    "minecraft:geometry":"geometry.puerta_oeste"
                }
            },
            {
                "condition": "query.block_property('door:toggle') == false",
                "components": {
                    "minecraft:rotation": [0, 90, 0],
                    "minecraft:on_interact": {
                        "event": "door_close"
                    }
                }
            },
            {
                "condition": "query.block_property('door:toggle') == true",
                "components": {
                    "minecraft:rotation": [0, 0, 0],
                    "minecraft:on_interact": {
                        "event": "door_open"
                    }
                }
            },
            {
                "condition": "query.block_property('door:log_side') == false",
                "components": {
                    "minecraft:material_instances": {
                        "*": {
                            "texture": "auto_negro",
                            "render_method": "alpha_test"
                        }
                    }
                }
            }
        ]
    }
}