mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 18:50:51 +01:00
#1189: Add LivingEntity#playHurtAnimation()
By: Collin <collinjbarber@gmail.com>
This commit is contained in:
parent
8b30feb641
commit
8bd41d17a2
1 changed files with 16 additions and 0 deletions
|
@ -8,6 +8,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket;
|
||||||
|
import net.minecraft.server.level.WorldServer;
|
||||||
import net.minecraft.sounds.SoundEffect;
|
import net.minecraft.sounds.SoundEffect;
|
||||||
import net.minecraft.world.EnumHand;
|
import net.minecraft.world.EnumHand;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
@ -682,6 +684,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||||
getHandle().swing(EnumHand.OFF_HAND, true);
|
getHandle().swing(EnumHand.OFF_HAND, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playHurtAnimation(float yaw) {
|
||||||
|
if (getHandle().level() instanceof WorldServer world) {
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
ClientboundHurtAnimationPacket packet = new ClientboundHurtAnimationPacket(getEntityId(), actualYaw);
|
||||||
|
|
||||||
|
world.getChunkSource().broadcastAndSend(getHandle(), packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCollidable(boolean collidable) {
|
public void setCollidable(boolean collidable) {
|
||||||
getHandle().collides = collidable;
|
getHandle().collides = collidable;
|
||||||
|
|
Loading…
Reference in a new issue