Package net.minestom.server.event.player
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(@NotNull Player player, Player.Hand hand, @NotNull Block block, @NotNull BlockVec blockPosition, @NotNull Point cursorPosition, @NotNull BlockFace blockFace) -
Method Summary
Modifier and TypeMethodDescription@NotNull BlockgetBlock()@NotNull BlockFaceGets the block face.@NotNull BlockVecGets the position of the interacted block.@NotNull PointGets the cursor position of the interacted blockgetHand()Gets the hand used for the interaction.@NotNull PlayerGets 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstanceMethods inherited from interface net.minestom.server.event.trait.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
Gets the hand used for the interaction.- Returns:
- the hand used
-
getBlockFace
Gets the block face.- Returns:
- the block face
-
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
-