{
  "format_version": "1.17.40",
  "minecraft:entity": {
    "description": {
      "identifier": "oct_spcrs:car_manual",
      "is_spawnable": false,
      "is_summonable": true,
      "is_experimental": false,
      "properties": {
        "oct_spcrs:page_id": {
          "client_sync": true,
          "type": "int",
          "default": 0,
          "range": [
            0,
            32
          ]
        },
        "oct_spcrs:drop_egg": {
          "client_sync": true,
          "type": "bool",
          "default": false
        }
      }
    },
    "components": {
      //Stats
      "minecraft:type_family": {
        "family": [
          "oct_spcrs_car_manual",
          "oct_spcrs"
        ]
      },
      "minecraft:collision_box": {
        "width": 0.8,
        "height": 1.2
      },
      "minecraft:scale": {
        "value": 1.0
      },
      "minecraft:damage_sensor": {
        "triggers": [
          { // Previous Page
            "cause": "entity_attack",
            "on_damage": {
              "filters": [
                {
                  "all_of": [
                    {
                      "test": "is_family",
                      "subject": "other",
                      "value": "player"
                    },
                    {
                      "test": "bool_property",
                      "subject": "self",
                      "domain": "oct_spcrs:drop_egg",
                      "operator": "==",
                      "value": false
                    }
                  ]
                }
              ],
              "target": "self",
              "event": "oct_spcrs:page_id.previous"
            },
            "deals_damage": false
          },
          { //cancel damage
            "cause": "all",
            "deals_damage": false
          }
        ]
      },
      "minecraft:health": {
        "value": 1,
        "max": 1,
        "min": 1
      },
      "minecraft:knockback_resistance": {
        "value": 1,
        "max": 1
      },
      "minecraft:interact": {
        "interactions": [
          { // Next Page
            "on_interact": {
              "filters": [
                {
                  "all_of": [
                    {
                      "test": "is_family",
                      "subject": "other",
                      "value": "player"
                    },
                    {
                      "test": "is_sneaking",
                      "subject": "other",
                      "operator": "==",
                      "value": false
                    },
                    {
                      "test": "bool_property",
                      "subject": "self",
                      "domain": "oct_spcrs:drop_egg",
                      "operator": "==",
                      "value": false
                    }
                  ]
                }
              ],
              "target": "self",
              "event": "oct_spcrs:page_id.next"
            },
            "swing": true,
            "interact_text": "action.interact.oct_spcrs.book_next"
          },
          { // Close Book
            "on_interact": {
              "filters": [
                {
                  "all_of": [
                    {
                      "test": "is_family",
                      "subject": "other",
                      "value": "player"
                    },
                    {
                      "test": "is_sneaking",
                      "subject": "other",
                      "operator": "==",
                      "value": true
                    },
                    {
                      "test": "bool_property",
                      "subject": "self",
                      "domain": "oct_spcrs:drop_egg",
                      "operator": "==",
                      "value": false
                    }
                  ]
                }
              ],
              "target": "self",
              "event": "oct_spcrs:drop_egg"
            },
            "swing": true,
            "interact_text": "action.interact.oct_spcrs.book_close"
          }
        ]
      },
      "minecraft:physics": {
        "has_gravity": true,
        "has_collision": true
      },
      "minecraft:pushable": {
        "is_pushable": false,
        "is_pushable_by_piston": false
      },
      "minecraft:conditional_bandwidth_optimization": {}
    },
    "component_groups": {
      "oct_spcrs:despawn": {
        "minecraft:instant_despawn": {}
      }
    },
    "events": {
      "oct_spcrs:despawn": {
        "add": {
          "component_groups": [
            "oct_spcrs:despawn"
          ]
        }
      },
      "oct_spcrs:drop_egg": {
        "queue_command": {
          "command": "scriptevent oct_spcrs:drop_egg manual_egg"
        },
        "set_property": {
          "oct_spcrs:drop_egg": true
        }
      },
      "oct_spcrs:page_id.next": {
        "set_property": {
          "oct_spcrs:page_id": "q.property('oct_spcrs:page_id') < 24 ? (q.property('oct_spcrs:page_id') + 1) : 0"
        }
      },
      "oct_spcrs:page_id.previous": {
        "set_property": {
          "oct_spcrs:page_id": "q.property('oct_spcrs:page_id') > 0 ? (q.property('oct_spcrs:page_id') - 1) : 24"
        }
      }
    }
  }
}