Bedrock Wiki
  • Discord
  • Contribute
  • bedrock.dev
  • MS Learn
Beginner's Guide
  • Guide
    • 1. Introduction
      guide
    • 2. Add-Ons Explained
    • 3. Software & Preparation
    • 4. Project Setup
    • 5. Create a Custom Item
    • 6. Create a Custom Entity
    • 7. Blockbench: Modeling, Texturing & Animating
    • 8. Adding Loot Tables, Spawn Rules & Crafting Recipes
  • Extra
    • a. Understanding JSON
    • b. Download Example Packs
    • c. Troubleshooting
      help
    • d. Advanced Manifest
    • e. Format Versions
    • f. Project Setup Android
Animation Controllers
  • Intro to Animation Controllers
    guide
  • Entity Commands
  • AFK Detector
  • Death Commands
  • Molang into Scoreboard
  • Respawn Commands
Blocks
  • General
    • Intro to Blocks
      guide
    • Block Components
    • Block Tags
    • Block States
    • Block Traits
    • Block Permutations
    • Block Events
      Scripts
    • Block Event Migration
      help
    • Blocks as Items
    • Multi-Blocks
    • Troubleshooting Blocks
      help
  • Sound & Visuals
    • Intro to Block Visuals
      guide
    • Block Culling
    • Block Models
      guide
    • Block Sounds
    • Block Texture Animation
    • Block Texture Variation
    • Block Tinting
    • N-Way Rotation
      guide
  • Tutorials
    • Applying Effects
      Scripts
    • Avoiding State Limit
    • Block Orientation
    • Fake Blocks
      Scripts
    • Ore Loot Tables
      Scripts
    • Tool-Based Destruction
  • Vanilla Re-Creations
    • Custom Crops
      Scripts
    • Custom Fences
    • Custom Glass
    • Custom Glazed Terracotta
    • Custom Heads
    • Custom Trapdoors
      Scripts
  • Documentation
    • Block Co-Location
    • Block Format History
    • Block Shapes
    • Redstone Components
    • Vanilla Block Models
    • Vanilla Block Sounds
    • Vanilla Block Tags
    • Vanilla Voxel Shapes
Commands
  • General
    • Intro to Command Blocks
    • Understanding Selectors
    • Functions
      guide
    • Block States
    • Coordinate System
    • Giving NBT Items
    • Scoreboard Operations
  • Commands
    • Damage
    • Execute
    • Playanimation
    • Playsound
  • On Event Systems
    • On First World Load
      function
    • On Player First Join
    • On Player Join
    • On Player Leave
    • On Player Death
    • On Player Respawn
  • Scoreboard Systems
    • Entity Counter
    • Scoreboard Timers
    • Comparing And Retrieving Scores
  • Detection Systems
    • Look Detection
    • Item Drop Detection
    • Movement Detections
    • Rain Detection
  • Techniques
    • Execute Logic Gates
      concept
    • Execute at Block Variant
    • Execution Forking
      concept
    • Binary in Commands
      concept
    • MBE - Max's Block Entity
    • FMBE - A New Way to Create Display Entities
    • Dynamic Displays
    • Orbital Camera
  • Useful Creations
    • Sphere Command
    • Compass Display
    • Custom Crafting
    • Multiplayer Position Rearrangement
      function
Concepts
  • contents.json
  • Molang
  • Namespaces
  • Overwriting Assets
  • Shaders
  • Sounds
  • Subpacks
  • Texture Atlases
  • textures_list.json
Documentation
  • Advanced Molang
  • File Types
  • Fog IDs
  • Material Configuration Description
  • Molang Queries
  • Pack Folder Structure
  • Shared Constructs
  • Sound Definitions
  • Vanilla Materials
Entities
  • General
    • Intro to Entities BP
      guide
    • Intro to Entities RP
      guide
    • Troubleshooting Entities
      help
    • Entity Events
    • Entity Properties
    • NPC Dialogue
    • Render Controllers
    • Spawn Rules
  • Tutorials
    • Area Effect Clouds
    • Coordinate Space Conversion
    • Creating Boats
    • Detecting Other Entities
    • Disabling Team Damage
    • Dummy Entities
    • Entity Attacks
    • Entity Movement
    • Entity Timers
    • Holding Items
    • Invulnerable Entities
    • Look at Entity
    • Riding Flying Entities
    • Sleeping Entities
    • Solid Entities
    • Spawning Tamed Entities
      Scripts
    • Village Mechanic
  • Documentation
    • Dummy Components
    • Non-Mob Runtime Identifiers
    • Projectiles
    • Runtime Identifiers
    • Vanilla Usage Components
    • Vanilla Usage Spawn Rules
