{
	"format_version": "1.20.30",
	"minecraft:block": {
		"description": {
			"identifier": "farmersdelight:rice_plant",
			"is_experimental": true,
			"states": {
				"farmersdelight:age": [
					0,
					1,
					2,
					3,
					4,
					5,
					6,
					7
				]
			}
		},
		"components": {
			"minecraft:geometry": "geometry.x_tall",
			"minecraft:map_color": "#00ff00",
			"minecraft:material_instances": {
				"*": {
					"render_method": "alpha_test",
					"ambient_occlusion": true,
					"face_dimming": false,
					"texture": "rice_stage0"
				}
			},
			"minecraft:flammable": {
				"flame_odds": 0,
				"burn_odds": 0
			},
			"minecraft:loot": "loot_tables/rice_not_ready.json",
			"minecraft:destructible_by_mining": {
				"seconds_to_destroy": 0
			},
			"minecraft:destructible_by_explosion": {
				"explosion_resistance": 10
			},
			"minecraft:collision_box": false,
			"minecraft:selection_box": {
				"origin": [
					-8,
					0,
					-8
				],
				"size": [
					16,
					2,
					16
				]
			},
			"minecraft:random_ticking": {
				"on_tick": {
					"event": "grow"
				}
			},
			"minecraft:on_interact": {
				"event": "grow_bonemeal",
				"condition": "query.get_equipped_item_name=='bone_meal'",
				"target": "self"
			},
			"minecraft:on_placed": {
				"event": "message",
				"target": "other"
			},
			"minecraft:light_dampening": 0,
			"minecraft:placement_filter": {
				"conditions": [
					{
						"block_filter": [
							"farmersdelight:delight_farmland",
							"minecraft:farmland",
							"farmersdelight:rich_soil_farmland"
						],
						"allowed_faces": [
							"up"
						]
					}
				]
			}
		},
		"permutations": [
			{
				"condition": "query.block_state('farmersdelight:age')==1",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage1"
						}
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							3,
							16
						]
					}
				}
			},
			{
				"condition": "query.block_state('farmersdelight:age')==2",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage2"
						}
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							8,
							16
						]
					}
				}
			},
			{
				"condition": "query.block_state('farmersdelight:age')==3",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage3"
						}
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							12,
							16
						]
					}
				}
			},
			{
				"condition": "query.block_state('farmersdelight:age')==4",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage4"
						}
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					}
				}
			},
			{
				"condition": "query.block_state('farmersdelight:age')==5",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage5"
						}
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					}
				}
			},
			{
				"condition": "query.block_state('farmersdelight:age')==6",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage6"
						}
					},
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					}
				}
			},
			{
				"condition": "query.block_state('farmersdelight:age')==7",
				"components": {
					"minecraft:material_instances": {
						"*": {
							"render_method": "alpha_test",
							"ambient_occlusion": true,
							"face_dimming": false,
							"texture": "rice_stage7"
						}
					},
					"minecraft:loot": "loot_tables/rice_ready.json",
					"minecraft:selection_box": {
						"origin": [
							-8,
							0,
							-8
						],
						"size": [
							16,
							16,
							16
						]
					}
				}
			}
		],
		"events": {
			"grow": {
				"randomize": [
					{
						"weight": 0.2,
						"sequence": [
							{
								"condition": "query.block_neighbor_has_any_tag(0,-1,0,'delight_farmland')",
								"set_block_state": {
									"farmersdelight:age": "(query.block_state('farmersdelight:age')<7) ? query.block_state('farmersdelight:age') + 1 : 7"
								}
							},
							{
								"condition": "query.block_neighbor_has_any_tag(0,-1,0,'rich_soil_farmland')&&query.block_state('farmersdelight:age')<7",
								"set_block_state": {
									"farmersdelight:age": "math.min(query.block_state('farmersdelight:age') + math.die_roll_integer(1, 1, 3), 7)"
								},
								"run_command": {
									"command": [
										"particle minecraft:crop_growth_emitter ~~~"
									],
									"target": "self"
								}
							}
						]
					},
					{
						"weight": 0.8
					}
				]
			},
			"grow_bonemeal": {
				"sequence": [
					{
						"set_block_state": {
							"farmersdelight:age": "math.min(query.block_state('farmersdelight:age') + math.die_roll_integer(1, 1, 5), 7)"
						}
					},
					{
						"run_command": {
							"command": [
								"particle minecraft:crop_growth_emitter ~~~"
							]
						},
						"condition": "query.block_state('farmersdelight:age')<7"
					},
					{
						"run_command": {
							"command": [
								"playsound item.bone_meal.use"
							],
							"target": "other"
						},
						"condition": "query.block_state('farmersdelight:age')<7"
					},
					{
						"decrement_stack": {},
						"condition": "query.block_state('farmersdelight:age')<7"
					}
				]
			},
			"message": {
				"sequence": [
					{
						"condition": "!query.block_neighbor_has_any_tag(0,-1,0,'faded_farmland')",
						"run_command": {
							"target": "other",
							"command": [
								"give @s farmersdelight:rice"
							]
						}
					},
					{
						"condition": "!query.block_neighbor_has_any_tag(0,-1,0,'faded_farmland')",
						"run_command": {
							"command": [
								"tellraw @a[r=6] {\"rawtext\":[{\"text\":\"\"},{\"translate\":\"delight.farmland.deny\"}]}"
							]
						}
					},
					{
						"condition": "!query.block_neighbor_has_any_tag(0,-1,0,'faded_farmland')",
						"run_command": {
							"command": [
								"playsound block.false_permissions @a[r=6]"
							]
						},
						"set_block_at_pos": {
							"block_type": "minecraft:air",
							"block_offset": [
								0,
								0,
								0
							]
						}
					}
				]
			}
		}
	}
}