Parts of Custom Tree

experimental

expert

Vanilla-like custom trees are possible. Make their parts following this tutorial.

Features

  • Features:

    • Decaying leaves
    • If leaves are broken using shears, they will drop themselves
    • Leaves doesn't decay if placed by a player
    • Logs are strippable and rotatable
    • Stripping logs are compatible with tools from other Add-Ons (if they have the tag:minecraft_is_axe component)
    • Saplings can be bonemealed
  • Issues:

    • If leaves are broken using shears, they can drop normal loot too
    • Due to some Minecraft bugs leaves will decay after reloading chunks

TIP

To make leaves decay, you need to use /fill command that will replace custom_leaves with custom_leaves. It is needed for switching decaying to true because on player placing it sets decaying to false.

WARNING

This method requires PC.

Making Leaves

Code
BP/blocks/custom_leaves.jsonCopy
{
    "format_version":"1.16.100",
    "minecraft:block":{
        "description":{
            "identifier":"wiki:custom_leaves",
            "properties":{
                "wiki:decaying":[
					true,
                    false
                ]
            }
            //Properties will make leaves decay or not
        },
        "permutations":[
            {
                "condition":"query.block_property('wiki:decaying') == true",
                "components":{
                    "minecraft:ticking":{
                        "looping":true,
                        "range":[
                            15.0,
                            20.0
                        ],
                        "on_tick":{
                            "event":"wiki:decay"
                        }
                        //In range of 10-18 seconds leaves will decay if weren't updated
                    }
                }
            },
            {
                "condition":"query.block_property('wiki:decaying') == false",
				"components":{}
				//Empty components
            }
        ],
        "components":{
            "minecraft:destroy_time":0.35,
            "minecraft:breakonpush":true,
            "minecraft:material_instances":{
                "*":{
                    "texture":"custom_leaves",
                    "render_method":"alpha_test"
                    //Use this render method to make leaves half-transparent, like vanilla ones
                }
            },
			"minecraft:flammable": {
				"burn_odds": 50,
				"flame_odds": 50
			},
            "minecraft:unit_cube":{},
            "minecraft:loot":"loot_tables/blocks/custom_leaves_loot.json",
            //Basic loot
            "minecraft:on_player_placing":{
                "event":"wiki:set_property_false"
            },
            //On player placing runs event that sets decaying property to false
            "minecraft:on_player_destroyed":{
                "condition":"query.get_equipped_item_name(0) == 'shears'",
                "event":"wiki:spawn_loot"
                //Spawns loot (leaves block)
            }
        },
        "events":{
            "wiki:set_property_false":{
                "set_block_property":{
                    "wiki:decaying":false
                }
            },
            //Sets decaying to false
            "wiki:set_property_true":{
                "set_block_property":{
                    "wiki:decaying":true
                }
            },
            //Sets decaying to true
            "wiki:spawn_loot":{
                "spawn_loot":{
                    "table":"loot_tables/blocks/custom_leaves_block.json"
                }
            },
            //Spawns leaves block
            "wiki:decay":{
                "run_command":{
                    "command":[
                        "setblock ~~~ air 0 destroy"
                    ]
                }
            }
            //Imitation of decaying
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

Making Log

Code
BP/blocks/custom_log.jsonCopy
{
    "format_version": "1.16.100",
    "minecraft:block": {
        "description": {
            "identifier": "wiki:custom_log",
            "properties": {
                "wiki:facing_direction": [0, 1, 2]
            }
            //Log direction properties
        },
        "permutations": [
            {
                "condition": "query.block_property('wiki:facing_direction') == 0",
                //If query.block_property('wiki:facing_direction') == 0 sets no rotation and on_interact component
                "components": {
                    "minecraft:rotation": [0, 0, 0],
                    "minecraft:on_interact": {
                        "condition": "query.equipped_item_any_tag('slot.weapon.mainhand', 'minecraft:is_axe')",
                        "event": "wiki:become_stripped_0"
                        //Event sets custom stripped log with no rotation
                    }
                }
            },
            {
                "condition": "query.block_property('wiki:facing_direction') == 1",
                //If query.block_property('wiki:facing_direction') == 1 sets rotation and on_interact component
                "components": {
                    "minecraft:rotation": [90, 0, 0],
                    "minecraft:on_interact": {
                        "condition": "query.equipped_item_any_tag('slot.weapon.mainhand', 'minecraft:is_axe')",
                        "event": "wiki:become_stripped1"
                        //Event sets custom stripped log with rotation
                    }
                }
            },
            {
                "condition": "query.block_property('wiki:facing_direction') == 2",
                //If query.block_property('wiki:facing_direction') == 2 sets rotation and on_interact component
                "components": {
                    "minecraft:rotation": [0, 0, 90],
                    "minecraft:on_interact": {
                        "condition": "query.equipped_item_any_tag('slot.weapon.mainhand', 'minecraft:is_axe')",
                        "event": "wiki:become_stripped2"
                        //Event sets custom stripped log with rotation
                    }
                }
            }
        ],
        "components": {
            "minecraft:material_instances": {
                "*": {
                    "texture": "custom_log",
                    "render_method": "opaque"
                },
                "ends": {
                    "texture": "custom_log_top",
                    "render_method": "opaque"
                },
                "up": "ends",
                "down": "ends"
                //Sets different textures for sides and top/bottom of log
            },
            "minecraft:loot": "loot_tables/blocks/custom_log_block.json",
            //Due to some bugs you need to add this component and loot table
            "minecraft:destroy_time": 1.0,
            "minecraft:unit_cube": {},
            "minecraft:ticking": {
                "looping": true,
                "range": [6.0, 8.0],
                "on_tick": {
                    "event": "wiki:update_leaves"
                }
            },
            //Updates blocks every 4-6 seconds so they don't decay. Use range to prevent huge lags every N-seconds
            "minecraft:on_player_placing": {
                "event": "wiki:set_facing_direction"
            }
            //Sets log rotation on player placing
        },
        "events": {
            "wiki:update_leaves": {
                "run_command": {
                    "command": ["fill ~3 ~3 ~3 ~-3 ~-3 ~-3 wiki:fake_leaves 0 replace wiki:custom_leaves", "fill ~3 ~3 ~3 ~-3 ~-3 ~-3 wiki:custom_leaves 0 replace wiki:fake_leaves"]
                }
            },
            //Updates leaves
            "wiki:set_facing_direction": {
                "set_block_property": {
                    "wiki:facing_direction": "math.floor( query.block_face / 2.0 )"
                }
            },
            //Sets block rotation
            "wiki:become_stripped_0": {
                "sequence": [
                    {
                        "run_command": {
                            "command": ["setblock ~~~ wiki:custom_stripped_log"]
                        }
                    },
                    //Damages axe of player who stripped the log
                    {
                        "damage": {
                            "type": "durability",
                            "amount": 1,
                            "target": "item"
                        }
                    }
                ]
            },
            //Sets custom stripped log with special rotation
            "wiki:become_stripped1": {
                "sequence": [
                    {
                        "run_command": {
                            "command": ["structure load custom_stripped_log1 ~~~"]
                        }
                    },
                    //Damages axe of player who stripped the log
                    {
                        "damage": {
                            "type": "durability",
                            "amount": 1,
                            "target": "item"
                        }
                    }
                ]
            },
            //Loads structure (custom stripped log with special rotation)
            "wiki:become_stripped2": {
                "sequence": [
                    {
                        "run_command": {
                            "command": ["structure load custom_stripped_log2 ~~~"]
                        }
                    },
                    //Damages axe of player who stripped the log
                    {
                        "damage": {
                            "type": "durability",
                            "amount": 1,
                            "target": "item"
                        }
                    }
                ]
            }
            //Loads structure (custom stripped log with special rotation)
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

Making Fake Leaves

You can replace block with itself only one time, then it doesn't work. That is why fake leaves are needed. Log commands will update leaves without stopping: fill ~3 ~3 ~3 ~-3 ~-3 ~-3 wiki:fake_leaves 0 replace wiki:custom_leavesfill ~3 ~3 ~3 ~-3 ~-3 ~-3 wiki:custom_leaves 0 replace wiki:fake_leaves

Code
BP/blocks/fake_leaves.jsonCopy
{
    "format_version": "1.16.100",
    "minecraft:block": {
        "description": {
            "identifier": "wiki:fake_leaves"
        },
        "components": {
            "minecraft:destroy_time": 2,
            "minecraft:breakonpush": true,
            "minecraft:material_instances": {
                "*": {
                    "texture": "custom_leaves",
                    "render_method": "alpha_test"
                    //Use this render method to make leaves half-transparent, like vanilla ones
                }
            },
            "minecraft:flammable": {
                "burn_odds": 50,
                "flame_odds": 50
            },
            "minecraft:ticking": {
                "range": [0.1, 0.1],
                "on_tick": {
                    "event": "wiki:update_leaves"
                }
            },
            //If something went wrong and fake leaves weren't replaces with custom leaves
            "minecraft:unit_cube": {},
            "minecraft:loot": "loot_tables/blocks/custom_leaves_loot.json"
            //Basic loot
        },
        "events": {
            "wiki:update_leaves": {
                "run_command": {
                    "command": ["setblock ~~~ wiki:custom_leaves"]
                }
            }
            //Turning Back into custom leaves (if log was broken)
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

Making Stripped Log

Here all components are the same

Code
BP/blocks/custom_stripped_log.jsonCopy
{
    "format_version": "1.16.100",
    "minecraft:block": {
        "description": {
            "identifier": "wiki:custom_stripped_log",
            "properties": {
                "wiki:facing_direction": [0, 1, 2]
            }
        },
        "permutations": [
            {
                "condition": "query.block_property('wiki:facing_direction') == 0",
                "components": {
                    "minecraft:rotation": [0, 0, 0]
                }
            },
            {
                "condition": "query.block_property('wiki:facing_direction') == 1",
                "components": {
                    "minecraft:rotation": [90, 0, 0]
                }
            },
            {
                "condition": "query.block_property('wiki:facing_direction') == 2",
                "components": {
                    "minecraft:rotation": [0, 0, 90]
                }
            }
        ],
        "components": {
            "minecraft:material_instances": {
                "*": {
                    "texture": "custom_stripped_log",
                    "render_method": "opaque"
                },
                "ends": {
                    "texture": "custom_stripped_log_top",
                    "render_method": "opaque"
                },
                "up": "ends",
                "down": "ends"
            },
            "minecraft:flammable": {
                "burn_odds": 50,
                "flame_odds": 25
            },
            "minecraft:loot": "loot_tables/blocks/custom_stripped_log_block.json",
            "minecraft:destroy_time": 1.0,
            "minecraft:unit_cube": {},
            "minecraft:on_player_placing": {
                "event": "wiki:set_facing_direction"
            }
        },
        "events": {
            "wiki:set_facing_direction": {
                "set_block_property": {
                    "wiki:facing_direction": "math.floor( query.block_face / 2.0 )"
                }
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

Making Sapling

Code
BP/blocks/custom_sapling.jsonCopy
{
    "format_version": "1.16.100",
    "minecraft:block": {
        "description": {
            "identifier": "wiki:custom_sapling",
            "properties": {
                "wiki:growing": [0, 1, 2]
            }
            //Properties of sapling growing
        },
        "permutations": [
            {
                "condition": "query.block_property('wiki:growing') == 0",
                "components": {
                    "minecraft:on_interact": {
                        "condition": "query.get_equipped_item_name('main_hand') == 'bone_meal'",
                        "event": "bone_meal_1"
                    },
                    "minecraft:ticking": {
                        "range": [120, 180],
                        "on_tick": {
                            "event": "grow_1"
                        }
                    }
                }
            },
            {
                "condition": "query.block_property('wiki:growing') == 1",
                "components": {
                    "minecraft:on_interact": {
                        "condition": "query.get_equipped_item_name('main_hand') == 'bone_meal'",
                        "event": "bone_meal_2"
                    },
                    "minecraft:ticking": {
                        "range": [120, 180],
                        "on_tick": {
                            "event": "grow_2"
                        }
                    }
                }
            },
            {
                "condition": "query.block_property('wiki:growing') == 2",
                "components": {
                    "minecraft:on_interact": {
                        "condition": "query.get_equipped_item_name('main_hand') == 'bone_meal'",
                        "event": "bone_meal_3"
                    },
                    "minecraft:ticking": {
                        "range": [120, 180],
                        "on_tick": {
                            "event": "grow_3"
                        }
                    }
                }
            }
        ],
        "components": {
            "minecraft:material_instances": {
                "*": {
                    "texture": "custom_sapling",
                    "render_method": "alpha_test",
                    //Add this two components to remove shadow from this block:
                    "face_dimming": false,
                    "ambient_occlusion": false
                }
            },
            "minecraft:pick_collision": {
                "origin": [-6, 0, -6],
                "size": [12, 13, 12]
            },
            "minecraft:loot": "loot_tables/blocks/custom_sapling.json",
            //Add loot component so it will drop sapling placer
            "minecraft:geometry": "geometry.custom_sapling",
            "minecraft:destroy_time": 0.01,
            "minecraft:entity_collision": false,
            "minecraft:breakonpush": true,
            "minecraft:breathability": "air",
            "minecraft:block_light_absorption": 0,
            "minecraft:placement_filter": {
                "conditions": [
                    {
                        "block_filter": ["minecraft:dirt", "minecraft:grass", "minecraft:podzol"],
                        "allowed_faces": ["up"]
                    }
                ]
            },
            //Allows to place block only on this blocks
            "minecraft:ticking": {
                "range": [1, 1],
                "on_tick": {
                    "event": "grow_0"
                }
            }
            //Starts to grow
        },
        "events": {
            "grow_0": {
                "set_block_property": {
                    "wiki:growing": 0
                }
                //Sets growing stage to 0
            },
            "grow_1": {
                "sequence": [
                    {
                        "run_command": {
                            "command": ["particle minecraft:crop_growth_emitter ~~~"]
                        }
                        //Adds particles
                    },
                    {
                        "set_block_property": {
                            "wiki:growing": 1
                        }
                        //Sets growing stage to 1
                    }
                ]
            },
            "grow_2": {
                "sequence": [
                    {
                        "run_command": {
                            "command": ["particle minecraft:crop_growth_emitter ~~~"]
                        }
                        //Adds particles
                    },
                    {
                        "set_block_property": {
                            "wiki:growing": 2
                            //Sets growing stage to 2
                        }
                    }
                ]
            },
            "grow_3": {
                "run_command": {
                    "command": ["particle minecraft:crop_growth_emitter ~~~", "structure load custom_tree ~-2 ~ ~-2"]
                }
                //Particles and structure loads. Magic!
            },
            "bone_meal_1": {
                "sequence": [
                    {
                        "decrement_stack": {}
                        //Clears item that were used to interact
                    },
                    {
                        "trigger": {
                            "event": "grow_1"
                        }
                        //Runs grow_1 event
                    }
                ]
            },
            "bone_meal_2": {
                "sequence": [
                    {
                        "decrement_stack": {}
                        //Clears item that were used to interact
                    },
                    {
                        "trigger": {
                            "event": "grow_2"
                        }
                        //Runs grow_2 event
                    }
                ]
            },
            "bone_meal_3": {
                "sequence": [
                    {
                        "decrement_stack": {}
                        //Clears item that were used to interact
                    },
                    {
                        "trigger": {
                            "event": "grow_3"
                        }
                        //Runs grow_3 event
                    }
                ]
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

Making Sapling Placer

Code
BP/items/custom_sapling_placer.jsonCopy
{
    "format_version": "1.16.100",
    "minecraft:item": {
        "description": {
            "identifier": "wiki:custom_sapling_placer",
            "category": "nature"
        },
        "components": {
            "minecraft:creative_category": {
                "parent": "itemGroup.name.sapling"
            },
            "minecraft:max_stack_size": 64,
            "minecraft:block_placer": {
                "block": "wiki:custom_sapling"
            },
            "minecraft:icon": {
                "texture": "custom_sapling_placer"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Making Loot Tables

This loot will spawn leaves block

Code
BP/loot_tables/blocks/custom_leaves_block.jsonCopy
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "wiki:custom_leaves",
                    "weight": 1
                }
            ]
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Leaves default loot

BP/loot_tables/blocks/custom_leaves_loot.jsonCopy
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:apple",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "wiki:custom_sapling",
                    "weight": 5
                },
                {
                    "type": "empty",
                    //Nothing wil drop
                    "weight": 10
                }
            ]
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

This loot will spawn log block

BP/loot_tables/blocks/custom_leaves_block.jsonCopy
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "wiki:custom_log",
                    "weight": 1
                }
            ]
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

This loot will spawn stripped log

BP/loot_tables/blocks/custom_stripped_log_block.jsonCopy
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "wiki:custom_stripped_log",
                    "weight": 1
                }
            ]
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

This will spawn custom_sapling_placer

BP/loot_tables/blocks/custom_sapling_placer.jsonCopy
{
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "wiki:custom_sapling_placer",
                    "weight": 1
                }
            ]
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Exporting Structures

Now you need to get custom_stripped_log1 and custom_stripped_log2 structures. Just export rotated stripped logs.

Build some trees too! (Don't forget to update leaves using /fill command)

Resource Pack

It is time to make a resource pack!

Make translations for blocks:

RP/texts/en_US.langCopy
tile.wiki:custom_log.name=Custom Log
tile.wiki:custom_leaves.name=Custom leaves
tile.wiki:custom_stripped_log.name=Custom Stripped Log
tile.wiki:custom_sapling.name=Custom Sapling
item.wiki:custom_sapling_placer.name=Custom Sapling
tile.wiki:fake_leaves.name=Custom Leaves
1
2
3
4
5
6

Make terrain_texture.json and textures.

RP/textures/terrain_texture.jsonCopy
{
    "num_mip_levels": 4,
    "padding": 8,
    "resource_pack_name": "Parts of Custom Tree",
    "texture_data": {
        "custom_leaves": {
            "textures": "textures/blocks/leaves_oak"
        },
        "custom_log": {
            "textures": "textures/blocks/log_oak"
        },
        "custom_log_top": {
            "textures": "textures/blocks/log_oak_top"
        },
        "custom_stripped_log": {
            "textures": "textures/blocks/stripped_oak_log"
        },
        "custom_stripped_log_top": {
            "textures": "textures/blocks/stripped_oak_log_top"
        },
        "custom_sapling": {
            "textures": "textures/blocks/sapling_oak"
        }
    },
    "texture_name": "atlas.terrain"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

Make geometry for sapling:

RP/models/blocks/custom_sapling.geo.jsonCopy
{
    "format_version": "1.12.0",
    "minecraft:geometry": [
        {
            "description": {
                "identifier": "geometry.custom_sapling",
                "texture_width": 16,
                "texture_height": 16,
                "visible_bounds_width": 2,
                "visible_bounds_height": 2.5,
                "visible_bounds_offset": [0, 0.75, 0]
            },
            "bones": [
                {
                    "name": "bb_main",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        { "origin": [-8, 0, 0], "size": [16, 16, 0], "pivot": [0, 0, 0], "rotation": [0, -45, 0], "uv": [0, 0] },
                        { "origin": [-8, 0, 0], "size": [16, 16, 0], "pivot": [0, 0, 0], "rotation": [0, 45, 0], "uv": [0, 0] }
                    ]
                }
            ]
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Make item_texture file

RP/textures/terrain_texture.jsonCopy
{
    "resource_pack_name": "Parts of Custom Tree",
    "texture_name": "atlas.items",
    "texture_data": {
        "custom_sapling_placer": {
            "textures": "textures/blocks/sapling_oak"
        }
    }
}
1
2
3
4
5
6
7
8
9

Add sounds to blocks

RP/blocks.jsonCopy
{
    "format_version": [1, 1, 0],
    "wiki:custom_leaves": {
        "sound": "grass"
    },
    "wiki:custom_log": {
        "sound": "wood"
    },
    "wiki:custom_stripped_log": {
        "sound": "wood"
    },
    "wiki:custom_sapling": {
        "sound": "grass"
    },
    "wiki:fake_leaves": {
        "sound": "grass"
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Result

What you have now: Custom Leaves, Custom Log, Custom Stripped Log, Custom Sapling, Custom Tree Structure

Contributors

stiranteSmokeyStackMedicalJewel105aexer0e