Search in sources :

Example 91 with BlockPosition

use of net.minecraft.server.v1_10_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerNavigation method d.

@Override
protected void d() {
    PathPoint localPathPoint;
    for (int i = 0; i < this.c.d(); i++) {
        localPathPoint = this.c.a(i);
        Object localObject = i + 1 < this.c.d() ? this.c.a(i + 1) : null;
        IBlockData localIBlockData = this.b.getType(new BlockPosition(localPathPoint.a, localPathPoint.b, localPathPoint.c));
        Block localBlock = localIBlockData.getBlock();
        if (localBlock == Blocks.cauldron) {
            this.c.a(i, localPathPoint.a(localPathPoint.a, localPathPoint.b + 1, localPathPoint.c));
            if ((localObject != null) && (localPathPoint.b >= ((PathPoint) localObject).b)) {
                this.c.a(i + 1, ((PathPoint) localObject).a(((PathPoint) localObject).a, localPathPoint.b + 1, ((PathPoint) localObject).c));
            }
        }
    }
    if (this.f2) {
        if (this.b.h(new BlockPosition(MathHelper.floor(this.a.locX), (int) (this.a.getBoundingBox().b + 0.5D), MathHelper.floor(this.a.locZ)))) {
            return;
        }
        for (int i = 0; i < this.c.d(); i++) {
            localPathPoint = this.c.a(i);
            if (this.b.h(new BlockPosition(localPathPoint.a, localPathPoint.b, localPathPoint.c))) {
                this.c.b(i - 1);
                return;
            }
        }
    }
}
Also used : PathPoint(net.minecraft.server.v1_11_R1.PathPoint) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Block(net.minecraft.server.v1_11_R1.Block) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 92 with BlockPosition

use of net.minecraft.server.v1_10_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerNavigation method b.

private boolean b(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, Vec3D paramVec3D, double paramDouble1, double paramDouble2) {
    for (BlockPosition localBlockPosition : BlockPosition.a(new BlockPosition(paramInt1, paramInt2, paramInt3), new BlockPosition(paramInt1 + paramInt4 - 1, paramInt2 + paramInt5 - 1, paramInt3 + paramInt6 - 1))) {
        double d1 = localBlockPosition.getX() + 0.5D - paramVec3D.x;
        double d2 = localBlockPosition.getZ() + 0.5D - paramVec3D.z;
        if (d1 * paramDouble1 + d2 * paramDouble2 >= 0.0D) {
            Block localBlock = this.b.getType(localBlockPosition).getBlock();
            if (!localBlock.b(this.b, localBlockPosition)) {
                return false;
            }
        }
    }
    return true;
}
Also used : BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Block(net.minecraft.server.v1_12_R1.Block)

Example 93 with BlockPosition

use of net.minecraft.server.v1_10_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerNavigation method b.

@Override
public PathEntity b(BlockPosition paramBlockPosition) {
    BlockPosition localBlockPosition;
    if (this.b.getType(paramBlockPosition).getMaterial() == Material.AIR) {
        localBlockPosition = paramBlockPosition.down();
        while ((localBlockPosition.getY() > 0) && (this.b.getType(localBlockPosition).getMaterial() == Material.AIR)) {
            localBlockPosition = localBlockPosition.down();
        }
        if (localBlockPosition.getY() > 0) {
            return b2(localBlockPosition.up());
        }
        while ((localBlockPosition.getY() < this.b.getHeight()) && (this.b.getType(localBlockPosition).getMaterial() == Material.AIR)) {
            localBlockPosition = localBlockPosition.up();
        }
        paramBlockPosition = localBlockPosition;
    }
    if (this.b.getType(paramBlockPosition).getMaterial().isBuildable()) {
        localBlockPosition = paramBlockPosition.up();
        while ((localBlockPosition.getY() < this.b.getHeight()) && (this.b.getType(localBlockPosition).getMaterial().isBuildable())) {
            localBlockPosition = localBlockPosition.up();
        }
        return b2(localBlockPosition);
    }
    return b2(paramBlockPosition);
}
Also used : BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition)

Example 94 with BlockPosition

use of net.minecraft.server.v1_10_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerNavigation method d.

