#1157: Add Player#sendHurtAnimation()

This commit is contained in:
Parker Hawke 2023-04-02 12:58:05 +10:00 committed by md_5
parent e142fb9fd3
commit 20e8a486fe
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

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