Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Block definition

From SAS Gaming Wiki

Template:Exclusive

A block definition is a Minecraft:JSON file used to define a custom Minecraft:block and its behavior. Block definition files are located in the Template:File folder of a Minecraft:behavior pack.

Structure

Block definitions are structured as follows:


States

The Template:Nbt object is used to define custom Minecraft:block states. Only custom states are allowed, using a vanilla state or the "minecraft" namespace will cause an error and fail. The object consists of state names as properties, and an array of possible values for each state. Integer states can also be defined as a range using an object. Block state values can be queried in permutations using the Minecraft:molang query "query.block_state('<state_name>')".

Examples:

<syntaxhighlight lang=json copy> "states": {

 "example:string_state": ["a", "b", "c"],
 "example:int_state": [1,2,3],
 "example:bool_state": [true,false],
 "example:int_state_2": {
   "min": 0,
   "max": 10
 }

} </syntaxhighlight>

Traits

The Template:Nbt object is used to add vanilla block traits, which allow for custom blocks to have access to some vanilla block states. This object only gives access to the states, other functionality usually has to be added using permutations. The object consists of traits and their enabled states:

minecraft:connection

Template:Warning

Gives blocks the boolean states Template:Cd, allowing for the block to connect to blocks next to it.

Example:

<syntaxhighlight lang=json copy> "traits": {

 "minecraft:connection": {
   "enabled_states": ["minecraft:cardinal_connections"]
 }

} </syntaxhighlight>

minecraft:multi_block

Template:Experimental

Allows a block to be made up of multiple block parts like a Minecraft:door. This adds the Template:Cd state, which is an integer representing which part this block is in the multi block.

Example:

<syntaxhighlight lang=json copy> "traits": {

 "minecraft:multi_block": {
   "enabled_states": [
     "minecraft:multi_block_part"
   ],
   "parts": 3,
   "direction": "up"
 }

} </syntaxhighlight>

minecraft:placement_position

Gives blocks states related to where the player places the block. Two states are available:

  • minecraft:vertical_half: The half of the block space that the block was placed in, allowing for stair and slab functionality. Possible values are Template:Cd.
  • minecraft:block_face: The block face that the player placed the block on, allowing for log and pillar functionality. Possible values are Template:Cd.

Example:

<syntaxhighlight lang=json copy> "traits": {

 "minecraft:placement_position": {
   "enabled_states": ["minecraft:vertical_half"]
 }

} </syntaxhighlight>

minecraft:placement_direction

Gives blocks states related to the direction in which the player places the block. Three states are available:

  • minecraft:cardinal_direction: The direction the player was facing when the block was placed. Possible values are Template:Cd.
  • minecraft:facing_direction: Same as minecraft:cardinal_direction, but allows up and down as well. Possible values are Template:Cd.
  • minecraft:corner: Allows the block to form corners with other blocks like stairs. Possible values are Template:Cd.

Example:

<syntaxhighlight lang=json copy> "traits": {

 "minecraft:placement_direction": {
   "enabled_states": ["minecraft:corner_and_cardinal_direction"],
   "blocks_to_corner_with": [{"tags": "q.any_tag('minecraft:cornerable_stairs')"}]
 }

} </syntaxhighlight>

History

Template:HistoryTable

Navigation

Template:Navbox Bedrock Edition

Minecraft:pt:Definição de bloco