{
	"format_version": "1.20.50",
	"minecraft:entity": {
		"description": {
			"identifier": "eddieworks:sewing_machine",
			"is_summonable": true
		},
		"component_groups": {
			"destroy_timer": {
				"minecraft:timer": {
					"time": 0.5, "looping": false,
					"time_down_event": { "event": "sewing:intact" }
				}
			},
			"has_nothing": 			{ "minecraft:mark_variant": { "value": 0 } },
			"has_crank": 			{ "minecraft:mark_variant": { "value": 1 } },
			"has_needle": 			{ "minecraft:mark_variant": { "value": 2 } },
			"has_crank_and_needle": {
				"minecraft:mark_variant": { "value": 3 },
				"minecraft:interact": {},
				"minecraft:economy_trade_table": {
					"display_name": "entity.eddieworks:sewing_machine.name",
					"table": "trading/sewing_machine.trade.json",
					"new_screen": true
				}
			},

			"intact": 		   { "minecraft:variant": { "value": 0 } },
			"destroy_stage_1": { "minecraft:variant": { "value": 1 } },
			"destroy_stage_2": { "minecraft:variant": { "value": 2 } },
			"destroy_stage_3": { "minecraft:variant": { "value": 3 } },
			"creative": {
				"minecraft:mark_variant": { "value": 4 },
				"minecraft:variant": { "value": 4 },
				"minecraft:interact": {},
				"minecraft:economy_trade_table": {
					"display_name": "entity.eddieworks:sewing_machine.name",
					"table": "trading/sewing_machine.trade.json",
					"new_screen": true
				}
			},

			"remove_machine": {
				"minecraft:behavior.sneeze": {
					"loot_table": "loot_tables/sewing_machine.loot.json",
					"prepare_time": 0,
					"probability": 1
				},
				"minecraft:instant_despawn": {}
			},
			"remove_in_creative": { "minecraft:instant_despawn": {} }
		},
		"components": {
			"minecraft:rideable": {
				"family_types": [ "sewing_collision" ],
				"seats": [ { "position": [ 0, 0, 0 ] } ]
			},
			"minecraft:addrider": {
				"entity_type": "eddieworks:sewing_machine_collision",
				"spawn_event": "sewing:machine"
			},
			"minecraft:fire_immune": {},
			"minecraft:collision_box": {
				"width": 0.6,
				"height": 0.7
			},
			"minecraft:custom_hit_test": {
				"hitboxes": [
					{
						"width": 0.6,
						"height": 0.7,
						"pivot": [ 0, 0, 0 ]
					}
				]
			},
			"minecraft:physics": {
				"has_collision": false,
				"has_gravity": false
			},
			"minecraft:pushable": {
				"is_pushable": false,
				"is_pushable_by_piston": false
			},
			"minecraft:interact": {
				"interactions": [
					{
						"on_interact": {
							"filters": {
								"all_of": [
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "eddieworks:sewing_crank" },
									{ "test": "is_mark_variant", "value": 0 }
								]
							},
							"event": "sewing:place_crank"
						},
						"use_item": true,
						"play_sounds": "armor.equip_netherite",
						"interact_text": "sewing_machine.place_crank"
					},
					{
						"on_interact": {
							"filters": {
								"all_of": [
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "eddieworks:sewing_needle" },
									{ "test": "is_mark_variant", "value": 0 }
								]
							},
							"event": "sewing:place_needle"
						},
						"use_item": true,
						"play_sounds": "armor.equip_netherite",
						"interact_text": "sewing_machine.place_needle"
					},
					{
						"on_interact": {
							"filters": {
								"all_of": [
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "eddieworks:sewing_crank" },
									{ "test": "is_mark_variant", "value": 2 }
								]
							},
							"event": "sewing:place_filled"
						},
						"use_item": true,
						"play_sounds": "armor.equip_netherite",
						"interact_text": "sewing_machine.place_crank"
					},
					{
						"on_interact": {
							"filters": {
								"all_of": [
									{ "test": "has_equipment", "subject": "other", "domain": "hand", "value": "eddieworks:sewing_needle" },
									{ "test": "is_mark_variant", "value": 1 }
								]
							},
							"event": "sewing:place_filled"
						},
						"use_item": true,
						"play_sounds": "armor.equip_netherite",
						"interact_text": "sewing_machine.place_needle"
					}
				]
			},
			"minecraft:damage_sensor": {
				"triggers": [
					{
						"cause": "entity_attack",
						"on_damage": { "filters": { "test": "is_variant", "value": 0 }, "event": "sewing:destroy_1" },
						"on_damage_sound_event": "hit",
						"deals_damage": false
					},
					{
						"cause": "entity_attack",
						"on_damage": { "filters": { "test": "is_variant", "value": 1 }, "event": "sewing:destroy_2" },
						"on_damage_sound_event": "hit",
						"deals_damage": false
					},
					{
						"cause": "entity_attack",
						"on_damage": { "filters": { "test": "is_variant", "value": 2 }, "event": "sewing:destroy_3" },
						"on_damage_sound_event": "hit",
						"deals_damage": false
					},
					{
						"cause": "entity_attack",
						"on_damage": { "filters": { "test": "is_variant", "value": 3 }, "event": "sewing:remove_machine" },
						"on_damage_sound_event": "break",
						"deals_damage": false
					},
					{
						"cause": "entity_attack",
						"on_damage": { "filters": { "test": "is_variant", "value": 4 }, "event": "sewing:remove_in_creative" },
						"on_damage_sound_event": "break",
						"deals_damage": false
					},
					{ "cause": "all", "deals_damage": false }
				]
			}
		},
		"events": {
			"minecraft:entity_spawned": {
				"sequence": [
					{
						"filters": { "test": "has_equipment", "subject": "other", "value": "eddieworks:sewing_machine_filled" },
						"add": { "component_groups": [ "creative" ] }
					}
				]
			},
			"sewing:place_crank":  { "add": { "component_groups": [ "has_crank" ] } },
			"sewing:place_needle": { "add": { "component_groups": [ "has_needle" ] } },
			"sewing:place_filled": { "add": { "component_groups": [ "has_crank_and_needle" ] } },
			
			"sewing:intact": 	{
				"add": 		{ "component_groups": [ "intact" ] },
				"remove": 	{ "component_groups": [ "destroy_timer" ] }
			},
			"sewing:destroy_1": { "add": { "component_groups": [ "destroy_timer", "destroy_stage_1" ] } },
			"sewing:destroy_2": { "add": { "component_groups": [ "destroy_timer", "destroy_stage_2" ] } },
			"sewing:destroy_3": { "add": { "component_groups": [ "destroy_timer", "destroy_stage_3" ] } },

			"sewing:remove_machine": {
				"remove": { "component_groups": [ "destroy_timer" ] },
				"add": { "component_groups": [ "remove_machine" ] }
			},
			"sewing:remove_in_creative": { "add": { "component_groups": [ "remove_in_creative" ] } }
		}
	}
}