Java Code Examples for net.minecraft.entity.player.EntityPlayer.getDistanceSqToCenter()

The following are Jave code examples for showing how to use getDistanceSqToCenter() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Backmemed   File: PhaseHoldingPattern.java   View Source Code Vote up 4 votes
private void findNewTarget()
{
    if (this.currentPath != null && this.currentPath.isFinished())
    {
        BlockPos blockpos = this.dragon.world.getTopSolidOrLiquidBlock(new BlockPos(WorldGenEndPodium.END_PODIUM_LOCATION));
        int i = this.dragon.getFightManager() == null ? 0 : this.dragon.getFightManager().getNumAliveCrystals();

        if (this.dragon.getRNG().nextInt(i + 3) == 0)
        {
            this.dragon.getPhaseManager().setPhase(PhaseList.LANDING_APPROACH);
            return;
        }

        double d0 = 64.0D;
        EntityPlayer entityplayer = this.dragon.world.getNearestAttackablePlayer(blockpos, d0, d0);

        if (entityplayer != null)
        {
            d0 = entityplayer.getDistanceSqToCenter(blockpos) / 512.0D;
        }

        if (entityplayer != null && (this.dragon.getRNG().nextInt(MathHelper.abs((int)d0) + 2) == 0 || this.dragon.getRNG().nextInt(i + 2) == 0))
        {
            this.strafePlayer(entityplayer);
            return;
        }
    }

    if (this.currentPath == null || this.currentPath.isFinished())
    {
        int j = this.dragon.initPathPoints();
        int k = j;

        if (this.dragon.getRNG().nextInt(8) == 0)
        {
            this.clockwise = !this.clockwise;
            k = j + 6;
        }

        if (this.clockwise)
        {
            ++k;
        }
        else
        {
            --k;
        }

        if (this.dragon.getFightManager() != null && this.dragon.getFightManager().getNumAliveCrystals() >= 0)
        {
            k = k % 12;

            if (k < 0)
            {
                k += 12;
            }
        }
        else
        {
            k = k - 12;
            k = k & 7;
            k = k + 12;
        }

        this.currentPath = this.dragon.findPath(j, k, (PathPoint)null);

        if (this.currentPath != null)
        {
            this.currentPath.incrementPathIndex();
        }
    }

    this.navigateToNextPathNode();
}
 
Example 2
Project: CustomWorldGen   File: PhaseHoldingPattern.java   View Source Code Vote up 4 votes
private void findNewTarget()
{
    if (this.currentPath != null && this.currentPath.isFinished())
    {
        BlockPos blockpos = this.dragon.worldObj.getTopSolidOrLiquidBlock(new BlockPos(WorldGenEndPodium.END_PODIUM_LOCATION));
        int i = this.dragon.getFightManager() == null ? 0 : this.dragon.getFightManager().getNumAliveCrystals();

        if (this.dragon.getRNG().nextInt(i + 3) == 0)
        {
            this.dragon.getPhaseManager().setPhase(PhaseList.LANDING_APPROACH);
            return;
        }

        double d0 = 64.0D;
        EntityPlayer entityplayer = this.dragon.worldObj.getNearestAttackablePlayer(blockpos, d0, d0);

        if (entityplayer != null)
        {
            d0 = entityplayer.getDistanceSqToCenter(blockpos) / 512.0D;
        }

        if (entityplayer != null && (this.dragon.getRNG().nextInt(MathHelper.abs_int((int)d0) + 2) == 0 || this.dragon.getRNG().nextInt(i + 2) == 0))
        {
            this.strafePlayer(entityplayer);
            return;
        }
    }

    if (this.currentPath == null || this.currentPath.isFinished())
    {
        int j = this.dragon.initPathPoints();
        int k = j;

        if (this.dragon.getRNG().nextInt(8) == 0)
        {
            this.clockwise = !this.clockwise;
            k = j + 6;
        }

        if (this.clockwise)
        {
            ++k;
        }
        else
        {
            --k;
        }

        if (this.dragon.getFightManager() != null && this.dragon.getFightManager().getNumAliveCrystals() >= 0)
        {
            k = k % 12;

            if (k < 0)
            {
                k += 12;
            }
        }
        else
        {
            k = k - 12;
            k = k & 7;
            k = k + 12;
        }

        this.currentPath = this.dragon.findPath(j, k, (PathPoint)null);

        if (this.currentPath != null)
        {
            this.currentPath.incrementPathIndex();
        }
    }

    this.navigateToNextPathNode();
}