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

Script error: No such module "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:

  1. REDIRECT Template:Code

Template:Redr for 26.0. Preview versions should use the version that it is a preview for (Example: Preview 26.0.27 would be

  1. REDIRECT Template:Code

Template:Redr).

  1. REDIRECT Template:Code

Template:Redr. If omitted or

  1. REDIRECT Template:Code

Template:Redr, the block will not appear in the creative inventory or recipe book.

  1. REDIRECT Template:Code
Template:Redr
  1. REDIRECT Template:Code

Template:Redr is true.


States

The Template:Nbt/sprite states object is used to define custom 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/sprite traits 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

  1. REDIRECT Template:Code

Template:Redr, 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:Message boxTemplate:Article other

Allows a block to be made up of multiple block parts like a Minecraft:door. This adds the

  1. REDIRECT Template:Code

Template:Redr state, which is an integer representing which part this block is in the multi block.

  1. REDIRECT Template:Code

Template:Redr.

    • Template:Nbt/sprite parts: The number of parts that this multi block should have. The value must be between 2 and 4, inclusive.
    • Template:Nbt/sprite direction: The direction to place the parts of the multi block in. Can be either
  1. REDIRECT Template:Code

Template:Redr.

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
  1. REDIRECT Template:Code

Template:Redr.

  • minecraft:block_face: The block face that the player placed the block on, allowing for log and pillar functionality. Possible values are
  1. REDIRECT Template:Code

Template:Redr.

  1. REDIRECT Template:Code

Template:Redr.

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
  1. REDIRECT Template:Code

Template:Redr.

  • minecraft:facing_direction: Same as minecraft:cardinal_direction, but allows up and down as well. Possible values are
  1. REDIRECT Template:Code

Template:Redr.

  • minecraft:corner: Allows the block to form corners with other blocks like stairs. Possible values are
  1. REDIRECT Template:Code

Template:Redr.

  1. REDIRECT Template:Code

Template:Redr. minecraft:corner_and_cardinal_direction enables both the minecraft:cardinal_direction and minecraft:corner states.

    • Template:Nbt/sprite y_rotation_offset: The offset to apply to the y rotation of the block. Can be
  1. REDIRECT Template:Code

Template:Redr.

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

Editions
Merged
Ports to consoles
Discontinued
Development
Version history
Technical
Creator
Add-ons
Multiplayer
Exclusive features
Blocks
Mobs
Effects
Unused
Removed

pt:Definição de bloco