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.entity.Player;
import net.minestom.server.event.CancellableEvent; import net.minestom.server.event.CancellableEvent;
import net.minestom.server.instance.block.BlockFace;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
public class PlayerBlockInteractEvent extends CancellableEvent { public class PlayerBlockInteractEvent extends CancellableEvent {
private BlockPosition blockPosition; private BlockPosition blockPosition;
private Player.Hand hand; private Player.Hand hand;
private final BlockFace blockFace;
/** /**
* Does this interaction block the normal item use? * Does this interaction block the normal item use?
@ -15,9 +17,10 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
*/ */
private boolean blocksItemUse; private boolean blocksItemUse;
public PlayerBlockInteractEvent(BlockPosition blockPosition, Player.Hand hand) { public PlayerBlockInteractEvent(BlockPosition blockPosition, Player.Hand hand, BlockFace blockFace) {
this.blockPosition = blockPosition; this.blockPosition = blockPosition;
this.hand = hand; this.hand = hand;
this.blockFace = blockFace;
} }
public boolean isBlockingItemUse() { public boolean isBlockingItemUse() {
@ -35,4 +38,8 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
public Player.Hand getHand() { public Player.Hand getHand() {
return hand; return hand;
} }
public BlockFace getBlockFace() {
return blockFace;
}
} }

View File

@ -38,7 +38,7 @@ public class BlockPlacementListener {
return; return;
// Interact at block // Interact at block
PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(blockPosition, hand); PlayerBlockInteractEvent playerBlockInteractEvent = new PlayerBlockInteractEvent(blockPosition, hand, blockFace);
player.callCancellableEvent(PlayerBlockInteractEvent.class, playerBlockInteractEvent, () -> { player.callCancellableEvent(PlayerBlockInteractEvent.class, playerBlockInteractEvent, () -> {
CustomBlock customBlock = instance.getCustomBlock(blockPosition); CustomBlock customBlock = instance.getCustomBlock(blockPosition);
if (customBlock != null) { if (customBlock != null) {