EntityAILeapAtTarget .java

net.minecraft.entity.ai.EntityAILeapAtTarget (class, 64 lines): members: leapMotionY, leapTarget, leaper, continueExecuting, startExecuting, shouldExecute.

net.minecraft.entity.aiclass64 linescommonextends EntityAIBase1.9 KB

API Surface (3)

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

Fields & Constants (3)

leaper
leapTarget
leapMotionY

Code Graph: Dependencies (4)

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

Full Source

EntityAILeapAtTarget.java64 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.EntityLiving;
4
import net.minecraft.entity.EntityLivingBase;
5
import net.minecraft.util.MathHelper;
6
7
public class EntityAILeapAtTarget extends EntityAIBase
8
{
9
    /** The entity that is leaping. */
10
    EntityLiving leaper;
11
12
    /** The entity that the leaper is leaping towards. */
13
    EntityLivingBase leapTarget;
14
15
    /** The entity's motionY after leaping. */
16
    float leapMotionY;
17
18
    public EntityAILeapAtTarget(EntityLiving leapingEntity, float leapMotionYIn)
19
    {
20
        this.leaper = leapingEntity;
21
        this.leapMotionY = leapMotionYIn;
22
        this.setMutexBits(5);
23
    }
24
25
    /**
26
     * Returns whether the EntityAIBase should begin execution.
27
     */
28
    public boolean shouldExecute()
29
    {
30
        this.leapTarget = this.leaper.getAttackTarget();
31
32
        if (this.leapTarget == null)
33
        {
34
            return false;
35
        }
36
        else
37
        {
38
            double d0 = this.leaper.getDistanceSqToEntity(this.leapTarget);
39
            return d0 >= 4.0D && d0 <= 16.0D ? (!this.leaper.onGround ? false : this.leaper.getRNG().nextInt(5) == 0) : false;
40
        }
41
    }
42
43
    /**
44
     * Returns whether an in-progress EntityAIBase should continue executing
45
     */
46
    public boolean continueExecuting()
47
    {
48
        return !this.leaper.onGround;
49
    }
50
51
    /**
52
     * Execute a one shot task or start executing a continuous task
53
     */
54
    public void startExecuting()
55
    {
56
        double d0 = this.leapTarget.posX - this.leaper.posX;
57
        double d1 = this.leapTarget.posZ - this.leaper.posZ;
58
        float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1);
59
        this.leaper.motionX += d0 / (double)f * 0.5D * 0.800000011920929D + this.leaper.motionX * 0.20000000298023224D;
60
        this.leaper.motionZ += d1 / (double)f * 0.5D * 0.800000011920929D + this.leaper.motionZ * 0.20000000298023224D;
61
        this.leaper.motionY = (double)this.leapMotionY;
62
    }
63
}
64

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