Minecraft:Block behaviour (Java Edition)
More actions
This article describes the various components of block behaviour Template:In, based on the class Template:Jbcp in the code.
This article aims to document the technical details of each block's behavior, citing the code responsible for each behavior and specifying details such as which tags are used, how the Minecraft:block states or Minecraft:block entity is affected, which advancement triggers are activated, etc. These details are usually hidden in the usage section of a specific block's wiki page.
This file may become very large and need to be split, however, the basic property information should be present here, pointing to main articles when necessary.
Note that not all block behaviors will be described here, as some behaviors of certain blocks are described in item classes, entities, etc. For example, the behavior of blocks in the Template:Tag link tag turning into mud is described by the items that corvert them.Template:Refhip
Properties
BlockBehaviour(Template:Tooltip)
These are the block properties saved as attributes of each block instance. Normally these properties are given in the block registry in the Template:Jbcp class, or sometimes in a subclass of Template:Jbcp.
- hasCollision
- drops
- descriptionId
- explosionResistance
- isRandomlyTicking
- soundType
- friction
- speedFactor
- jumpFactor
- dynamicShape
- requiredFeatures
- properties
The effect of each property depends on its use in other methods.
Properties class
Properties is a public static class of Template:Jbcp which defines the properties for each block. These properties serve to describe general block behaviors that do not need to be specified by a specific method.
For example, blocks with the hasCollision property, a priori, have a collision shape equal to their shape, and blocks without this property have an empty collision box. However, there are some exceptions, namely the blocks that have implementations of the method that defines their collision box, defining it more specifically.
Block properties can be of various types, such as boolean, float, etc., unlike block tags which in practice function as a boolean property.
| Type | Properties | Default |
|---|---|---|
| Function<BlockState, MapColor> | mapColor | state -> MapColor.NONE |
| Template:Nbt boolean | hasCollision | true |
| SoundType | soundType | SoundType.STONE |
| ToIntFunction<BlockState> | lightEmission | state -> 0 |
| Template:Nbt float | explosionResistance | |
| Template:Nbt float | destroyTime | |
| Template:Nbt boolean | requiresCorrectToolForDrops | |
| Template:Nbt boolean | isRandomlyTicking | |
| Template:Nbt float | friction | 0.6f |
| Template:Nbt float | speedFactor | 1.0f |
| Template:Nbt float | jumpFactor | 1.0f |
| @Nullable ResourceKey<Block> | id | |
| DependantName<Block, Optional<ResourceKey<LootTable>>> | drops | id -> Optional.of(ResourceKey.create(Registries.LOOT_TABLE, id.identifier().withPrefix("blocks/"))) |
| DependantName<Block, String> | descriptionId | id -> Util.makeDescriptionId("block", id.identifier()) |
| Template:Nbt boolean | canOcclude | true |
| Template:Nbt boolean | isAir | |
| Template:Nbt boolean | ignitedByLava | |
| Template:Nbt boolean | liquid | |
| Template:Nbt boolean | forceSolidOff | |
| Template:Nbt boolean | forceSolidOn | |
| PushReaction | pushReaction | PushReaction.NORMAL |
| Template:Nbt boolean | spawnTerrainParticles | true |
| NoteBlockInstrument | instrument | NoteBlockInstrument.HARP |
| Template:Nbt boolean | replaceable | |
| StateArgumentPredicate<EntityType<?>> | isValidSpawn | (state, level, pos, entityType) -> state.isFaceSturdy(level, pos, Direction.UP) && state.getLightEmission() < 14 |
| StatePredicate | isRedstoneConductor | BlockStateBase::isCollisionShapeFullBlock |
| StatePredicate | isSuffocating | (state, level, pos) -> state.blocksMotion() && state.isCollisionShapeFullBlock(level, pos) |
| StatePredicate | isViewBlocking | this.isSuffocating |
| PostProcess | postProcess | (state, level, pos) -> null |
| StatePredicate | emissiveRendering | (state, level, pos) -> false |
| Template:Nbt boolean | dynamicShape | |
| FeatureFlagSet | requiredFeatures | FeatureFlags.VANILLA_SET |
| @Nullable OffsetFunction | offsetFunction |
Properties class methods
There are many methods used to assign properties to a certain block; most commonly, the Template:Jbcp class is used to add properties to blocks at the time of their registration.
ofLegacyCopy(Template:Tooltip)
Copies some properties from one block to another.
The final properties of the new block are, in order of priority:
- Properties defined after copying
- Properties copied from the other block, which are:
- destroyTime
- explosionResistance
- hasCollision
- isRandomlyTicking
- lightEmission
- mapColor
- soundType
- friction
- speedFactor
- dynamicShape
- canOcclude
- isAir
- ignitedByLava
- liquid
- forceSolidOff
- forceSolidOn
- pushReaction
- requiresCorrectToolForDrops
- offsetFunction
- spawnTerrainParticles
- requiredFeatures
- emissiveRendering
- instrument
- replaceable
- Default properties, for the other properties
Used in the registration of 105 blocks and in the method Template:Cd (used in the registration of 47 Minecraft:stairs) in Template:Jbcp, and in Template:Cd.
ofFullCopy(Template:Tooltip)
Like the Template:Cd but in addition to the properties copied by Template:Cd it also copies:
- jumpFactor
- isRedstoneConductor
- isValidSpawn
- postProcess
- isSuffocating
- isViewBlocking
- drops
- descriptionId
Used in the registration of 84 blocks and in the method Template:Cd (used in the registration of 4 Minecraft:cut copper stairs) in Template:Jbcp.
mapColor(Template:Tooltip)
For all states of the block, define the color map as the color associated with the given dye color.
Used in the registration of 48 blocks (all 16 Minecraft:glazed terracotta, Minecraft:concrete, and Minecraft:concrete powder) and in the method Template:Cd (unsed in all 16 Minecraft:stained glass) in Template:Jbcp.
mapColor(Template:Tooltip)
For all states of the block, define the color map with the given map color
Used in the registration of 662 blocks, in the method Template:Cd (used in 9 Minecraft:leaves), in the method Template:Cd (used in all 17 Minecraft:shulker boxs), in the method Template:Cd (used in Minecraft:piston and Minecraft:sticky piston) and, in the method Template:Cd (used in all 17 Minecraft:candles) in Template:Jbcp.
mapColor(Template:Tooltip)
For a block, it defines a map between its states and a map color, so that the same block can have different colors in different states.
Used in the registration of 3 blocks (Minecraft:wheat crop, Minecraft:barrier and light), in the method Template:Cd (unsed in all 16 Minecraft:beds), in the method Template:Cd (unsed in 21 blocks, but 11 of they have the same color for all states) and, in the method Template:Cd (unsed in 4 blocks, but they all have the same color for all states) in Template:Jbcp.
noCollision()
Set the hasCollision and canOcclude block properties to false.
Used in the registration of 241 blocks and in the method Template:Cd (used in the registration of 14 Minecraft:buttons) in Template:Jbcp.
Notes
See also
Minecraft:Hardcoded item properties (Java Edition) — Similar article for items