mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 18:32:28 +01:00
BlockFace added to PlayerBlockInteractEvent
This commit is contained in:
parent
7485919805
commit
54c4134006
@ -2,12 +2,14 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
||||
public class PlayerBlockInteractEvent extends CancellableEvent {
|
||||
|
||||
private BlockPosition blockPosition;
|
||||
private Player.Hand hand;
|
||||
private final BlockFace blockFace;
|
||||
|
||||
/**
|
||||
* Does this interaction block the normal item use?
|
||||
@ -15,9 +17,10 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
|
||||
*/
|
||||
private boolean blocksItemUse;
|
||||
|
||||
public PlayerBlockInteractEvent(BlockPosition blockPosition, Player.Hand hand) {
|
||||
public PlayerBlockInteractEvent(BlockPosition blockPosition, Player.Hand hand, BlockFace blockFace) {
|
||||
this.blockPosition = blockPosition;
|
||||
this.hand = hand;
|
||||
this.blockFace = blockFace;
|
||||
}
|
||||
|
||||
public boolean isBlockingItemUse() {
|
||||
@ -35,4 +38,8 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
|
||||
public Player.Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public BlockFace getBlockFace() {
|
||||
return blockFace;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class BlockPlacementListener {
|
||||
return;
|
||||
|
||||
// Interact at block
|
||||
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(blockPosition, hand);
|
||||
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(blockPosition, hand, blockFace);
|
||||
player.callCancellableEvent(PlayerBlockInteractEvent.class, playerBlockInteractEvent, () -> {
|
||||
CustomBlock customBlock = instance.getCustomBlock(blockPosition);
|
||||
if (customBlock != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user