2023-08-22 05:07:18 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: aerulion <aerulion@gmail.com>
|
|
|
|
Date: Mon, 21 Aug 2023 04:36:07 +0200
|
2024-01-14 16:31:39 +01:00
|
|
|
Subject: [PATCH] Add BlockFace to BlockDamageEvent
|
2023-08-22 05:07:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2024-04-25 00:36:49 +02:00
|
|
|
index 7b4426ac0435d3f419d9ece29dc9eccdb8f99950..cef3a64b5e6c4d34ed079078420078a7adfcd574 100644
|
2023-08-22 05:07:18 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2024-04-25 00:36:49 +02:00
|
|
|
@@ -256,7 +256,7 @@ public class ServerPlayerGameMode {
|
2023-08-22 05:07:18 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, pos, this.player.getInventory().getSelected(), f >= 1.0f);
|
2024-01-14 16:31:39 +01:00
|
|
|
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, pos, direction, this.player.getInventory().getSelected(), f >= 1.0f); // Paper - Add BlockFace to BlockDamageEvent
|
2023-08-22 05:07:18 +02:00
|
|
|
|
|
|
|
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
|
2024-05-11 23:48:37 +02:00
|
|
|
index 304a224e82d3b73ae914c58753eca9ecb1a08c1c..1543a8d55a55b1e6b48855f584ecf8c543f2e5f2 100644
|
2023-08-22 05:07:18 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-04-25 00:36:49 +02:00
|
|
|
@@ -650,13 +650,13 @@ public class CraftEventFactory {
|
2023-08-22 05:07:18 +02:00
|
|
|
/**
|
|
|
|
* BlockDamageEvent
|
|
|
|
*/
|
|
|
|
- public static BlockDamageEvent callBlockDamageEvent(ServerPlayer who, BlockPos pos, ItemStack itemstack, boolean instaBreak) {
|
2024-01-14 16:31:39 +01:00
|
|
|
+ public static BlockDamageEvent callBlockDamageEvent(ServerPlayer who, BlockPos pos, Direction direction, ItemStack itemstack, boolean instaBreak) { // Paper - Add BlockFace to BlockDamageEvent
|
2023-08-22 05:07:18 +02:00
|
|
|
Player player = who.getBukkitEntity();
|
|
|
|
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
|
|
|
|
|
|
|
Block blockClicked = CraftBlock.at(who.level(), pos);
|
|
|
|
|
|
|
|
- BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak);
|
2024-01-14 16:31:39 +01:00
|
|
|
+ BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, CraftBlock.notchToBlockFace(direction), itemInHand, instaBreak); // Paper - Add BlockFace to BlockDamageEvent
|
2023-08-22 05:07:18 +02:00
|
|
|
player.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
return event;
|