Add BlockFace to BlockDamageEvent

This commit is contained in:
aerulion 2023-08-21 04:36:07 +02:00
parent 1abc111403
commit edb4225d90
2 changed files with 3 additions and 3 deletions

View file

@ -197,7 +197,7 @@
+ }
+ return;
+ }
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, pos, this.player.getInventory().getSelected(), f >= 1.0f);
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, pos, direction, this.player.getInventory().getSelected(), f >= 1.0f); // Paper - Add BlockFace to BlockDamageEvent
+
+ if (blockEvent.isCancelled()) {
+ // Let the client know the block still exists

View file

@ -660,13 +660,13 @@ public class CraftEventFactory {
/**
* BlockDamageEvent
*/
public static BlockDamageEvent callBlockDamageEvent(ServerPlayer who, BlockPos pos, ItemStack itemstack, boolean instaBreak) {
public static BlockDamageEvent callBlockDamageEvent(ServerPlayer who, BlockPos pos, Direction direction, ItemStack itemstack, boolean instaBreak) { // Paper - Add BlockFace to BlockDamageEvent
Player player = who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
Block blockClicked = CraftBlock.at(who.level(), pos);
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak);
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, CraftBlock.notchToBlockFace(direction), itemInHand, instaBreak); // Paper - Add BlockFace to BlockDamageEvent
player.getServer().getPluginManager().callEvent(event);
return event;