Commits
Collin authored and md_5 committed b60a95c8cf3
1 1 | package org.bukkit.craftbukkit.entity; |
2 2 | |
3 3 | import com.google.common.base.Preconditions; |
4 4 | import com.google.common.collect.Sets; |
5 5 | import java.util.ArrayList; |
6 6 | import java.util.Collection; |
7 7 | import java.util.Iterator; |
8 8 | import java.util.List; |
9 9 | import java.util.Set; |
10 10 | import java.util.UUID; |
11 + | import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket; |
12 + | import net.minecraft.server.level.WorldServer; |
11 13 | import net.minecraft.sounds.SoundEffect; |
12 14 | import net.minecraft.world.EnumHand; |
13 15 | import net.minecraft.world.damagesource.DamageSource; |
14 16 | import net.minecraft.world.effect.MobEffect; |
15 17 | import net.minecraft.world.effect.MobEffectList; |
16 18 | import net.minecraft.world.entity.EntityInsentient; |
17 19 | import net.minecraft.world.entity.EntityLiving; |
18 20 | import net.minecraft.world.entity.EntityTypes; |
19 21 | import net.minecraft.world.entity.EnumMonsterType; |
20 22 | import net.minecraft.world.entity.ai.attributes.GenericAttributes; |
675 677 | getHandle().swing(EnumHand.MAIN_HAND, true); |
676 678 | } |
677 679 | |
678 680 | |
679 681 | public void swingOffHand() { |
680 682 | Preconditions.checkState(!getHandle().generation, "Cannot swing hand during world generation"); |
681 683 | |
682 684 | getHandle().swing(EnumHand.OFF_HAND, true); |
683 685 | } |
684 686 | |
687 + | |
688 + | public void playHurtAnimation(float yaw) { |
689 + | if (getHandle().level() instanceof WorldServer world) { |
690 + | /* |
691 + | * Vanilla degrees state that 0 = left, 90 = front, 180 = right, and 270 = behind. |
692 + | * This makes no sense. We'll add 90 to it so that 0 = front, clockwise from there. |
693 + | */ |
694 + | float actualYaw = yaw + 90; |
695 + | ClientboundHurtAnimationPacket packet = new ClientboundHurtAnimationPacket(getEntityId(), actualYaw); |
696 + | |
697 + | world.getChunkSource().broadcastAndSend(getHandle(), packet); |
698 + | } |
699 + | } |
700 + | |
685 701 | |
686 702 | public void setCollidable(boolean collidable) { |
687 703 | getHandle().collides = collidable; |
688 704 | } |
689 705 | |
690 706 | |
691 707 | public boolean isCollidable() { |
692 708 | return getHandle().collides; |
693 709 | } |
694 710 | |