From b65d70e9ea365c81ab1e8908caa97b22da07d76a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 24 Feb 2021 20:21:39 +1100 Subject: [PATCH] #807: Add Player#sendBlockDamage() By: Parker Hawke --- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index b6b9ffc779..a499b17eab 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -44,6 +44,7 @@ import net.minecraft.server.MapIcon; import net.minecraft.server.MinecraftKey; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.PacketDataSerializer; +import net.minecraft.server.PacketPlayOutBlockBreakAnimation; import net.minecraft.server.PacketPlayOutBlockChange; import net.minecraft.server.PacketPlayOutChat; import net.minecraft.server.PacketPlayOutCustomPayload; @@ -545,6 +546,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().playerConnection.sendPacket(packet); } + @Override + public void sendBlockDamage(Location loc, float progress) { + 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 (getHandle().playerConnection == null) return; + + int stage = (int) (9 * progress); // There are 0 - 9 damage states + PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(getHandle().getId(), new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage); + getHandle().playerConnection.sendPacket(packet); + } + @Override public void sendSignChange(Location loc, String[] lines) { sendSignChange(loc, lines, DyeColor.BLACK);