-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
AttackAction.java
53 lines (44 loc) · 1.34 KB
/
AttackAction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package mchorse.blockbuster.recording.actions;
import mchorse.blockbuster.common.entity.EntityActor;
import mchorse.blockbuster.recording.data.Frame;
import mchorse.blockbuster.utils.EntityUtils;
import net.minecraft.entity.Entity;
import net.minecraft.util.DamageSource;
/**
* Attack action
*
* This action is responsible for attacking an entity in in front of the actor.
*/
public class AttackAction extends Action
{
public AttackAction()
{}
@Override
public byte getType()
{
return Action.ATTACK;
}
@Override
public void apply(EntityActor actor)
{
Frame frame = actor.playback.record.frames.get(actor.playback.tick);
float yaw = actor.rotationYaw;
float pitch = actor.rotationPitch;
float yawHead = actor.rotationYawHead;
actor.rotationYaw = frame.yaw;
actor.rotationPitch = frame.pitch;
actor.rotationYawHead = frame.yawHead;
Entity target = EntityUtils.getTargetEntity(actor, 5.0);
actor.rotationYaw = yaw;
actor.rotationPitch = pitch;
actor.rotationYawHead = yawHead;
if (target != null)
{
target.attackEntityFrom(DamageSource.causeMobDamage(actor), 2.0F);
if (actor.morph != null)
{
actor.morph.attack(target, actor);
}
}
}
}