#807: Add Player#sendBlockDamage()

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
CraftBukkit/Spigot 2021-02-24 20:21:39 +11:00
parent 510efe562a
commit b65d70e9ea

View file

@ -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);