{
  "format_version": "1.21.80",
  "minecraft:block": {
    "description": {
      "identifier": "mnp_ci:palm_fence",
      "menu_category": {
        "category": "none"
      },
      "states": {
        "mnp_ci:post": [0, 1],
        "mnp_ci:north_picket": [0, 1],
        "mnp_ci:south_picket": [0, 1],
        "mnp_ci:east_picket": [0, 1],
        "mnp_ci:west_picket": [0, 1]
      }
    },
    "permutations": [
      // Collision and selection boxes for all possible combinations of fences.
      {
        "condition": "q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 0, -8],
            "size": [10, 16, 10]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -8],
            "size": [10, 16, 10]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -8],
            "size": [10, 16, 10]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -8],
            "size": [10, 16, 10]
          }
        }
      },
      {
        "condition": "!q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 0, -2],
            "size": [10, 16, 10]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -2],
            "size": [10, 16, 10]
          }
        }
      },
      {
        "condition": "!q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -2],
            "size": [10, 16, 10]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -2],
            "size": [10, 16, 10]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -2],
            "size": [8, 16, 8]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -8],
            "size": [16, 16, 16]
          }
        }
      },
      {
        "condition": "!q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, 2],
            "size": [4, 16, -4]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -2],
            "size": [4, 16, 4]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -4],
            "size": [7, 16, 8]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -8],
            "size": [10, 16, 16]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-4, 0, -4],
            "size": [6, 16, 8]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -8],
            "size": [10, 16, 16]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-4, 0, -4],
            "size": [8, 16, 6]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -8],
            "size": [16, 16, 10]
          }
        }
      },
      {
        "condition": "!q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-4, 0, -2],
            "size": [8, 16, 7]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -2],
            "size": [16, 16, 10]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -8],
            "size": [4, 16, 10]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -8],
            "size": [4, 16, 10]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -2],
            "size": [4, 16, 10]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -2],
            "size": [4, 16, 10]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:east_picket') && !q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 0, -2],
            "size": [10, 16, 4]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -2],
            "size": [10, 16, 4]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket') && !q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -2],
            "size": [10, 16, 4]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -2],
            "size": [10, 16, 4]
          }
        }
      },
      {
        "condition": "q.block_state('mnp_ci:north_picket') && q.block_state('mnp_ci:south_picket') && !q.block_state('mnp_ci:west_picket') && !q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-2, 0, -8],
            "size": [4, 16, 16]
          },
          "minecraft:selection_box": {
            "origin": [-2, 0, -8],
            "size": [4, 16, 16]
          }
        }
      },
      {
        "condition": "!q.block_state('mnp_ci:north_picket') && !q.block_state('mnp_ci:south_picket') && q.block_state('mnp_ci:west_picket') && q.block_state('mnp_ci:east_picket')",
        "components": {
          "minecraft:collision_box": {
            "origin": [-8, 0, -2],
            "size": [16, 16, 4]
          },
          "minecraft:selection_box": {
            "origin": [-8, 0, -2],
            "size": [16, 16, 4]
          }
        }
      }
    ],
    "components": {
      "minecraft:geometry": {
        "identifier": "geometry.mnp_ci.fence",
        "bone_visibility": {
          // Enables and disables bones according to the fence's block states.
          "post": "!q.block_state('mnp_ci:post')",
          "north_picket": "q.block_state('mnp_ci:north_picket')",
          "south_picket": "q.block_state('mnp_ci:south_picket')",
          "east_picket": "q.block_state('mnp_ci:east_picket')",
          "west_picket": "q.block_state('mnp_ci:west_picket')"
        }
      },
      "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:loot": "loot_tables/mnp_ci/palm_tree/palm_fence.json", // Drops the inventory fence block when the block is destroyed.
      "minecraft:flammable": {
        // Makes the fences flammable.
        "catch_chance_modifier": 5,
        "destroy_chance_modifier": 20
      },
      "minecraft:tick": {
        "interval_range": [3, 3]
      },
      "minecraft:custom_components": ["mnp_ci:on_fence_player_destroy", "mnp_ci:on_fence_interact", "mnp_ci:on_fence_tick"],
      "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')"
            }
          }
        ]
      },
      "tag:fence": {},
      "minecraft:material_instances": {
        "*": {
          "texture": "mnp_ci:palm_tree_planks",
          "render_method": "alpha_test_to_opaque"
        }
      }
    }
  }
}
