From 54c4134006c91e71c33a3a963ba48068a2b8de36 Mon Sep 17 00:00:00 2001 From: jglrxavpok Date: Sat, 18 Jul 2020 17:45:56 +0200 Subject: [PATCH] BlockFace added to PlayerBlockInteractEvent --- .../server/event/player/PlayerBlockInteractEvent.java | 9 ++++++++- .../minestom/server/listener/BlockPlacementListener.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java b/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java index 251258ce8..a079fc246 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java @@ -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; + } } diff --git a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java index 79a8d444d..0150e4df9 100644 --- a/src/main/java/net/minestom/server/listener/BlockPlacementListener.java +++ b/src/main/java/net/minestom/server/listener/BlockPlacementListener.java @@ -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) {