#1157: Add Player#sendHurtAnimation()

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
CraftBukkit/Spigot 2023-04-02 12:58:05 +10:00
parent 609f8055d2
commit f8dd2656fa

View file

@ -39,6 +39,7 @@ import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.network.protocol.game.ClientboundClearTitlesPacket;
import net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket;
import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket;
@ -840,6 +841,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().connection.send(packet);
}
@Override
public void sendHurtAnimation(float yaw) {
if (getHandle().connection == null) {
return;
}
/*
* Vanilla degrees state that 0 = left, 90 = front, 180 = right, and 270 = behind.
* This makes no sense. We'll add 90 to it so that 0 = front, clockwise from there.
*/
float actualYaw = yaw + 90;
getHandle().connection.send(new ClientboundHurtAnimationPacket(getEntityId(), actualYaw));
}
@Override
public void addCustomChatCompletions(Collection<String> completions) {
this.sendCustomChatCompletionPacket(completions, ClientboundCustomChatCompletionsPacket.Action.ADD);