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
|
|
|
|
Subject: [PATCH] Expose clicked BlockFace during BlockDamageEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
2023-12-06 17:34:54 +01:00
|
|
|
index 511221a686c1d2cad3b4abf79ee32b26058dad27..899439e0af639e8d9124522b3cb6a10601b17fe2 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
|
2023-12-03 04:41:35 +01:00
|
|
|
@@ -253,7 +253,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);
|
|
|
|
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, pos, direction, this.player.getInventory().getSelected(), f >= 1.0f); // Paper - Expose BlockFace
|
|
|
|
|
|
|
|
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
|
2023-12-06 17:34:54 +01:00
|
|
|
index 8f78b9e714c472f59f3abf565c53bd87a6811674..704ba208d5cbaef8bc2eb0a87d6fbb1be42e0460 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
|
2023-11-11 21:25:45 +01:00
|
|
|
@@ -652,13 +652,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) {
|
|
|
|
+ public static BlockDamageEvent callBlockDamageEvent(ServerPlayer who, BlockPos pos, Direction direction, ItemStack itemstack, boolean instaBreak) { // Paper - Expose BlockFace
|
|
|
|
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 - Expose BlockFace
|
|
|
|
player.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
return event;
|