![]() |
VOOZH | about |
This article describes the various components of block behaviour in Java Edition, based on the class BlockBehaviour 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 block states or 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 #convertable_to_mud tag turning into mud is described by the items that corvert them.[1]
BlockBehaviour(...)
These are the block properties saved as attributes of each block instance. Normally these properties are given in the block registry in the Blocks class, or sometimes in a subclass of Block.
The effect of each property depends on its use in other methods.
Properties is a public static class of BlockBehaviour 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 |
| [Boolean] boolean | hasCollision | true |
| SoundType | soundType | SoundType.STONE |
| ToIntFunction<BlockState> | lightEmission | state -> 0 |
| [Float] float | explosionResistance | |
| [Float] float | destroyTime | |
| [Boolean] boolean | requiresCorrectToolForDrops | |
| [Boolean] boolean | isRandomlyTicking | |
| [Float] float | friction | 0.6f |
| [Float] float | speedFactor | 1.0f |
| [Float] 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()) |
| [Boolean] boolean | canOcclude | true |
| [Boolean] boolean | isAir | |
| [Boolean] boolean | ignitedByLava | |
| [Boolean] boolean | liquid | |
| [Boolean] boolean | forceSolidOff | |
| [Boolean] boolean | forceSolidOn | |
| PushReaction | pushReaction | PushReaction.NORMAL |
| [Boolean] boolean | spawnTerrainParticles | true |
| NoteBlockInstrument | instrument | NoteBlockInstrument.HARP |
| [Boolean] 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 |
| [Boolean] boolean | dynamicShape | |
| FeatureFlagSet | requiredFeatures | FeatureFlags.VANILLA_SET |
| @Nullable OffsetFunction | offsetFunction |
There are many methods used to assign properties to a certain block; most commonly, the Blocks class is used to add properties to blocks at the time of their registration.
ofLegacyCopy(...)
Copies some properties from one block to another.
The final properties of the new block are, in order of priority:
Used in the registration of 105 blocks and in the method registerLegacyStair(...) (used in the registration of 47 stairs) in Blocks, and in ofFullCopy(...).
ofFullCopy(...)
Like the ofLegacyCopy(...) but in addition to the properties copied by ofLegacyCopy(...) it also copies:
Used in the registration of 84 blocks and in the method registerStair(...) (used in the registration of 4 cut copper stairs) in Blocks.
mapColor(...)
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 glazed terracotta, concrete, and concrete powder) and in the method registerStainedGlass(...) (unsed in all 16 stained glass) in Blocks.
mapColor(...)
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 leavesProperties(...) (used in 9 leaves), in the method shulkerBoxProperties(...) (used in all 17 shulker boxs), in the method pistonProperties() (used in piston and sticky piston) and, in the method candleProperties(...) (used in all 17 candles) in Blocks.
mapColor(...)
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 (wheat crop, barrier and light), in the method registerBed(...) (unsed in all 16 beds), in the method logProperties(...) (unsed in 21 blocks, but 11 of they have the same color for all states) and, in the method netherStemProperties(...) (unsed in 4 blocks, but they all have the same color for all states) in Blocks.
noCollision()
Set the hasCollision and canOcclude block properties to false.
Used in the registration of 241 blocks and in the method buttonProperties() (used in the registration of 14 buttons) in Blocks.
Hardcoded item properties (Java Edition) — Similar article for items