From f5f84ff476fff9c1f3f3f755a7045af9a0e32da1 Mon Sep 17 00:00:00 2001 From: Fruxz <28064149+TheFruxz@users.noreply.github.com> Date: Sat, 17 Sep 2022 23:27:46 +0200 Subject: [PATCH] Add custom destroyerIdentity parameter to the sendBlockBreak function (#5840) --- ...destroyerIdentity-to-sendBlockDamage.patch | 38 +++++++++++++++++++ ...destroyerIdentity-to-sendBlockDamage.patch | 32 ++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch create mode 100644 patches/server/0937-Add-custom-destroyerIdentity-to-sendBlockDamage.patch diff --git a/patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch b/patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch new file mode 100644 index 000000000..46ac25ad4 --- /dev/null +++ b/patches/api/0392-Add-custom-destroyerIdentity-to-sendBlockDamage.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: TheFruxz +Date: Sat, 2 Apr 2022 13:03:39 +0200 +Subject: [PATCH] Add custom destroyerIdentity to sendBlockDamage + + +diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java +index b607c229cfb1e95b17b6a0073380089ef5e1b675..5e51bc9176b481ec70fd7e5ac23d04d59f8d1a9a 100644 +--- a/src/main/java/org/bukkit/entity/Player.java ++++ b/src/main/java/org/bukkit/entity/Player.java +@@ -592,7 +592,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + /** + * Send block damage. This fakes block break progress for a user at a + * certain location. This will not actually change the block's break +- * progress in any way. ++ * progress in any way. The destroying entity will be this player. + * + * @param loc the location of the damaged block + * @param progress the progress from 0.0 - 1.0 where 0 is no damage and +@@ -601,6 +601,18 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + public void sendBlockDamage(@NotNull Location loc, float progress); + + // Paper start ++ ++ /** ++ * Send block damage. This fakes block break progress for a user at a certain location. ++ * This will not actually change the block's break progress in any way. ++ * The destroying entity is defined via the destroyerIdentity parameter. ++ * ++ * @param loc the location of the damaged block ++ * @param progress the progress from 0.0 - 1.0 where 0 is no damage and 1.0 is the most damaged ++ * @param destroyerIdentity the entity id of the destroyer ++ */ ++ public void sendBlockDamage(@NotNull Location loc, float progress, int destroyerIdentity); ++ + /** + * Send multiple block changes. This fakes a multi block change packet for each + * chunk section that a block change occurs. This will not actually change the world in any way. diff --git a/patches/server/0937-Add-custom-destroyerIdentity-to-sendBlockDamage.patch b/patches/server/0937-Add-custom-destroyerIdentity-to-sendBlockDamage.patch new file mode 100644 index 000000000..d883e026d --- /dev/null +++ b/patches/server/0937-Add-custom-destroyerIdentity-to-sendBlockDamage.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: TheFruxz +Date: Sat, 26 Mar 2022 18:41:36 +0100 +Subject: [PATCH] Add custom destroyerIdentity to sendBlockDamage + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 41258fcfa0505500665c2f185b9ef6d050213355..4ba927b4585ca56337fa763d60d21de3b58bb2f7 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -965,13 +965,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + + @Override + public void sendBlockDamage(Location loc, float progress) { ++ // Paper start - customBlockDamage identity ++ sendBlockDamage(loc, progress, this.getHandle().getId()); ++ } ++ ++ @Override ++ public void sendBlockDamage(Location loc, float progress, int destroyerIdentity) { ++ // Paper end - customBlockDamage identity + Preconditions.checkArgument(loc != null, "loc must not be null"); + Preconditions.checkArgument(progress >= 0.0 && progress <= 1.0, "progress must be between 0.0 and 1.0 (inclusive)"); + + if (this.getHandle().connection == null) return; + + int stage = (int) (9 * progress); // There are 0 - 9 damage states +- ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(this.getHandle().getId(), new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage); ++ ClientboundBlockDestructionPacket packet = new ClientboundBlockDestructionPacket(destroyerIdentity, new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage); // Paper - customBlockDamage identity + this.getHandle().connection.send(packet); + } +