Interface BlockBehaviour
public interface BlockBehaviour
The server-side logic of a block type: how it is placed, used and removed, and how it interacts
with light.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionkey()Returns the key of the block type this behaviour drives.default intlightEmission(BlockData data) Returns the light level the state emits, from0to15.default intlightOpacity(BlockData data) Returns how much light the state absorbs, from0(transparent) to15(opaque).Returns the color terrain maps draw the state with.default voidonRemove(World world, BlockPosition position, BlockData data) Called when the block is about to be replaced by another block type: broken, blown up, or overwritten by a plugin.placementState(BlockPlaceContext context) Chooses the state a player places, for instance facing the player.type()Returns the block type this behaviour drives.default booleanuse(Player player, BlockPosition position, BlockData data) Called when a player uses the block, a right click, unless they sneak with an item in hand.
-
Method Details
-
type
BlockType type()Returns the block type this behaviour drives.- Returns:
- the block type this behaviour drives
- Since:
- 0.1.0
-
key
-
placementState
Chooses the state a player places, for instance facing the player.- Parameters:
context- where and how the block is being placed- Returns:
- the state to place, or
nullto refuse the placement - Since:
- 0.1.0
-
use
Called when a player uses the block, a right click, unless they sneak with an item in hand. Opening a crafting table or an ender chest happens here.Runs on the thread of the region owning the block.
- Parameters:
player- the player using the blockposition- where the block is, in the player's worlddata- the state of the block- Returns:
truewhen the use is handled: the held item is then neither used nor placed- Since:
- 0.1.0
-
onRemove
Called when the block is about to be replaced by another block type: broken, blown up, or overwritten by a plugin. The block and its block entity are still in place, so that what it holds can be read.Runs on the thread of the region owning the block.
- Parameters:
world- the world of the blockposition- where the block isdata- the state being removed- Since:
- 0.1.0
-
lightEmission
Returns the light level the state emits, from0to15.- Parameters:
data- the state- Returns:
- the light level the state emits, from
0to15 - Since:
- 0.1.0
-
lightOpacity
Returns how much light the state absorbs, from0(transparent) to15(opaque).- Parameters:
data- the state- Returns:
- how much light the state absorbs, from
0(transparent) to15(opaque) - Since:
- 0.1.0
-
mapColor
Returns the color terrain maps draw the state with.- Parameters:
data- the state- Returns:
- the color,
MapColor.NONEfor a block maps look through, ornull(the default) to keep the vanilla color of the block - Since:
- 0.1.0
- See Also:
-