Package net.minestom.server.event.player
Class PlayerBlockPlaceEvent
java.lang.Object
net.minestom.server.event.Event
net.minestom.server.event.CancellableEvent
net.minestom.server.event.player.PlayerBlockPlaceEvent
public class PlayerBlockPlaceEvent extends CancellableEvent
Called when a player tries placing a block.
-
Constructor Summary
Constructors Constructor Description PlayerBlockPlaceEvent(Player player, short blockStateId, short customBlockId, BlockPosition blockPosition, Player.Hand hand)
-
Method Summary
Modifier and Type Method Description void
consumeBlock(boolean consumeBlock)
Should the block be consumed if not cancelled.boolean
doesConsumeBlock()
Should the block be consumed if not cancelled.BlockPosition
getBlockPosition()
Gets the block position.short
getBlockStateId()
Gets the block state id.short
getCustomBlockId()
Gets the custom block id.Player.Hand
getHand()
Gets the hand with which the player is trying to place.Player
getPlayer()
Gets the player who is placing the block.void
setBlockStateId(short blockStateId)
Changes the visual block id.void
setCustomBlock(short customBlockId)
Sets both the blockStateId and customBlockId.void
setCustomBlock(java.lang.String customBlockId)
Sets both the blockId and customBlockId.void
setCustomBlock(CustomBlock customBlock)
Sets both the blockId and customBlockId.void
setCustomBlockId(short customBlockId)
Sets the custom block id to place.
-
Constructor Details
-
PlayerBlockPlaceEvent
public PlayerBlockPlaceEvent(@NotNull Player player, short blockStateId, short customBlockId, @NotNull BlockPosition blockPosition, @NotNull Player.Hand hand)
-
-
Method Details
-
setCustomBlock
Sets both the blockId and customBlockId.- Parameters:
customBlock
- the custom block to place
-
setCustomBlock
public void setCustomBlock(short customBlockId)Sets both the blockStateId and customBlockId.- Parameters:
customBlockId
- the custom block id to place
-
setCustomBlock
public void setCustomBlock(@NotNull java.lang.String customBlockId)Sets both the blockId and customBlockId.- Parameters:
customBlockId
- the custom block id to place
-
getCustomBlockId
public short getCustomBlockId()Gets the custom block id.- Returns:
- the custom block id
-
setCustomBlockId
public void setCustomBlockId(short customBlockId)Sets the custom block id to place.WARNING: this does not change the visual block id, see
setBlockStateId(short)
orsetCustomBlock(short)
.- Parameters:
customBlockId
- the custom block id
-
getBlockStateId
public short getBlockStateId()Gets the block state id.- Returns:
- the block state id
-
setBlockStateId
public void setBlockStateId(short blockStateId)Changes the visual block id.- Parameters:
blockStateId
- the new block state id
-
getPlayer
Gets the player who is placing the block.- Returns:
- the player
-
getBlockPosition
Gets the block position.- 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
-