aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0870-Add-BlockFace-to-BlockDamageEvent.patch
blob: f2de8e9aa8d661b002b07628c36fda9cbdc6dcec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: aerulion <aerulion@gmail.com>
Date: Mon, 21 Aug 2023 04:36:07 +0200
Subject: [PATCH] Add BlockFace to BlockDamageEvent


diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index c680f081ba548f84f07a968a46811090c53e57e3..d839f8df658c894f144ba4637d290ffbed77e132 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -261,7 +261,7 @@ public class ServerPlayerGameMode {
                     }
                     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
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 35afad4e995f7e94d7a4541157b237c73d1b9635..9d7bcd7a99cfda0776d267bada384304558fa6fe 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -655,13 +655,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;