{
  "format_version": "1.21.80",
  "minecraft:block": {
    "description": {
      "identifier": "mnp_ci:palm_door",
      "menu_category": {
        "category": "none"
      },
      "traits": {
        "minecraft:placement_direction": {
          "enabled_states": ["minecraft:cardinal_direction"]
        }
      },
      "states": {
        "mnp_ci:door_open_bit": [false, true],
        "mnp_ci:door_upper_block_bit": [false, true],
        "mnp_ci:door_hinge_bit": [false, true]
      }
    },
    "permutations": [
      {
        "condition": "query.block_state('minecraft:cardinal_direction') == 'north'",
        "components": {
          "minecraft:transformation": {
            "rotation": [0, 0, 0]
          }
        }
      },
      {
        "condition": "query.block_state('minecraft:cardinal_direction') == 'south'",
        "components": {
          "minecraft:transformation": {
            "rotation": [0, 180, 0]
          }
        }
      },
      {
        "condition": "query.block_state('minecraft:cardinal_direction') == 'east'",
        "components": {
          "minecraft:transformation": {
            "rotation": [0, 270, 0]
          }
        }
      },
      {
        "condition": "query.block_state('minecraft:cardinal_direction') == 'west'",
        "components": {
          "minecraft:transformation": {
            "rotation": [0, 90, 0]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:door_open_bit') && !q.block_state('mnp_ci:door_hinge_bit')",
        "components": {
          "minecraft:collision_box": {
            "origin": [5, 0, -8],
            "size": [3, 16, 16]
          },
          "minecraft:selection_box": {
            "origin": [5, 0, -8],
            "size": [3, 16, 16]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:door_open_bit') && q.block_state('mnp_ci:door_hinge_bit')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 0, -8],
            "size": [3, 16, 16]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -8],
            "size": [3, 16, 16]
          }
        }
      },
      // Bottom Block - FIXED: Ensure interaction component is included
      {
        "condition": "!q.block_state('mnp_ci:door_upper_block_bit')",
        "components": {
          "minecraft:custom_components": ["mnp_ci:door_on_place", "mnp_ci:door_on_interact", "mnp_ci:door_on_tick"],
          "minecraft:material_instances": {
            "*": {
              "texture": "mnp_ci:palm_door_lower",
              "render_method": "blend"
            }
          }
        }
      },
      // Top Block - FIXED: Ensure interaction component is included
      {
        "condition": "q.block_state('mnp_ci:door_upper_block_bit')",
        "components": {
          "minecraft:custom_components": ["mnp_ci:door_on_interact", "mnp_ci:door_on_tick"],
          "minecraft:material_instances": {
            "*": {
              "texture": "mnp_ci:palm_door_top",
              "render_method": "blend"
            }
          }
        }
      }
    ],
    "components": {
      // IMPORTANT: Keep the interaction component in base components too
      "minecraft:custom_components": ["mnp_ci:door_on_interact", "mnp_ci:door_on_tick"],
      "minecraft:collision_box": {
        "origin": [-8, 0, 5],
        "size": [16, 16, 3]
      },
      "minecraft:selection_box": {
        "origin": [-8, 0, 5],
        "size": [16, 16, 3]
      },
      "minecraft:loot": "loot_tables/mnp_ci/palm_tree/palm_door.json",
      "minecraft:tick": {
        "interval_range": [3, 3]
      },
      "minecraft:liquid_detection": {
        "detection_rules": [
          {
            "liquid_type": "water",
            "can_contain_liquid": true, // Waterloggable
            "on_liquid_touches": "no_reaction" // Water flows through the block like air
          }
        ]
      },
      "minecraft:flammable": {
        "catch_chance_modifier": 5,
        "destroy_chance_modifier": 20
      },
      "minecraft:destructible_by_mining": {
        "seconds_to_destroy": 3,
        "item_specific_speeds": [
          {
            "destroy_speed": 1.5,
            "item": {
              "tags": "q.all_tags('minecraft:is_axe', 'minecraft:wooden_tier')"
            }
          },
          {
            "destroy_speed": 0.75,
            "item": {
              "tags": "q.all_tags('minecraft:is_axe', 'minecraft:stone_tier')"
            }
          },
          {
            "destroy_speed": 0.5,
            "item": {
              "tags": "q.all_tags('minecraft:is_axe', 'minecraft:iron_tier')"
            }
          },
          {
            "destroy_speed": 0.25,
            "item": {
              "tags": "q.all_tags('minecraft:is_axe', 'minecraft:golden_tier')"
            }
          },
          {
            "destroy_speed": 0.4,
            "item": {
              "tags": "q.all_tags('minecraft:is_axe', 'minecraft:diamond_tier')"
            }
          },
          {
            "destroy_speed": 0.35,
            "item": {
              "tags": "q.all_tags('minecraft:is_axe', 'minecraft:netherite_tier')"
            }
          }
        ]
      },
      "minecraft:destructible_by_explosion": {
        "explosion_resistance": 3
      },
      "minecraft:geometry": {
        "identifier": "geometry.mnp_ci.door",
        "bone_visibility": {
          "door_open": "q.block_state('mnp_ci:door_open_bit') && !q.block_state('mnp_ci:door_hinge_bit')",
          "door_closed": "!q.block_state('mnp_ci:door_open_bit') && !q.block_state('mnp_ci:door_hinge_bit')",
          "door_open_flipped": "q.block_state('mnp_ci:door_open_bit') && q.block_state('mnp_ci:door_hinge_bit')",
          "door_closed_flipped": "!q.block_state('mnp_ci:door_open_bit') && q.block_state('mnp_ci:door_hinge_bit')"
        }
      },
      "minecraft:material_instances": {
        "*": {
          "texture": "mnp_ci:palm_door_lower",
          "render_method": "blend"
        }
      }
    }
  }
}
