#1189: Add LivingEntity#playHurtAnimation()
This commit is contained in:
parent
95c335c636
commit
b60a95c8cf
@ -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…
x
Reference in New Issue
Block a user