@Override
public void d() {
    this.e += 1;
    if (this.g) {
        k();
    }
    if (o()) {
        return;
    }
    if (b()) {
        n();
    } else if ((this.c != null) && (this.c.e() < this.c.d())) {
        Vec3D localVec3D = c();
        Vec3D localObject = this.c.a(this.a, this.c.e());
        if ((localVec3D.y > localObject.y) && (!this.a.onGround) && (MathHelper.floor(localVec3D.x) == MathHelper.floor(localObject.x)) && (MathHelper.floor(localVec3D.z) == MathHelper.floor(localObject.z))) {
            this.c.c(this.c.e() + 1);
        }
    }
    m();
    if (o()) {
        return;
    }
    Vec3D localVec3D = this.c.a(this.a);
    Object localObject = new BlockPosition(localVec3D).down();
    AxisAlignedBB localAxisAlignedBB = this.b.getType((BlockPosition) localObject).e(this.b, (BlockPosition) localObject);
    localVec3D = localVec3D.a(0.0D, 1.0D - localAxisAlignedBB.e, 0.0D);
    this.a.getControllerMove().a(localVec3D.x, localVec3D.y, localVec3D.z, this.d);
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Vec3D(net.minecraft.server.v1_12_R1.Vec3D)

Example 95 with BlockPosition

use of net.minecraft.server.v1_10_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

private PathPoint a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, double paramDouble, EnumDirection paramEnumDirection) {
    PathPoint localPathPoint = null;
    BlockPosition localBlockPosition1 = new BlockPosition(paramInt1, paramInt2, paramInt3);
    BlockPosition localBlockPosition2 = localBlockPosition1.down();
    double d1 = paramInt2 - (1.0D - this.a.getType(localBlockPosition2).e(this.a, localBlockPosition2).e);
    if (d1 - paramDouble > 1.125D) {
        return null;
    }
    PathType localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);
    float f = this.b.a(localPathType1);
    double d2 = this.b.width / 2.0D;
    if (f >= 0.0F) {
        localPathPoint = a(paramInt1, paramInt2, paramInt3);
        localPathPoint.m = localPathType1;
        localPathPoint.l = Math.max(localPathPoint.l, f);
    }
    if (localPathType1 == PathType.WALKABLE) {
        return localPathPoint;
    }
    if ((localPathPoint == null) && (paramInt4 > 0) && (localPathType1 != PathType.FENCE) && (localPathType1 != PathType.TRAPDOOR)) {
        localPathPoint = a(paramInt1, paramInt2 + 1, paramInt3, paramInt4 - 1, paramDouble, paramEnumDirection);
        if ((localPathPoint != null) && ((localPathPoint.m == PathType.OPEN) || (localPathPoint.m == PathType.WALKABLE)) && (this.b.width < 1.0F)) {
            double d3 = paramInt1 - paramEnumDirection.getAdjacentX() + 0.5D;
            double d4 = paramInt3 - paramEnumDirection.getAdjacentZ() + 0.5D;
            AxisAlignedBB localAxisAlignedBB1 = new AxisAlignedBB(d3 - d2, paramInt2 + 0.001D, d4 - d2, d3 + d2, paramInt2 + this.b.length, d4 + d2);
            AxisAlignedBB localAxisAlignedBB2 = this.a.getType(localBlockPosition1).e(this.a, localBlockPosition1);
            AxisAlignedBB localAxisAlignedBB3 = localAxisAlignedBB1.b(0.0D, localAxisAlignedBB2.e - 0.002D, 0.0D);
            if (this.b.world.a(localAxisAlignedBB3)) {
                localPathPoint = null;
            }
        }
    }
    if (localPathType1 == PathType.OPEN) {
        AxisAlignedBB localAxisAlignedBB4 = new AxisAlignedBB(paramInt1 - d2 + 0.5D, paramInt2 + 0.001D, paramInt3 - d2 + 0.5D, paramInt1 + d2 + 0.5D, paramInt2 + this.b.length, paramInt3 + d2 + 0.5D);
        if (this.b.world.a(localAxisAlignedBB4)) {
            return null;
        }
        if (this.b.width >= 1.0F) {
            PathType localPathType2 = a(this.b, paramInt1, paramInt2 - 1, paramInt3);
            if (localPathType2 == PathType.BLOCKED) {
                localPathPoint = a(paramInt1, paramInt2, paramInt3);
                localPathPoint.m = PathType.WALKABLE;
                localPathPoint.l = Math.max(localPathPoint.l, f);
                return localPathPoint;
            }
        }
        int i = 0;
        while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) {
            paramInt2--;
            if (i++ >= this.b.bg()) {
                return null;
            }
            localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);
            f = this.b.a(localPathType1);
            if ((localPathType1 != PathType.OPEN) && (f >= 0.0F)) {
                localPathPoint = a(paramInt1, paramInt2, paramInt3);
                localPathPoint.m = localPathType1;
                localPathPoint.l = Math.max(localPathPoint.l, f);
            } else if (f < 0.0F) {
                return null;
            }
        }
    }
    return localPathPoint;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) PathPoint(net.minecraft.server.v1_12_R1.PathPoint) PathType(net.minecraft.server.v1_12_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Aggregations

BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)23 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)23 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)20 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)17 Location (org.bukkit.Location)16 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)10 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)10 NPC (net.citizensnpcs.api.npc.NPC)8 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)8 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)7 PathType (net.minecraft.server.v1_10_R1.PathType)7 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)7 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)7 Block (net.minecraft.server.v1_10_R1.Block)6 Block (net.minecraft.server.v1_11_R1.Block)6 PathType (net.minecraft.server.v1_11_R1.PathType)6 PathType (net.minecraft.server.v1_12_R1.PathType)6 BlockPosition (net.minecraft.server.v1_9_R2.BlockPosition)6 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)5 IBlockData (net.minecraft.server.v1_10_R1.IBlockData)5