Package net.minestom.server.event.player
Class PlayerBlockPlaceEvent
java.lang.Object
net.minestom.server.event.player.PlayerBlockPlaceEvent
- All Implemented Interfaces:
Event
,BlockEvent
,CancellableEvent
,EntityEvent
,EntityInstanceEvent
,InstanceEvent
,PlayerEvent
,PlayerInstanceEvent
public class PlayerBlockPlaceEvent
extends Object
implements PlayerInstanceEvent, BlockEvent, CancellableEvent
Called when a player tries placing a block.
-
Constructor Summary
ConstructorDescriptionPlayerBlockPlaceEvent
(@NotNull Player player, @NotNull Block block, @NotNull BlockFace blockFace, @NotNull BlockVec blockPosition, @NotNull Point cursorPosition, @NotNull PlayerHand hand) -
Method Summary
Modifier and TypeMethodDescriptionvoid
consumeBlock
(boolean consumeBlock) Should the block be consumed if not cancelled.boolean
Should the block be consumed if not cancelled.@NotNull Block
getBlock()
Gets the block which will be placed.@NotNull BlockFace
@NotNull BlockVec
Gets the block position.@NotNull Point
@NotNull PlayerHand
getHand()
Gets the hand with which the player is trying to place.@NotNull Player
Gets the player.boolean
Gets if theEvent
should be cancelled or not.void
Changes the block to be placed.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
setDoBlockUpdates
(boolean doBlockUpdates) Should the place trigger updates (on self and neighbors)boolean
Should the place trigger updates (on self and neighbors)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstance
Methods inherited from interface net.minestom.server.event.trait.PlayerEvent
getEntity
-
Constructor Details
-
PlayerBlockPlaceEvent
-
-
Method Details
-
getBlock
Gets the block which will be placed.- Specified by:
getBlock
in interfaceBlockEvent
- Returns:
- the block to place
-
setBlock
Changes the block to be placed.- Parameters:
block
- the new block
-
getBlockFace
-
getBlockPosition
Gets the block position.- Specified by:
getBlockPosition
in interfaceBlockEvent
- Returns:
- the block position
-
getCursorPosition
-
getHand
Gets the hand with which the player is trying to place.- Returns:
- the hand used
-
consumeBlock
public void consumeBlock(boolean consumeBlock) Should the block be consumed if not cancelled.- Parameters:
consumeBlock
- true if the block should be consumer (-1 amount), false otherwise
-
doesConsumeBlock
public boolean doesConsumeBlock()Should the block be consumed if not cancelled.- Returns:
- true if the block will be consumed, false otherwise
-
setDoBlockUpdates
public void setDoBlockUpdates(boolean doBlockUpdates) Should the place trigger updates (on self and neighbors)- Parameters:
doBlockUpdates
- true if this placement should do block updates
-
shouldDoBlockUpdates
public boolean shouldDoBlockUpdates()Should the place trigger updates (on self and neighbors)- Returns:
- true if this placement should do block updates
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEvent
Gets if theEvent
should be cancelled or not.- Specified by:
isCancelled
in interfaceCancellableEvent
- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEvent
Marks theEvent
as cancelled or not.- Specified by:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancel
- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEvent
Gets the player.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player
-