Custom Crops
📝 BP/blocks/custom_crop.json
json
{
"format_version": "1.26.40",
"minecraft:block": {
"description": {
"identifier": "wiki:custom_crop",
"states": {
"wiki:growth": {
"values": { "min": 0, "max": 7 }
}
}
},
"components": {
"minecraft:tags": ["minecraft:crop"],
"minecraft:collision_box": false,
// Trigger growth on random ticks and when interacting with Bone Meal
"wiki:crop_growth": {
"growth_state": "wiki:growth",
"max_growth": 7,
// Require a light level of 9 or above in order to grow on random ticks
"min_light_level": 9,
// Match the growth speed of vanilla crops
"farmland_search_range": 1,
"farmland_speed_modifier": 1,
"farmland_moisture_speed_modifier": 2,
"neighboring_farmland_speed_multiplier": 0.25,
"crowding_speed_multiplier": 0.5,
// Add 2-5 growth stages at random when a non-creative mode player uses Bone Meal on the crop
"growth_on_fertilize": [2, 5]
},
// Visuals
"minecraft:destruction_particles": {
"particle_count": 48
},
"minecraft:geometry": "geometry.custom_crop",
"minecraft:material_instances": {
"*": {
"texture": "wiki:custom_crop_0",
"render_method": "alpha_test_single_sided",
"ambient_occlusion": 0,
"face_dimming": false
}
},
// Break the crop if it isn't placed on farmland
"minecraft:placement_filter": {
"conditions": [
{
"allowed_faces": ["up"],
"block_filter": ["minecraft:farmland"]
}
]
},
// Prevent rain from splashing and snow from accumulating on top of the block
"minecraft:precipitation_interactions": {
"precipitation_behavior": "none"
},
// Break the crop when water flows into it
"minecraft:liquid_detection": {
"detection_rules": [
{
"liquid_type": "water",
"on_liquid_touches": "popped"
}
]
},
// Break the crop when it is pushed by a piston
"minecraft:movable": {
"movement_type": "popped"
},
// Prevent blocks such as fences and glass panes from connecting
"minecraft:connection_rule": {
"accepts_connections_from": "none"
}
},
"permutations": [
{
"condition": "q.block_state('wiki:growth') < 7",
"components": {
// Loot table for when the crop is not fully grown; vanilla crops only drop seeds when young
"minecraft:loot": "loot_tables/wiki/blocks/custom_crop_young.json"
}
},
{
"condition": "q.block_state('wiki:growth') == 0",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 1.6, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') == 1",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 3.2, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') >= 2",
"components": {
"minecraft:material_instances": {
"*": {
"texture": "wiki:custom_crop_1",
"render_method": "alpha_test_single_sided",
"ambient_occlusion": 0,
"face_dimming": false
}
}
}
},
{
"condition": "q.block_state('wiki:growth') == 2",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 4.8, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') == 3",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 6.4, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') >= 4",
"components": {
"minecraft:material_instances": {
"*": {
"texture": "wiki:custom_crop_2",
"render_method": "alpha_test_single_sided",
"ambient_occlusion": 0,
"face_dimming": false
}
}
}
},
{
"condition": "q.block_state('wiki:growth') == 4",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 8, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') == 5",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 9.6, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') == 6",
"components": {
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 11.2, 16]
}
}
},
{
"condition": "q.block_state('wiki:growth') == 7",
"components": {
"minecraft:material_instances": {
"*": {
"texture": "wiki:custom_crop_3",
"render_method": "alpha_test_single_sided",
"ambient_occlusion": 0,
"face_dimming": false
}
},
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 12.8, 16]
},
// Drop different loot when fully grown
"minecraft:loot": "loot_tables/wiki/blocks/custom_crop_mature.json"
}
}
]
}
}Code samples on this page are licensed under the MIT License