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
ConstructorsConstructorDescriptionPlayerBlockPlaceEvent(@NotNull Player player, @NotNull Block block, @NotNull BlockFace blockFace, @NotNull BlockVec blockPosition, Player.Hand hand) -
Method Summary
Modifier and TypeMethodDescriptionvoidconsumeBlock(boolean consumeBlock) Should the block be consumed if not cancelled.booleanShould the block be consumed if not cancelled.@NotNull BlockgetBlock()Gets the block which will be placed.@NotNull BlockFace@NotNull BlockVecGets the block position.getHand()Gets the hand with which the player is trying to place.@NotNull PlayerGets the player.booleanGets if theEventshould be cancelled or not.voidChanges the block to be placed.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.voidsetDoBlockUpdates(boolean doBlockUpdates) Should the place trigger updates (on self and neighbors)booleanShould 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, waitMethods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstanceMethods inherited from interface net.minestom.server.event.trait.PlayerEvent
getEntity
-
Constructor Details
-
PlayerBlockPlaceEvent
public PlayerBlockPlaceEvent(@NotNull @NotNull Player player, @NotNull @NotNull Block block, @NotNull @NotNull BlockFace blockFace, @NotNull @NotNull BlockVec blockPosition, @NotNull Player.Hand hand)
-
-
Method Details
-
getBlock
Gets the block which will be placed.- Specified by:
getBlockin 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:
getBlockPositionin interfaceBlockEvent- Returns:
- the block position
-
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: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
-