Items
  • General
    • Intro to Items
      guide
    • Item Components
    • Item Tags
    • Item Events
      Scripts
    • Item Event Migration
      help
    • Item Catalog
    • Troubleshooting Items
      help
  • Tutorials
    • Equipment-Based Commands
    • Spawning Items
    • Throwable Items
  • Vanilla Re-Creations
    • Custom Armor
    • Custom Food
      Scripts
    • Custom Pottery Sherds
    • Custom Weapons
  • Documentation
    • Enchantments
    • Attachables
    • Item Format History
    • Numerical Item IDs
    • Vanilla Item Groups
    • Vanilla Item Tags
    • Vanilla Usage Components
JSON UI
  • General
    • Intro to JSON UI
      guide
    • Best Practices
      guide
  • Tutorials
    • Adding HUD Elements
    • Aseprite Animations
    • Buttons and Toggles
    • Dynamic Content Generation
    • Modifying Server Forms
    • Preserve Title Texts
    • Type Conversion
  • Documentation
    • JSON UI Documentation
Loot, Recipes & Trading
  • General
    • Trading Behavior
  • Documentation
    • Loot Tables
    • Trade Tables
    • Recipes
    • Item Functions
  • Tutorials
    • Randomized Structure Loot
Meta
  • Add-On Performance
  • Style Guide
  • Useful Links
  • Using Schemas
  • Version Control
  • Q&A
    • Blocks and Items Q&A 2024/08/30
    • Deferred Technical Preview Q&A 2024/02/23
    • GameTest Q&A 2021/08/06
    • Scripting and Editor Q&A 2023/09/22
    • World Generation Q&A 2024/11/15
NBT
  • General
    • .mcstructure
  • Tutorials
    • Enabling Experiments by Editing NBT
    • Extending Structure Limits
  • NBT in Depth
    • About NBT (Named Binary Tag)
    • NBT Libraries
    • Reading NBT Example
Particles
  • General
    • Intro to Particles
      guide
  • Tutorials
    • Disabling Particles
  • Documentation
    • Vanilla Particles
Scripting
  • General
    • Intro to Scripting
    • What is Script API?
    • API Modules
  • Tutorials
    • Script Core Features
    • Block Placement Prevention
    • Custom Commands
    • GameTests
    • Script Privileges
    • Script Requests API
    • Server Forms
  • Documentation
    • Engine Environment
    • Script Resources
    • Script Watchdog
    • Troubleshooting JavaScript
    • TypeScript
Servers
  • Software
    • Bedrock Server Software
  • Protocols
    • Bedrock Protocol
    • NetherNet Protocol
    • RakNet Protocol
Text & Localization
  • General
    • Intro to Text & Localization
    • Raw Text
    • Splashes
  • Emojis & Symbols
    • Fonts
    • Intro to Emojis
    • Custom Emojis
    • Input Keys
Visuals
  • General
    • Introduction to Entity Visuals
      guide
    • Bedrock Modeling
    • Custom Death Animations
    • Effects in Animations
    • Material Creations
    • Materials
    • Math-Based Animations
    • Skin Packs
  • Tutorials
    • Entity Texture Animation
    • Glowing Entity Texture
    • Hurt Animations
    • Leash Position
    • Player Geometry
    • Remove Entity Shadows
    • Retexturing Spawn Eggs
  • Ideas
    • Structure Presentation
World Generation
  • General
    • Intro to World Generation
      guide
    • Biomes
      guide
    • Feature Types
    • Jigsaw Structures
  • Tutorials
    • Block Conditions for Features
    • Generating Custom Ores
    • Generating Custom Structures
    • Generating Patches
    • Heightmap Noise
  • Documentation
    • Biome Tags

Custom Fences

intermediate
Custom Fences
  • Initial Block JSON
  • Fence Model
    • Block Model
    • Item Model
  • Applying Geometry & Textures
    • Item Visual
  • Collision & Selection Boxes
  • Final Block JSON
  • Item JSON
Download Example
Download as ZIP Download as MCADDON

FORMAT VERSION 1.26.40

This tutorial assumes a good understanding of block visuals and block permutations. Check out the block visuals guide before starting.

In this tutorial, you'll learn how to create your own fence blocks with connection and multi-box collisions.

Features:

  • Connects with adjacent blocks in each cardinal direction.
  • Multi-box collisions that are 1.5 blocks tall, preventing most entities from jumping over the fence.
  • Able to be used as fuel in a furnace.

