BlockFace added to PlayerBlockInteractEvent

This commit is contained in:
jglrxavpok 2020-07-18 17:45:56 +02:00
parent 7485919805
commit 54c4134006
2 changed files with 9 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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) {