Interface BlockPlaceContext
public interface BlockPlaceContext
Where and how a player is placing a block, handed to
BlockBehaviour.placementState(BlockPlaceContext).
The server makes it; the default methods work out what most blocks need from the rest.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanAttachTo(BlockFace side) Returnstruewhen the block on that side can hold the placed block: it is loaded, and neither air nor a fluid.Returns the face of the neighbouring block the player clicked.floatcursorY()Returns the height of the click on the clicked face, from0to1.default BlockFaceReturns the horizontal direction the player looks towards.default booleanReturnstruewhen the block replaces a water source, and should be waterlogged.default BlockFaceReturns the direction the player looks towards, vertical ones included.placer()Returns the location and orientation of the player.pos()Returns the position the block is placed at.Returns the state next to the placed block, ornullif it is not loaded.replaced()Returns the state about to be replaced, ornullif it is not loaded.booleansneaking()Returnstruewhen the player sneaks while placing the block: a chest then stays alone, unless it is placed against the side of another chest, which it joins.default booleanReturnstruewhen the block should go in the upper half, for slabs and stairs.world()Returns read access to the surrounding blocks.
-
Method Details
-
pos
BlockPosition pos()Returns the position the block is placed at.- Returns:
- the position the block is placed at
- Since:
- 0.1.0
-
clickedFace
BlockFace clickedFace()Returns the face of the neighbouring block the player clicked.- Returns:
- the face of the neighbouring block the player clicked
- Since:
- 0.1.0
-
placer
Location placer()Returns the location and orientation of the player.- Returns:
- the location and orientation of the player
- Since:
- 0.1.0
-
world
BlockGetter world()Returns read access to the surrounding blocks.- Returns:
- read access to the surrounding blocks
- Since:
- 0.1.0
-
cursorY
float cursorY()Returns the height of the click on the clicked face, from0to1.- Returns:
- the height of the click on the clicked face, from
0to1 - Since:
- 0.1.0
-
sneaking
boolean sneaking()Returnstruewhen the player sneaks while placing the block: a chest then stays alone, unless it is placed against the side of another chest, which it joins.- Returns:
truewhen the player sneaks while placing the block: a chest then stays alone, unless it is placed against the side of another chest, which it joins- Since:
- 0.1.0
-
horizontalFacing
Returns the horizontal direction the player looks towards.- Returns:
- the horizontal direction the player looks towards
- Since:
- 0.1.0
-
lookingDirection
Returns the direction the player looks towards, vertical ones included.- Returns:
- the direction the player looks towards, vertical ones included
- Since:
- 0.1.0
-
upperHalf
default boolean upperHalf()Returnstruewhen the block should go in the upper half, for slabs and stairs.- Returns:
truewhen the block should go in the upper half, for slabs and stairs- Since:
- 0.1.0
-
replaced
-
relative
-
canAttachTo
Returnstruewhen the block on that side can hold the placed block: it is loaded, and neither air nor a fluid.- Parameters:
side- the side the placed block would be attached to- Returns:
truewhen the block on that side can hold the placed block: it is loaded, and neither air nor a fluid- Since:
- 0.1.0
-
intoWater
default boolean intoWater()Returnstruewhen the block replaces a water source, and should be waterlogged.- Returns:
truewhen the block replaces a water source, and should be waterlogged- Since:
- 0.1.0
-