Initial Block JSON ​

There are quite a few components listed here. Here's what is important for fences specifically:

  • The minecraft:connection trait enables the minecraft:connection_north, minecraft:connection_south, minecraft:connection_west and minecraft:connection_east states which indicate in which directions the fence should form a connection.
  • The minecraft:has_fence_connections tag tells vanilla wooden fences that they can connect to the block.
  • The minecraft:connection_rule component is used to prevent bars, glass panes and walls from connecting to the block.

Note that the block description does not have the menu_category parameter as that will be defined in the item JSON instead in a later step.

📝 BP/blocks/custom_fence.json
json
{
    "format_version": "1.26.40",
    "minecraft:block": {
        "description": {
            "identifier": "wiki:custom_fence",
            "traits": {
                "minecraft:connection": {
                    "enabled_states": ["minecraft:cardinal_connections"]
                }
            }
        },
        "components": {
            "minecraft:tags": [
                "minecraft:has_fence_connections",
                "minecraft:is_axe_item_destructible"
            ],
            "minecraft:destructible_by_explosion": {
                "explosion_resistance": 15
            },
            "minecraft:destructible_by_mining": {
                "seconds_to_destroy": 2
            },
            "minecraft:destruction_particles": {
                "particle_count": 48
            },
            "minecraft:flammable": {
                "catch_chance_modifier": 5,
                "destroy_chance_modifier": 20,
                "lava_flammable": "always"
            },
            "minecraft:connection_rule": {
                "accepts_connections_from": "only_fences"
            },
            "minecraft:support": {
                "shape": "fence"
            },
            // Prevents snow from accumulating above the fence
            "minecraft:precipitation_interactions": {
                "precipitation_behavior": "obstruct_rain"
            },
            // Allows the fence to be waterlogged
            "minecraft:liquid_detection": {
                "detection_rules": [
                    {
                        "liquid_type": "water",
                        "can_contain_liquid": true
                    }
                ]
            },
            // Allows leads to be attached to the fence
            "minecraft:leashable": {
                "offset": [0, 12, 0]
            },
            "minecraft:selection_box": {
                "origin": [-2, 0, -2],
                "size": [4, 16, 4]
            },
            "minecraft:collision_box": {
                "origin": [-2, 0, -2],
                "size": [4, 24, 4]
            }
        }
    }
}
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

Fence Model ​

You might have noticed that fences use two distinct models: one when carried in the inventory depicting two posts and a different model when placed which only has one post.

This means that we'll have to create two models for our custom fence, where one is applied to the block and the other is applied to the block item.

Block Model ​

In this example, our block model will contain all of the fence rails (the horizontal parts of the fence). Each pair of rails in each direction is contained within a separate bone. This will allow us to conditionally show/hide the rails based on the block's permutation using bone_visibility.

