Record Class BlockPlaceContext
java.lang.Object
java.lang.Record
fr.fidorial.world.block.BlockPlaceContext
- Record Components:
pos- the position the block is placed atclickedFace- the face of the neighbouring block the player clickedplacer- the location and orientation of the playerworld- read access to the surrounding blockscursorY- the height of the click on the clicked face, from0to1
public record BlockPlaceContext(BlockPos pos, BlockFace clickedFace, Location placer, BlockGetter world, float cursorY)
extends Record
Where and how a player is placing a block, handed to
BlockBehaviour.placementState(BlockPlaceContext).- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionBlockPlaceContext(BlockPos pos, BlockFace clickedFace, Location placer, BlockGetter world, float cursorY) Creates an instance of aBlockPlaceContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theclickedFacerecord component.floatcursorY()Returns the value of thecursorYrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the horizontal direction the player looks towards.booleanReturnstruewhen the block replaces a water source, and should be waterlogged.Returns the direction the player looks towards, vertical ones included.placer()Returns the value of theplacerrecord component.pos()Returns the value of theposrecord component.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.final StringtoString()Returns a string representation of this record class.booleanReturnstruewhen the block should go in the upper half, for slabs and stairs.world()Returns the value of theworldrecord component.
-
Constructor Details
-
BlockPlaceContext
public BlockPlaceContext(BlockPos pos, BlockFace clickedFace, Location placer, BlockGetter world, float cursorY) Creates an instance of aBlockPlaceContextrecord class.- Parameters:
pos- the value for theposrecord componentclickedFace- the value for theclickedFacerecord componentplacer- the value for theplacerrecord componentworld- the value for theworldrecord componentcursorY- the value for thecursorYrecord component
-
-
Method Details
-
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
public 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
-
intoWater
public 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
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
pos
-
clickedFace
Returns the value of theclickedFacerecord component.- Returns:
- the value of the
clickedFacerecord component
-
placer
-
world
-
cursorY
-