{
  "format_version": "1.20.71",
  "minecraft:entity": {
    "description": {
      "identifier": "mythicus_im:hdc.guidebook",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false,

      "properties": {

        "mythicus_im:is_despawning": {
          "type": "bool",
          "default": false,
          "client_sync": true
        },

        "mythicus_im:page": {
          "type": "int",
          "range": [ 0, 11 ],
          "default": 0,
          "client_sync": true
        }

      }

    },

    "component_groups": {
      
      "mythicus_im:instant_despawn": { "minecraft:instant_despawn": {} },

      "mythicus_im:despawn.start": { 
        "minecraft:timer": {
          "looping": true,
          "time": 1.00,
          "time_down_event": {
            "event": "mythicus_im:despawn.finish"
          }
        }
      }

    },

    "components": {
      
      "minecraft:collision_box": {
        "width": 0.0,
        "height": 0.0
      },
      "minecraft:custom_hit_test": {
        "hitboxes": [
          {
            "width": 1.5,
            "height": 1.5,
            "pivot": [
              0,
              0.75,
              0
            ]
          }
        ]
      },
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": {
                "all_of": [
                  { "test": "is_family", "subject": "other", "value": "player" },
                  { "test": "is_sneaking", "subject": "other", "value": false }
                ]
              },
              "event": "mythicus_im:page.next"
            },
            "deals_damage": false
          },
          {
            "on_damage": {
              "filters": {
                "all_of": [
                  { "test": "is_family", "subject": "other", "value": "player" },
                  { "test": "is_sneaking", "subject": "other", "value": true }
                ]
              },
              "event": "mythicus_im:despawn.start"
            },
            "deals_damage": false
          },
          {
            "cause": "all",
            "deals_damage": false
          }
        ]
      },
      "minecraft:health": {
        "value": 100,
        "min": 100,
        "max": 100
      },
      "minecraft:persistent": {
      },
      "minecraft:knockback_resistance": {
        "value": 1,
        "max": 1
      },
      //"minecraft:push_through": {
      //  "value": 1
      //},
      "minecraft:pushable": {
        "is_pushable": false,
        "is_pushable_by_piston": false
      },
      "minecraft:physics": {
        "has_gravity": false,
        "has_collision": false
      },

      "minecraft:interact": {
        "interactions": [
          {
            "on_interact": {
              "filters": { "test": "is_family", "subject": "other", "value": "player" },
              "event": "mythicus_im:page.prev",
              "target": "self"
            },
            "swing": true,
            "play_sounds": "ignite"
          }
        ]
      }

    },

    "events": {

      "mythicus_im:instant_despawn": { "add": { "component_groups": [ "mythicus_im:instant_despawn" ] } },

      "mythicus_im:despawn.start": {
        "sequence": [
          { 
            "filters": { "test": "bool_property", "domain": "mythicus_im:is_despawning", "value": false },
            "set_property": { "mythicus_im:is_despawning": true },
            "add": { "component_groups": [ "mythicus_im:despawn.start" ] }
          }
        ]
      },
      "mythicus_im:despawn.finish": {
        "queue_command": { "command": [ "loot spawn ~ ~ ~ loot \"mythicus/hdc/entity/guidebook\"" ] },
        "add": { "component_groups": [ "mythicus_im:instant_despawn" ] }
      },



      //"mythicus_im:page.next": {
      //  "sequence": [
      //    { 
      //      "filters": { "test": "int_property", "domain": "mythicus_im:page", "operator": "<", "value": 10 },
      //      "set_property": { "mythicus_im:page": "q.property('mythicus_im:page') + 1" }
      //    },
      //    { 
      //      "filters": { "test": "int_property", "domain": "mythicus_im:page", "operator": ">=", "value": 10 },
      //      "set_property": { "mythicus_im:page": 0 }
      //    }
      //  ]
        
      //}

      "mythicus_im:page.next": {
        "set_property": { "mythicus_im:page": "q.property('mythicus_im:page') + 1" }
      },
      "mythicus_im:page.prev": {
        "set_property": { "mythicus_im:page": "q.property('mythicus_im:page') - 1" }
      }

    }

  }
}