Block Geometry JSON
📝 RP/models/blocks/custom_fence.geo.json
json
{
    "format_version": "1.26.40",
    "minecraft:geometry": [
        {
            "description": {
                "identifier": "geometry.custom_fence",
                "texture_width": 16,
                "texture_height": 16
            },
            "bones": [
                {
                    "name": "post",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [-2, 0, -2],
                            "size": [4, 16, 4],
                            "uv": {
                                "north": { "uv": [6, 0], "uv_size": [4, 16] },
                                "east": { "uv": [6, 0], "uv_size": [4, 16] },
                                "south": { "uv": [6, 0], "uv_size": [4, 16] },
                                "west": { "uv": [6, 0], "uv_size": [4, 16] },
                                "up": { "uv": [10, 10], "uv_size": [-4, -4] },
                                "down": { "uv": [10, 10], "uv_size": [-4, -4] }
                            }
                        }
                    ]
                },
                {
                    "name": "north_rails",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [-1, 12, -8],
                            "size": [2, 3, 6],
                            "uv": {
                                "north": { "uv": [7, 1], "uv_size": [2, 3] },
                                "east": { "uv": [10, 1], "uv_size": [6, 3] },
                                "west": { "uv": [0, 1], "uv_size": [6, 3] },
                                "up": { "uv": [9, 6], "uv_size": [-2, -6] },
                                "down": { "uv": [9, 16], "uv_size": [-2, -6] }
                            }
                        },
                        {
                            "origin": [-1, 6, -8],
                            "size": [2, 3, 6],
                            "uv": {
                                "north": { "uv": [7, 7], "uv_size": [2, 3] },
                                "east": { "uv": [10, 7], "uv_size": [6, 3] },
                                "west": { "uv": [0, 7], "uv_size": [6, 3] },
                                "up": { "uv": [9, 6], "uv_size": [-2, -6] },
                                "down": { "uv": [9, 16], "uv_size": [-2, -6] }
                            }
                        }
                    ]
                },
                {
                    "name": "south_rails",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [-1, 12, 2],
                            "size": [2, 3, 6],
                            "uv": {
                                "east": { "uv": [0, 1], "uv_size": [6, 3] },
                                "south": { "uv": [7, 1], "uv_size": [2, 3] },
                                "west": { "uv": [10, 1], "uv_size": [6, 3] },
                                "up": { "uv": [9, 16], "uv_size": [-2, -6] },
                                "down": { "uv": [9, 6], "uv_size": [-2, -6] }
                            }
                        },
                        {
                            "origin": [-1, 6, 2],
                            "size": [2, 3, 6],
                            "uv": {
                                "east": { "uv": [0, 7], "uv_size": [6, 3] },
                                "south": { "uv": [7, 7], "uv_size": [2, 3] },
                                "west": { "uv": [10, 7], "uv_size": [6, 3] },
                                "up": { "uv": [9, 16], "uv_size": [-2, -6] },
                                "down": { "uv": [9, 6], "uv_size": [-2, -6] }
                            }
                        }
                    ]
                },
                {
                    "name": "west_rails",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [2, 12, -1],
                            "size": [6, 3, 2],
                            "uv": {
                                "north": { "uv": [10, 1], "uv_size": [6, 3] },
                                "south": { "uv": [0, 1], "uv_size": [6, 3] },
                                "west": { "uv": [7, 1], "uv_size": [2, 3] },
                                "up": { "uv": [6, 9], "uv_size": [-6, -2] },
                                "down": { "uv": [6, 9], "uv_size": [-6, -2] }
                            }
                        },
                        {
                            "origin": [2, 6, -1],
                            "size": [6, 3, 2],
                            "uv": {
                                "north": { "uv": [10, 7], "uv_size": [6, 3] },
                                "south": { "uv": [0, 7], "uv_size": [6, 3] },
                                "west": { "uv": [7, 7], "uv_size": [2, 3] },
                                "up": { "uv": [6, 9], "uv_size": [-6, -2] },
                                "down": { "uv": [6, 9], "uv_size": [-6, -2] }
                            }
                        }
                    ]
                },
                {
                    "name": "east_rails",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [-8, 12, -1],
                            "size": [6, 3, 2],
                            "uv": {
                                "north": { "uv": [0, 1], "uv_size": [6, 3] },
                                "east": { "uv": [7, 1], "uv_size": [2, 3] },
                                "south": { "uv": [10, 1], "uv_size": [6, 3] },
                                "up": { "uv": [16, 9], "uv_size": [-6, -2] },
                                "down": { "uv": [16, 9], "uv_size": [-6, -2] }
                            }
                        },
                        {
                            "origin": [-8, 6, -1],
                            "size": [6, 3, 2],
                            "uv": {
                                "north": { "uv": [0, 7], "uv_size": [6, 3] },
                                "east": { "uv": [7, 7], "uv_size": [2, 3] },
                                "south": { "uv": [10, 7], "uv_size": [6, 3] },
                                "up": { "uv": [16, 9], "uv_size": [-6, -2] },
                                "down": { "uv": [16, 9], "uv_size": [-6, -2] }
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
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
Block Culling Rules JSON
📝 RP/block_culling/custom_fence.json
json
{
    "format_version": "1.21.80",
    "minecraft:block_culling_rules": {
        "description": {
            "identifier": "wiki:culling.custom_fence"
        },
        "rules": [
            // Post
            {
                "direction": "down",
                "geometry_part": {
                    "bone": "post",
                    "cube": 0,
                    "face": "down"
                }
            },
            {
                "direction": "up",
                "geometry_part": {
                    "bone": "post",
                    "cube": 0,
                    "face": "up"
                }
            },
            // North rails
            {
                "direction": "north",
                "geometry_part": {
                    "bone": "north_rails",
                    "cube": 0,
                    "face": "north"
                }
            },
            {
                "direction": "north",
                "geometry_part": {
                    "bone": "north_rails",
                    "cube": 1,
                    "face": "north"
                }
            },
            // South rails
            {
                "direction": "south",
                "geometry_part": {
                    "bone": "south_rails",
                    "cube": 0,
                    "face": "south"
                }
            },
            {
                "direction": "south",
                "geometry_part": {
                    "bone": "south_rails",
                    "cube": 1,
                    "face": "south"
                }
            },
            // West rails
            {
                "direction": "west",
                "geometry_part": {
                    "bone": "west_rails",
                    "cube": 0,
                    "face": "west"
                }
            },
            {
                "direction": "west",
                "geometry_part": {
                    "bone": "west_rails",
                    "cube": 1,
                    "face": "west"
                }
            },
            // East rails
            {
                "direction": "east",
                "geometry_part": {
                    "bone": "east_rails",
                    "cube": 0,
                    "face": "east"
                }
            },
            {
                "direction": "east",
                "geometry_part": {
                    "bone": "east_rails",
                    "cube": 1,
                    "face": "east"
                }
            }
        ]
    }
}
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

Item Model ​

In contrast, the bones in the item model are not necessary and have just been used to organize the cubes.

Item Geometry JSON
📝 RP/models/blocks/custom_fence_carried.geo.json
json
{
    "format_version": "1.26.40",
    "minecraft:geometry": [
        {
            "description": {
                "identifier": "geometry.custom_fence_carried",
                "texture_width": 16,
                "texture_height": 16
            },
            "item_display_transforms": {
                "gui": {
                    "fit_to_frame": false
                },
                "fixed": {
                    "rotation": [0, -90, 0]
                },
                "shelf": {
                    "rotation": [0, -90, 0]
                }
            },
            "bones": [
                {
                    "name": "posts",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [-2, 0, 4],
                            "size": [4, 16, 4],
                            "uv": {
                                "north": { "uv": [6, 0], "uv_size": [4, 16] },
                                "east": { "uv": [0, 0], "uv_size": [4, 16] },
                                "south": { "uv": [6, 0], "uv_size": [4, 16] },
                                "west": { "uv": [12, 0], "uv_size": [4, 16] },
                                "up": { "uv": [10, 16], "uv_size": [-4, -4] },
                                "down": { "uv": [10, 4], "uv_size": [-4, -4] }
                            }
                        },
                        {
                            "origin": [-2, 0, -8],
                            "size": [4, 16, 4],
                            "uv": {
                                "north": { "uv": [6, 0], "uv_size": [4, 16] },
                                "east": { "uv": [12, 0], "uv_size": [4, 16] },
                                "south": { "uv": [6, 0], "uv_size": [4, 16] },
                                "west": { "uv": [0, 0], "uv_size": [4, 16] },
                                "up": { "uv": [10, 4], "uv_size": [-4, -4] },
                                "down": { "uv": [10, 16], "uv_size": [-4, -4] }
                            }
                        }
                    ]
                },
                {
                    "name": "rails",
                    "pivot": [0, 0, 0],
                    "cubes": [
                        {
                            "origin": [-1, 12, -10],
                            "size": [2, 3, 2],
                            "uv": {
                                "north": { "uv": [0, 1], "uv_size": [2, 3] },
                                "east": { "uv": [0, 1], "uv_size": [2, 3] },
                                "west": { "uv": [0, 1], "uv_size": [2, 3] },
                                "up": { "uv": [9, 16], "uv_size": [-2, -2] },
                                "down": { "uv": [9, 16], "uv_size": [-2, -2] }
                            }
                        },
                        {
                            "origin": [-1, 12, -4],
                            "size": [2, 3, 8],
                            "uv": {
                                "east": { "uv": [4, 1], "uv_size": [8, 3] },
                                "west": { "uv": [4, 1], "uv_size": [8, 3] },
                                "up": { "uv": [9, 12], "uv_size": [-2, -8] },
                                "down": { "uv": [9, 12], "uv_size": [-2, -8] }
                            }
                        },
                        {
                            "origin": [-1, 12, 8],
                            "size": [2, 3, 2],
                            "uv": {
                                "east": { "uv": [14, 1], "uv_size": [2, 3] },
                                "south": { "uv": [14, 1], "uv_size": [2, 3] },
                                "west": { "uv": [14, 1], "uv_size": [2, 3] },
                                "up": { "uv": [9, 2], "uv_size": [-2, -2] },
                                "down": { "uv": [9, 2], "uv_size": [-2, -2] }
                            }
                        },
                        {
                            "origin": [-1, 6, -10],
                            "size": [2, 3, 2],
                            "uv": {
                                "north": { "uv": [0, 7], "uv_size": [2, 3] },
                                "east": { "uv": [0, 7], "uv_size": [2, 3] },
                                "west": { "uv": [0, 7], "uv_size": [2, 3] },
                                "up": { "uv": [9, 16], "uv_size": [-2, -2] },
                                "down": { "uv": [9, 16], "uv_size": [-2, -2] }
                            }
                        },
                        {
                            "origin": [-1, 6, -4],
                            "size": [2, 3, 8],
                            "uv": {
                                "east": { "uv": [4, 7], "uv_size": [8, 3] },
                                "west": { "uv": [4, 7], "uv_size": [8, 3] },
                                "up": { "uv": [9, 12], "uv_size": [-2, -8] },
                                "down": { "uv": [9, 12], "uv_size": [-2, -8] }
                            }
                        },
                        {
                            "origin": [-1, 6, 8],
                            "size": [2, 3, 2],
                            "uv": {
                                "east": { "uv": [14, 7], "uv_size": [2, 3] },
                                "south": { "uv": [14, 7], "uv_size": [2, 3] },
                                "west": { "uv": [14, 7], "uv_size": [2, 3] },
                                "up": { "uv": [9, 2], "uv_size": [-2, -2] },
                                "down": { "uv": [9, 2], "uv_size": [-2, -2] }
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
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

Applying Geometry & Textures ​

📝 BP/blocks/custom_fence.json
minecraft:blockcomponents
json
"minecraft:geometry": {
    "identifier": "geometry.custom_fence",
    "culling": "wiki:culling.custom_fence",
    "bone_visibility": {
        "north_rails": "q.block_state('minecraft:connection_north')",
        "south_rails": "q.block_state('minecraft:connection_south')",
        "west_rails": "q.block_state('minecraft:connection_west')",
        "east_rails": "q.block_state('minecraft:connection_east')"
    }
}
1
2
3
4
5
6
7
8
9
10

In this example, we will simply be applying a custom wooden planks texture to our fence, although you might instead like to create a special model and texture for your fence like bamboo fences have in vanilla.

📝 BP/blocks/custom_fence.json
minecraft:blockcomponents
json
"minecraft:material_instances": {
    "*": {
        "texture": "wiki:custom_planks"
    }
}
1
2
3
4
5

Item Visual ​

Next, we can use the minecraft:item_visual component to apply the item model to the block item:

📝 BP/blocks/custom_fence.json
minecraft:blockcomponents
json
"minecraft:item_visual": {
    "geometry": "geometry.custom_fence_carried",
    "material_instances": {
        "*": {
            "texture": "wiki:custom_planks"
        }
    }
}
1
2
3
4
5
6
7
8

Collision & Selection Boxes ​

Unlike geometry bones, collision and selection boxes cannot be individually enabled/disabled based on block states. This means we'll have to manually list the components for each block permutation making use of the permutations array.

📝 BP/blocks/custom_fence.json
minecraft:block
json
"permutations": [
    // Single connection
    {
        "condition": "q.block_state('minecraft:connection_north')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -8],
                "size": [4, 16, 10]
            },
            "minecraft:collision_box": {
                "origin": [-2, 0, -8],
                "size": [4, 24, 10]
            }
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_south')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -2],
                "size": [4, 16, 10]
            },
            "minecraft:collision_box": {
                "origin": [-2, 0, -2],
                "size": [4, 24, 10]
            }
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_west')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -2],
                "size": [10, 16, 4]
            },
            "minecraft:collision_box": {
                "origin": [-2, 0, -2],
                "size": [10, 24, 4]
            }
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -2],
                "size": [10, 16, 4]
            },
            "minecraft:collision_box": {
                "origin": [-8, 0, -2],
                "size": [10, 24, 4]
            }
        }
    },
    // Two connections (axis-aligned)
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -8],
                "size": [4, 16, 16]
            },
            "minecraft:collision_box": {
                "origin": [-2, 0, -8],
                "size": [4, 24, 16]
            }
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -2],
                "size": [16, 16, 4]
            },
            "minecraft:collision_box": {
                "origin": [-8, 0, -2],
                "size": [16, 24, 4]
            }
        }
    },
    // Two connections (corner)
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_west')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -8],
                "size": [10, 16, 10]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -8], "size": [4, 24, 10] },
                { "origin": [2, 0, -2], "size": [6, 24, 4] }
            ]
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -8],
                "size": [10, 16, 10]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -8], "size": [4, 24, 10] },
                { "origin": [-8, 0, -2], "size": [6, 24, 4] }
            ]
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -2],
                "size": [10, 16, 10]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -2], "size": [4, 24, 10] },
                { "origin": [2, 0, -2], "size": [6, 24, 4] }
            ]
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -2],
                "size": [10, 16, 10]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -2], "size": [4, 24, 10] },
                { "origin": [-8, 0, -2], "size": [6, 24, 4] }
            ]
        }
    },
    // Three connections
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-2, 0, -8],
                "size": [10, 16, 16]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -8], "size": [4, 24, 16] },
                { "origin": [2, 0, -2], "size": [6, 24, 4] }
            ]
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -8],
                "size": [10, 16, 16]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -8], "size": [4, 24, 16] },
                { "origin": [-8, 0, -2], "size": [6, 24, 4] }
            ]
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -8],
                "size": [16, 16, 10]
            },
            "minecraft:collision_box": [
                { "origin": [-8, 0, -2], "size": [16, 24, 4] },
                { "origin": [-2, 0, -8], "size": [4, 24, 6] }
            ]
        }
    },
    {
        "condition": "q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -2],
                "size": [16, 16, 10]
            },
            "minecraft:collision_box": [
                { "origin": [-8, 0, -2], "size": [16, 24, 4] },
                { "origin": [-2, 0, 2], "size": [4, 24, 6] }
            ]
        }
    },
    // Four connections
    {
        "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
        "components": {
            "minecraft:selection_box": {
                "origin": [-8, 0, -8],
                "size": [16, 16, 16]
            },
            "minecraft:collision_box": [
                { "origin": [-2, 0, -8], "size": [4, 24, 16] },
                { "origin": [-8, 0, -2], "size": [16, 24, 4] }
            ]
        }
    }
]
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

