Class PlayerBlockInteractEvent
java.lang.Object
net.minestom.server.event.player.PlayerBlockInteractEvent
- All Implemented Interfaces:
Event, BlockEvent, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent
public class PlayerBlockInteractEvent
extends Object
implements PlayerInstanceEvent, BlockEvent, CancellableEvent
Called when a player interacts with a block (right-click).
This is also called when a block is placed.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerBlockInteractEvent(Player player, PlayerHand hand, Block block, BlockVec blockPosition, Point cursorPosition, BlockFace blockFace) -
Method Summary
Modifier and TypeMethodDescriptiongetBlock()Gets the block face.Gets the position of the interacted block.Gets the cursor position of the interacted blockgetHand()Gets the hand used for the interaction.Gets the player.booleanGets if the event should block the item use.booleanGets if theEventshould be cancelled or not.voidsetBlockingItemUse(boolean blocks) Sets the blocking item use state of this event Note: If this is true, then noPlayerUseItemOnBlockEventwill be fired.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EntityInstanceEvent
getInstanceMethods inherited from interface PlayerEvent
getEntity
-
Constructor Details
-
PlayerBlockInteractEvent
-
-
Method Details
-
isBlockingItemUse
public boolean isBlockingItemUse()Gets if the event should block the item use.- Returns:
- true if the item use is blocked, false otherwise
-
setBlockingItemUse
public void setBlockingItemUse(boolean blocks) Sets the blocking item use state of this event Note: If this is true, then noPlayerUseItemOnBlockEventwill be fired.- Parameters:
blocks- - true to block item interactions, false to not block
-
getBlock
- Specified by:
getBlockin interfaceBlockEvent
-
getBlockPosition
Gets the position of the interacted block.- Specified by:
getBlockPositionin interfaceBlockEvent- Returns:
- the block position
-
getCursorPosition
Gets the cursor position of the interacted block- Returns:
- the cursor position of the interaction
-
getHand
-
getBlockFace
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEventMarks theEventas cancelled or not.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEventGets the player.- Specified by:
getPlayerin interfacePlayerEvent- Returns:
- the player
-