blob: e0643fd79fad101f98c0e47d82b04539e78386c2 (
plain)
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
54
55
56
57
58
59
60
61
62
63
|
package com.mondecitronne.homunculus;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.EntityAIBase;
public class EntityAIMasochism extends EntityAIBase {
protected EntityHomunculus homunculus;
protected Entity dominant;
private final float targetDistance;
private final double speed;
private int interestTimer;
public EntityAIMasochism(EntityHomunculus entityIn, double moveSpeed, float maxTargetDistance) {
homunculus = entityIn;
speed = moveSpeed;
targetDistance = maxTargetDistance;
interestTimer = 0;
}
protected boolean interestElapsed() {
return homunculus.ticksExisted - interestTimer > 1200;
}
protected void resetInterest() {
interestTimer = homunculus.ticksExisted;
}
@Override
public boolean shouldExecute() {
if (!homunculus.isMasochist()) {
return false;
}
if (dominant != null && !interestElapsed()) {
return true;
}
dominant = homunculus.getRevengeTarget();
resetInterest();
return dominant != null;
}
@Override
public boolean shouldContinueExecuting() {
return !homunculus.getNavigator().noPath() &&
dominant.isEntityAlive() &&
!interestElapsed() &&
dominant.getDistanceSq(homunculus) < (double) (targetDistance * targetDistance);
}
@Override
public void startExecuting() {
if (dominant.getDistanceSq(homunculus) > 8.0) {
homunculus.getNavigator().tryMoveToEntityLiving(dominant, speed);
}
updateTask();
}
@Override
public void updateTask() {
homunculus.getLookHelper().setLookPosition(dominant.posX, dominant.posY + (double) dominant.getEyeHeight(),
dominant.posZ, (float) homunculus.getHorizontalFaceSpeed(), (float) homunculus.getVerticalFaceSpeed());
}
}
|