{
	"format_version": "1.20.60",
	"minecraft:entity": {
		"description": {
			"identifier": "cbcl_lc:guide_book",
			"is_spawnable": true,
			"is_summonable": true,
			"is_experimental": false,
			"spawn_category": "misc",
			"animations": {
				"controller": "controller.animation.cbcl_lc.guide_book",
				"sound_controller": "controller.animation.cbcl_lc.guide_book.sound",
				"change_page_sound": "animation.cbcl_lc.guide_book.change_page_sound",
				"spawn_sound": "animation.cbcl_lc.guide_book.spawn_sound"
			},
			"scripts": {
				"animate": ["controller", "sound_controller"]
			},
			"properties": {
				"cbcl_lc:page": {
					"client_sync": true,
					"default": 0,
					"type": "int",
					"range": [
						0,
						11 // set max page count
					]
				}
			}
		},
		"component_groups": {
			"page_up": {
				"minecraft:timer": {
					"time": 0.3,
					"looping": true,
					"time_down_event": {
						"event": "change_page_up",
						"target": "self"
					}
				},
				"minecraft:is_baby": {},
				"minecraft:is_saddled": {}
			},
			"page_down": {
				"minecraft:timer": {
					"time": 0.3,
					"looping": true,
					"time_down_event": {
						"event": "change_page_down",
						"target": "self"
					}
				},
				"minecraft:is_baby": {},
				"minecraft:is_illager_captain": {}
			},
			"collect": {
				"minecraft:is_sheared": {},
				"minecraft:timer": {
					"time": 0.3,
					"looping": true,
					"time_down_event": {
						"event": "cbcl_lc:despawn_event",
						"target": "self"
					}
				},
				"minecraft:spawn_entity": {
					"entities": {
						"min_wait_time": 0,
						"max_wait_time": 0,
						"spawn_sound": "plop",
						"spawn_item": "cbcl_lc:guide_book_spawn_egg",
						"num_to_spawn": 1,
						"single_use": true
					}
				}
			},
			"cbcl_lc:despawn": {
				"minecraft:instant_despawn": {}
			}
		},
		"components": {
			"minecraft:damage_sensor": {
				"triggers": [
					{
						"deals_damage": false,
						"on_damage": {
							"filters": {
								"all_of": [
									{
										"test": "is_family",
										"subject": "damager",
										"operator": "==",
										"value": "player"
									},
									{
										"test": "is_sneaking",
										"subject": "damager",
										"value": true
									},
									{
										"test": "has_component",
										"subject": "self",
										"operator": "!=",
										"value": "minecraft:is_sheared"
									}
								]
							},
							"target": "self",
							"event": "collect"
						}
					},
					{
						"deals_damage": false,
						"on_damage": {
							"filters": {
								"all_of": [
									{
										"test": "is_family",
										"subject": "damager",
										"value": "player"
									},
									{
										"test": "is_sneaking",
										"subject": "damager",
										"operator": "==",
										"value": false
									},
									{
										"test": "has_component",
										"subject": "self",
										"operator": "!=",
										"value": "minecraft:is_sheared"
									},
									{
										"test": "has_component",
										"subject": "self",
										"operator": "!=",
										"value": "minecraft:is_baby"
									}
								]
							},
							"target": "self",
							"event": "init_change_page_down"
						}
					},
					{
						"deals_damage": false
					}
				]
			},
			"minecraft:interact": {
				"interactions": [
					{
						"cooldown": 0.2,
						"interact_text": "cbcl_lc.guidebook.interact_action",
						"on_interact": {
							"filters": {
								"all_of": [
									{
										"test": "has_component",
										"subject": "self",
										"operator": "!=",
										"value": "minecraft:is_baby"
									}
								]
							},
							"target": "self",
							"event": "init_change_page_up"
						}
					}
				]
			},
			"minecraft:physics": {
				"has_collision": true,
				"has_gravity": true
			},
			"minecraft:health": {
				"value": 1,
				"max": 1
			},
			"minecraft:collision_box": {
				"width": 1,
				"height": 1
			}
		},
		"events": {
			"init_change_page_up": {
				"sequence": [
					{
						"add": {
							"component_groups": ["page_up"]
						}
					}
				]
			},
			"change_page_up": {
				"sequence": [
					{
						"remove": {
							"component_groups": ["page_up"]
						}
					},
					{
						"filters": {
							"test": "int_property",
							"domain": "cbcl_lc:page",
							"operator": ">=",
							"value": 11 //set max page value here
						},
						"set_property": {
							"cbcl_lc:page": "0"
						}
					},
					{
						"filters": {
							"test": "int_property",
							"domain": "cbcl_lc:page",
							"operator": "<",
							"value": 11 //set max page value here
						},
						"set_property": {
							"cbcl_lc:page": "q.property('cbcl_lc:page') + 1"
						}
					}
				]
			},
			"init_change_page_down": {
				"sequence": [
					{
						"add": {
							"component_groups": ["page_down"]
						}
					}
				]
			},
			"change_page_down": {
				"sequence": [
					{
						"remove": {
							"component_groups": ["page_down"]
						}
					},
					{
						"filters": {
							"test": "int_property",
							"domain": "cbcl_lc:page",
							"operator": "<=",
							"value": 0
						},
						"set_property": {
							"cbcl_lc:page": 11 //set max page value here
						}
					},
					{
						"filters": {
							"test": "int_property",
							"domain": "cbcl_lc:page",
							"operator": ">",
							"value": 0
						},
						"set_property": {
							"cbcl_lc:page": "q.property('cbcl_lc:page') - 1"
						}
					}
				]
			},
			"collect": {
				"add": {
					"component_groups": ["collect"]
				}
			},
			"cbcl_lc:despawn_event": {
				"add": {
					"component_groups": ["cbcl_lc:despawn"]
				}
			}
		}
	}
}
