{
  "format_version": "1.16.100",
  "minecraft:block": {
    "description": {
      "identifier": "darkgato:ginger_door_down",
      "properties": {
        "door:rotation": [ 2, 3, 4, 5 ],
        "door:mode": [ 0, 1 ]
      }
    },
    "components": {
      "minecraft:material_instances": {
        "*": {
          "texture": "ginger_door_down",
          "render_method": "blend"
        }
      },
      "minecraft:destroy_time": 1,
      "minecraft:explosion_resistance": 1,
      "minecraft:block_light_absorption": 0,
      "minecraft:placement_filter": {
        "conditions": [
          {
            "allowed_faces": [ "up" ]
          }
        ]
      },
      "minecraft:on_player_placing": {
        "event": "update_rotation"
      },
      "minecraft:on_placed": {
        "event": "set_block_up"
      },
      "minecraft:on_interact": {
        "event": "open_or_close"
      }
    },
    "permutations": [
      {
        "condition": "query.block_property('door:rotation') == 2",
        "components": {
          "minecraft:rotation": [ 0, -180, 0 ],
          "tag:darkgato:rotation2": {}
        }
      },
      {
        "condition": "query.block_property('door:rotation') == 3",
        "components": {
          "minecraft:rotation": [ 0, 0, 0 ],
          "tag:darkgato:rotation3": {}
        }
      },
      {
        "condition": "query.block_property('door:rotation') == 4",
        "components": {
          "minecraft:rotation": [ 0, -90, 0 ],
          "tag:darkgato:rotation4": {}
        }
      },
      {
        "condition": "query.block_property('door:rotation') == 5",
        "components": {
          "minecraft:rotation": [ 0, 90, 0 ],
          "tag:darkgato:rotation5": {}
        }
      },
      {
        "condition": "query.block_property('door:mode') == 0",
        "components": {
          "minecraft:geometry": "geometry.ginger_door_closed",
          "minecraft:pick_collision": {
            "size": [ 16, 16, 2 ],
            "origin": [ -8, 0, 6 ]
          },
          "minecraft:entity_collision": {
            "size": [ 16, 16, 2 ],
            "origin": [ -8, 0, 6 ]
          }
        }
      },
      {
        "condition": "query.block_property('door:mode') == 1",
        "components": {
          "minecraft:geometry": "geometry.ginger_door_open",
          "minecraft:pick_collision": {
            "size": [ 2, 16, 16 ],
            "origin": [ -8, 0, -8]
          },
          "minecraft:entity_collision": {
            "size": [ 2, 16, 16 ],
            "origin": [ -8, 0, -8 ]
          }
        }
      }
    ],
    "events": {
      "update_rotation": {
        "set_block_property": {
          "door:rotation": "query.cardinal_facing_2d"
        }
      },
      "set_block_up": {
        "run_command": {
          "command": [
            "fill ~ ~1 ~ ~ ~1 ~ darkgato:ginger_door_up 0 replace air 0"
          ]
        }
      },
      "open_or_close": {
        "sequence": [
          {
            "condition": "query.block_property('door:mode') == 0",
            "set_block_property": {
              "door:mode": 1
            },
            "run_command": {
              "command": [
                "playsound door.open @a[r=8]"
              ]
            }
          },
          {
            "condition": "query.block_property('door:mode') == 1",
            "set_block_property": {
              "door:mode": 0
            },
            "run_command": {
              "command": [
                "playsound door.close @a[r=8]"
              ]
            }
          }
        ]
      }
    }
  }
}