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
ConstructorDescriptionPlayerBlockInteractEvent
(@NotNull Player player, @NotNull PlayerHand hand, @NotNull Block block, @NotNull BlockVec blockPosition, @NotNull Point cursorPosition, @NotNull BlockFace blockFace) -
Method Summary
Modifier and TypeMethodDescription@NotNull Block
getBlock()
@NotNull BlockFace
Gets the block face.@NotNull BlockVec
Gets the position of the interacted block.@NotNull Point
Gets the cursor position of the interacted block@NotNull PlayerHand
getHand()
Gets the hand used for the interaction.@NotNull Player
Gets the player.boolean
Gets if the event should block the item use.boolean
Gets if theEvent
should be cancelled or not.void
setBlockingItemUse
(boolean blocks) Sets the blocking item use state of this event Note: If this is true, then noPlayerUseItemOnBlockEvent
will be fired.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.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
-
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 noPlayerUseItemOnBlockEvent
will be fired.- Parameters:
blocks
- - true to block item interactions, false to not block
-
getBlock
- Specified by:
getBlock
in interfaceBlockEvent
-
getBlockPosition
Gets the position of the interacted block.- Specified by:
getBlockPosition
in 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: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
-