EntityAIMoveTowardsRestriction .java

net.minecraft.entity.ai.EntityAIMoveTowardsRestriction (class, 66 lines): members: movePosX, movePosY, movePosZ, movementSpeed, theEntity, startExecuting.

net.minecraft.entity.aiclass66 linescommonextends EntityAIBase1.8 KB

API Surface (3)

boolean shouldExecute()
boolean continueExecuting()
void startExecuting()

Fields & Constants (5)

theEntity
movePosX
movePosY
movePosZ
movementSpeed

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

EntityAIMoveTowardsRestriction.java66 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.EntityCreature;
4
import net.minecraft.util.BlockPos;
5
import net.minecraft.util.Vec3;
6
7
public class EntityAIMoveTowardsRestriction extends EntityAIBase
8
{
9
    private EntityCreature theEntity;
10
    private double movePosX;
11
    private double movePosY;
12
    private double movePosZ;
13
    private double movementSpeed;
14
15
    public EntityAIMoveTowardsRestriction(EntityCreature creatureIn, double speedIn)
16
    {
17
        this.theEntity = creatureIn;
18
        this.movementSpeed = speedIn;
19
        this.setMutexBits(1);
20
    }
21
22
    /**
23
     * Returns whether the EntityAIBase should begin execution.
24
     */
25
    public boolean shouldExecute()
26
    {
27
        if (this.theEntity.isWithinHomeDistanceCurrentPosition())
28
        {
29
            return false;
30
        }
31
        else
32
        {
33
            BlockPos blockpos = this.theEntity.getHomePosition();
34
            Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 16, 7, new Vec3((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ()));
35
36
            if (vec3 == null)
37
            {
38
                return false;
39
            }
40
            else
41
            {
42
                this.movePosX = vec3.xCoord;
43
                this.movePosY = vec3.yCoord;
44
                this.movePosZ = vec3.zCoord;
45
                return true;
46
            }
47
        }
48
    }
49
50
    /**
51
     * Returns whether an in-progress EntityAIBase should continue executing
52
     */
53
    public boolean continueExecuting()
54
    {
55
        return !this.theEntity.getNavigator().noPath();
56
    }
57
58
    /**
59
     * Execute a one shot task or start executing a continuous task
60
     */
61
    public void startExecuting()
62
    {
63
        this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.movementSpeed);
64
    }
65
}
66

Deobfuscated MCP 1.8.9 source of EntityAIMoveTowardsRestriction from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/ai/EntityAIMoveTowardsRestriction.java), stored verbatim.