{
	"format_version": "1.20.30",
	"minecraft:block": {
		"description": {
			"states": {
				"cfm:block_rotation": [
					2,
					3,
					4,
					5
				],
				"cfm:inventory": [
					false,
					true
				],
				"farmersdelight:first_inventory": [
					true,
					false
				]
			},
			"identifier": "farmersdelight:crimson_cabinet",
			"menu_category": {
				"category": "items",
				"group": "itemGroup.name.farmersdelight_cabinet"
			}
		},
		"components": {
			"minecraft:on_player_placing": {
				"event": "cfm:update_rotation"
			},
			"minecraft:material_instances": {
				"*": {
					"render_method": "alpha_test",
					"texture": "fd_crimson_cabinet"
				}
			},
			"minecraft:geometry": "geometry.cabinet_close",
			"minecraft:on_interact": {
				"event": "open"
			},
			"minecraft:loot": "loot_tables/df_crimson_cabinet.json",
			"minecraft:destructible_by_mining": {
				"seconds_to_destroy": 0.5
			}
		},
		"permutations": [
			{
				"condition": "query.block_state('cfm:block_rotation') == 2",
				"components": {
					"minecraft:on_placed": {
						"event": "nothing"
					},
					"minecraft:transformation": {
						"rotation": [
							0,
							180,
							0
						]
					}
				}
			},
			{
				"condition": "query.block_state('cfm:block_rotation') == 3",
				"components": {
					"minecraft:on_placed": {
						"event": "nothing"
					},
					"minecraft:transformation": {
						"rotation": [
							0,
							0,
							0
						]
					}
				}
			},
			{
				"condition": "query.block_state('cfm:block_rotation') == 4",
				"components": {
					"minecraft:on_placed": {
						"event": "nothing"
					},
					"minecraft:transformation": {
						"rotation": [
							0,
							270,
							0
						]
					}
				}
			},
			{
				"condition": "query.block_state('cfm:block_rotation') == 5",
				"components": {
					"minecraft:on_placed": {
						"event": "nothing"
					},
					"minecraft:transformation": {
						"rotation": [
							0,
							90,
							0
						]
					}
				}
			},
			{
				"condition": "query.block_state('cfm:inventory') == true",
				"components": {
					"minecraft:collision_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					},
					"minecraft:selection_box": false,
					"minecraft:queued_ticking": {
						"looping": true,
						"interval_range": [
							100,
							100
						],
						"on_tick": {
							"event": "close"
						}
					},
					"minecraft:on_placed": {
						"event": "nothing"
					},
					"minecraft:on_interact": {
						"event": "nothing"
					},
					"minecraft:geometry": "geometry.cabinet_open"
				}
			},
			{
				"condition": "query.block_state('cfm:inventory') == false",
				"components": {
					"minecraft:collision_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					},
					"minecraft:on_interact": {
						"event": "open",
						"target": "self"
					},
					"minecraft:geometry": "geometry.cabinet_close",
					"minecraft:on_placed": {
						"event": "nothing"
					}
				}
			}
		],
		"events": {
			"cfm:update_rotation": {
				"set_block_state": {
					"cfm:block_rotation": "query.cardinal_facing_2d"
				}
			},
			"open": {
				"sequence": [
					{
						"condition": "query.block_state('farmersdelight:first_inventory')==true",
						"run_command": {
							"command": [
								"summon farmersdelight:inventory"
							]
						}
					},
					{
						"set_block_state": {
							"cfm:inventory": true,
							"farmersdelight:first_inventory": false
						},
						"run_command": {
							"command": [
								"playsound block.barrel.open @a[r=50] ~~~"
							]
						}
					}
				]
			},
			"close": {
				"set_block_state": {
					"cfm:inventory": false
				},
				"run_command": {
					"command": [
						"playsound block.barrel.open @a[r=50] ~~~"
					]
				}
			}
		}
	}
}