{
    "format_version": "1.20.10",
    "minecraft:entity": {
        "description": {
            "identifier": "dds_camping:guide_book",
            "is_summonable": true,
            "is_spawnable": true,
            "properties": {
                "dds_camping:page": {
                    "client_sync": true,
                    "type": "int",
                    "default": 0,
                    "range": [
                        0,
                        17
                    ]
                }
            }
        },
        "component_groups": {
			"dds_camping:despawn_timer": {
				"minecraft:timer": {
                    "time": 0.6,
                    "looping": false,
                    "time_down_event": {
                        "event": "dds_camping:despawn",
                        "target": "self"
                    }
                }
            },
            "dds_camping:despawn": {
                "minecraft:spawn_entity": {
                    "entities": [
                        {
                            "single_use": true,
                            "min_wait_time": 0,
                            "max_wait_time": 0,
                            "spawn_item": "dds_camping:guide_book_spawn_egg"
                        }
                    ]
                },
                "minecraft:instant_despawn": {}
            }
        },
        "components": {
            "minecraft:type_family": {
                "family": [
                    "guide_book"
                ]
            },
            "minecraft:collision_box": {
                "height": 0,
                "width": 0
            },
            "minecraft:damage_sensor": {
                "triggers": [
                    {
                        "cause": "entity_attack",
                        "on_damage": {
                            "filters": {
                                "all_of": [
                                    {
                                        "test": "is_family",
                                        "subject": "other",
                                        "value": "player"
                                    },
                                    {
                                        "test": "is_sneaking",
                                        "subject": "other",
                                        "value": false
                                    }
                                ]
                            },
                            "event": "dds_camping:guide_book_back"
                        },
                        "deals_damage": false
                    },
                    {
                        "deals_damage": false
                    }
                ]
            },
            "minecraft:custom_hit_test": {
                "hitboxes": [
                    {
                        "width": 2,
                        "height": 2,
                        "pivot": [
                            0,
                            1,
                            0
                        ]
                    }
                ]
            },
            "minecraft:interact": {
                "interactions": [
                    {
                        "on_interact": {
                            "filters": [
                                {
                                    "all_of": [
                                        {
                                            "test": "is_sneaking",
                                            "subject": "other",
                                            "value": true
                                        }
                                    ]
                                }
                            ],
                            "event": "dds_camping:despawn_timer"
                        },
                        "cooldown": 0.8,
                        "use_item": false,
                        "interact_text": "action.interact.dds_camping.previous_page"
                    },
                    {
                        "on_interact": {
                            "filters": [
                                {
                                    "all_of": [
                                        {
                                            "test": "is_sneaking",
                                            "subject": "other",
                                            "value": false
                                        }
                                    ]
                                }
                            ],
                            "event": "dds_camping:guide_book_forward"
                        },
                        "cooldown": 0.8,
                        "use_item": false,
                        "interact_text": "action.interact.dds_camping.next_page"
                    }
                ]
            },
            "minecraft:equipment": {
                "table": "loot_tables/dds/camping/guidebook.json"
            },
            "minecraft:physics": {}
        },
        "events": {
            "dds_camping:despawn_timer": {
                "add": {
                    "component_groups": [
                        "dds_camping:despawn_timer"
                    ]
                },
				"queue_command": {
                    "command":"playanimation @s close"
                }
            },
			"dds_camping:despawn": {
                "add": {
                    "component_groups": [
                        "dds_camping:despawn"
                    ]
                }
            },
            "dds_camping:guide_book_back": {
                "set_property": {
                    "dds_camping:page": "q.property('dds_camping:page') > 0 ? q.property('dds_camping:page') - 1 : 17"
                },
                "queue_command": {
                    "command":"playanimation @s backward"
                }
            },
            "dds_camping:guide_book_forward": {
                "set_property": {
                    "dds_camping:page": "q.property('dds_camping:page') < 17 ? q.property('dds_camping:page') + 1 : 0"
                },
                "queue_command": {
                    "command":"playanimation @s forward"
                }
            }
        }
    }
}