Final Block JSON ​

Example Custom Fence Block JSON
📝 BP/blocks/custom_fence.json
json
{
    "format_version": "1.26.40",
    "minecraft:block": {
        "description": {
            "identifier": "wiki:custom_fence",
            "traits": {
                "minecraft:connection": {
                    "enabled_states": ["minecraft:cardinal_connections"]
                }
            }
        },
        "components": {
            "minecraft:tags": [
                "minecraft:has_fence_connections",
                "minecraft:is_axe_item_destructible"
            ],
            "minecraft:destructible_by_explosion": {
                "explosion_resistance": 15
            },
            "minecraft:destructible_by_mining": {
                "seconds_to_destroy": 2
            },
            "minecraft:destruction_particles": {
                "particle_count": 48
            },
            "minecraft:flammable": {
                "catch_chance_modifier": 5,
                "destroy_chance_modifier": 20,
                "lava_flammable": "always"
            },
            "minecraft:connection_rule": {
                "accepts_connections_from": "only_fences"
            },
            "minecraft:support": {
                "shape": "fence"
            },
            "minecraft:geometry": {
                "identifier": "geometry.custom_fence",
                "culling": "wiki:culling.custom_fence",
                "bone_visibility": {
                    "north_rails": "q.block_state('minecraft:connection_north')",
                    "south_rails": "q.block_state('minecraft:connection_south')",
                    "west_rails": "q.block_state('minecraft:connection_west')",
                    "east_rails": "q.block_state('minecraft:connection_east')"
                }
            },
            "minecraft:material_instances": {
                "*": {
                    "texture": "wiki:custom_planks"
                }
            },
            // Item icon
            "minecraft:item_visual": {
                "geometry": "geometry.custom_fence_carried",
                "material_instances": {
                    "*": {
                        "texture": "wiki:custom_planks"
                    }
                }
            },
            // Prevents snow from accumulating above the fence
            "minecraft:precipitation_interactions": {
                "precipitation_behavior": "obstruct_rain"
            },
            // Allows the fence to be waterlogged
            "minecraft:liquid_detection": {
                "detection_rules": [
                    {
                        "liquid_type": "water",
                        "can_contain_liquid": true
                    }
                ]
            },
            // Allows leads to be attached to the fence
            "minecraft:leashable": {
                "offset": [0, 12, 0]
            },
            "minecraft:instrument_sound": {
                "up": "note.bassattack"
            },
            "minecraft:selection_box": {
                "origin": [-2, 0, -2],
                "size": [4, 16, 4]
            },
            "minecraft:collision_box": {
                "origin": [-2, 0, -2],
                "size": [4, 24, 4]
            }
        },
        "permutations": [
            // Single connection
            {
                "condition": "q.block_state('minecraft:connection_north')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -8],
                        "size": [4, 16, 10]
                    },
                    "minecraft:collision_box": {
                        "origin": [-2, 0, -8],
                        "size": [4, 24, 10]
                    }
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_south')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -2],
                        "size": [4, 16, 10]
                    },
                    "minecraft:collision_box": {
                        "origin": [-2, 0, -2],
                        "size": [4, 24, 10]
                    }
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_west')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -2],
                        "size": [10, 16, 4]
                    },
                    "minecraft:collision_box": {
                        "origin": [-2, 0, -2],
                        "size": [10, 24, 4]
                    }
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -2],
                        "size": [10, 16, 4]
                    },
                    "minecraft:collision_box": {
                        "origin": [-8, 0, -2],
                        "size": [10, 24, 4]
                    }
                }
            },
            // Two connections (axis-aligned)
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -8],
                        "size": [4, 16, 16]
                    },
                    "minecraft:collision_box": {
                        "origin": [-2, 0, -8],
                        "size": [4, 24, 16]
                    }
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -2],
                        "size": [16, 16, 4]
                    },
                    "minecraft:collision_box": {
                        "origin": [-8, 0, -2],
                        "size": [16, 24, 4]
                    }
                }
            },
            // Two connections (corner)
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_west')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -8],
                        "size": [10, 16, 10]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -8], "size": [4, 24, 10] },
                        { "origin": [2, 0, -2], "size": [6, 24, 4] }
                    ]
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -8],
                        "size": [10, 16, 10]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -8], "size": [4, 24, 10] },
                        { "origin": [-8, 0, -2], "size": [6, 24, 4] }
                    ]
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -2],
                        "size": [10, 16, 10]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -2], "size": [4, 24, 10] },
                        { "origin": [2, 0, -2], "size": [6, 24, 4] }
                    ]
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -2],
                        "size": [10, 16, 10]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -2], "size": [4, 24, 10] },
                        { "origin": [-8, 0, -2], "size": [6, 24, 4] }
                    ]
                }
            },
            // Three connections
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-2, 0, -8],
                        "size": [10, 16, 16]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -8], "size": [4, 24, 16] },
                        { "origin": [2, 0, -2], "size": [6, 24, 4] }
                    ]
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -8],
                        "size": [10, 16, 16]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -8], "size": [4, 24, 16] },
                        { "origin": [-8, 0, -2], "size": [6, 24, 4] }
                    ]
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -8],
                        "size": [16, 16, 10]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-8, 0, -2], "size": [16, 24, 4] },
                        { "origin": [-2, 0, -8], "size": [4, 24, 6] }
                    ]
                }
            },
            {
                "condition": "q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -2],
                        "size": [16, 16, 10]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-8, 0, -2], "size": [16, 24, 4] },
                        { "origin": [-2, 0, 2], "size": [4, 24, 6] }
                    ]
                }
            },
            // Four connections
            {
                "condition": "q.block_state('minecraft:connection_north') && q.block_state('minecraft:connection_south') && q.block_state('minecraft:connection_west') && q.block_state('minecraft:connection_east')",
                "components": {
                    "minecraft:selection_box": {
                        "origin": [-8, 0, -8],
                        "size": [16, 16, 16]
                    },
                    "minecraft:collision_box": [
                        { "origin": [-2, 0, -8], "size": [4, 24, 16] },
                        { "origin": [-8, 0, -2], "size": [16, 24, 4] }
                    ]
                }
            }
        ]
    }
}
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293

Item JSON ​

Since our fence is made of wood, it should be able to be used as fuel in furnaces. Therefore, we need to add the minecraft:fuel component to the fence by replacing its block item as shown below:

📝 BP/items/custom_fence.json
json
{
    "format_version": "1.26.40",
    "minecraft:item": {
        "description": {
            "identifier": "wiki:custom_fence",
            "menu_category": {
                "category": "construction",
                "group": "minecraft:itemGroup.name.fence"
            }
        },
        "components": {
            "minecraft:block_placer": {
                "block": "wiki:custom_fence",
                "aligned_placement": true,
                "replace_block_item": true
            },
            "minecraft:fuel": {
                "duration": 3
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

Contributors

Edit Custom Fences on GitHub

Text and image content on this page is licensed under the Creative Commons Attribution 4.0 International License

Code samples on this page are licensed under the MIT License

Bedrock Wiki by Bedrock OSS

"Minecraft" is a trademark of Mojang AB.

Bedrock OSS, Bedrock Wiki and bedrock.dev are not affiliated in any way with Microsoft or Mojang AB.

  • Privacy Policy
  • Join our Discord
  • Learn how to Contribute
  • Visit our Repository