Search in sources :

Example 31 with PathPoint

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

the class PlayerPathfinderNormal method b.

@Override
public PathPoint b() {
    int i;
    BlockPosition localObject1;
    if ((e()) && (this.b.isInWater())) {
        i = (int) this.b.getBoundingBox().b;
        localObject1 = new BlockPosition.MutableBlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ));
        Block localObject2 = this.a.getType(localObject1).getBlock();
        while ((localObject2 == Blocks.FLOWING_WATER) || (localObject2 == Blocks.WATER)) {
            i++;
            ((MutableBlockPosition) localObject1).c(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ));
            localObject2 = this.a.getType(localObject1).getBlock();
        }
    } else if (this.b.onGround) {
        i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
    } else {
        localObject1 = new BlockPosition(this.b);
        while (((this.a.getType(localObject1).getMaterial() == Material.AIR) || (this.a.getType(localObject1).getBlock().b(this.a, localObject1))) && (localObject1.getY() > 0)) {
            localObject1 = localObject1.down();
        }
        i = localObject1.up().getY();
    }
    localObject1 = new BlockPosition(this.b);
    Object localObject2 = a(this.b, localObject1.getX(), i, localObject1.getZ());
    if (this.b.a((PathType) localObject2) < 0.0F) {
        HashSet<BlockPosition> localHashSet = Sets.newHashSet();
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().c));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().f));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().c));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().f));
        for (BlockPosition localBlockPosition : localHashSet) {
            PathType localPathType = a(this.b, localBlockPosition);
            if (this.b.a(localPathType) >= 0.0F) {
                return a(localBlockPosition.getX(), localBlockPosition.getY(), localBlockPosition.getZ());
            }
        }
    }
    return a(localObject1.getX(), i, localObject1.getZ());
}
Also used : PathType(net.minecraft.server.v1_11_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) Block(net.minecraft.server.v1_11_R1.Block) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 32 with PathPoint

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

the class PlayerPathfinderNormal method a.

@Override
public int a(PathPoint[] paramArrayOfPathPoint, PathPoint paramPathPoint1, PathPoint paramPathPoint2, float paramFloat) {
    int i = 0;
    int k = 0;
    PathType localPathType = a(this.b, paramPathPoint1.a, paramPathPoint1.b + 1, paramPathPoint1.c);
    if (this.b.a(localPathType) >= 0.0F) {
        k = MathHelper.d(Math.max(1.0F, this.b.P));
    }
    BlockPosition localBlockPosition = new BlockPosition(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c).down();
    double d = paramPathPoint1.b - (1.0D - this.a.getType(localBlockPosition).d(this.a, localBlockPosition).e);
    PathPoint localPathPoint1 = a(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c + 1, k, d, EnumDirection.SOUTH);
    PathPoint localPathPoint2 = a(paramPathPoint1.a - 1, paramPathPoint1.b, paramPathPoint1.c, k, d, EnumDirection.WEST);
    PathPoint localPathPoint3 = a(paramPathPoint1.a + 1, paramPathPoint1.b, paramPathPoint1.c, k, d, EnumDirection.EAST);
    PathPoint localPathPoint4 = a(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c - 1, k, d, EnumDirection.NORTH);
    if ((localPathPoint1 != null) && (!localPathPoint1.i) && (localPathPoint1.a(paramPathPoint2) < paramFloat)) {
        paramArrayOfPathPoint[(i++)] = localPathPoint1;
    }
    if ((localPathPoint2 != null) && (!localPathPoint2.i) && (localPathPoint2.a(paramPathPoint2) < paramFloat)) {
        paramArrayOfPathPoint[(i++)] = localPathPoint2;
    }
    if ((localPathPoint3 != null) && (!localPathPoint3.i) && (localPathPoint3.a(paramPathPoint2) < paramFloat)) {
        paramArrayOfPathPoint[(i++)] = localPathPoint3;
    }
    if ((localPathPoint4 != null) && (!localPathPoint4.i) && (localPathPoint4.a(paramPathPoint2) < paramFloat)) {
        paramArrayOfPathPoint[(i++)] = localPathPoint4;
    }
    int m = (localPathPoint4 == null) || (localPathPoint4.m == PathType.OPEN) || (localPathPoint4.l != 0.0F) ? 1 : 0;
    int n = (localPathPoint1 == null) || (localPathPoint1.m == PathType.OPEN) || (localPathPoint1.l != 0.0F) ? 1 : 0;
    int i1 = (localPathPoint3 == null) || (localPathPoint3.m == PathType.OPEN) || (localPathPoint3.l != 0.0F) ? 1 : 0;
    int i2 = (localPathPoint2 == null) || (localPathPoint2.m == PathType.OPEN) || (localPathPoint2.l != 0.0F) ? 1 : 0;
    PathPoint localPathPoint5;
    if ((m != 0) && (i2 != 0)) {
        localPathPoint5 = a(paramPathPoint1.a - 1, paramPathPoint1.b, paramPathPoint1.c - 1, k, d, EnumDirection.NORTH);
        if ((localPathPoint5 != null) && (!localPathPoint5.i) && (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
            paramArrayOfPathPoint[(i++)] = localPathPoint5;
        }
    }
    if ((m != 0) && (i1 != 0)) {
        localPathPoint5 = a(paramPathPoint1.a + 1, paramPathPoint1.b, paramPathPoint1.c - 1, k, d, EnumDirection.NORTH);
        if ((localPathPoint5 != null) && (!localPathPoint5.i) && (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
            paramArrayOfPathPoint[(i++)] = localPathPoint5;
        }
    }
    if ((n != 0) && (i2 != 0)) {
        localPathPoint5 = a(paramPathPoint1.a - 1, paramPathPoint1.b, paramPathPoint1.c + 1, k, d, EnumDirection.SOUTH);
        if ((localPathPoint5 != null) && (!localPathPoint5.i) && (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
            paramArrayOfPathPoint[(i++)] = localPathPoint5;
        }
    }
    if ((n != 0) && (i1 != 0)) {
        localPathPoint5 = a(paramPathPoint1.a + 1, paramPathPoint1.b, paramPathPoint1.c + 1, k, d, EnumDirection.SOUTH);
        if ((localPathPoint5 != null) && (!localPathPoint5.i) && (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
            paramArrayOfPathPoint[(i++)] = localPathPoint5;
        }
    }
    return i;
}
Also used : PathType(net.minecraft.server.v1_11_R1.PathType) PathPoint(net.minecraft.server.v1_11_R1.PathPoint) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Aggregations

PathPoint (net.minecraft.server.v1_11_R1.PathPoint)9 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)8 PathPoint (net.minecraft.server.v1_12_R1.PathPoint)8 PathPoint (net.minecraft.server.v1_8_R3.PathPoint)7 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)4 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)4 PathEntity (net.minecraft.server.v1_11_R1.PathEntity)4 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)4 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)3 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)3 PathType (net.minecraft.server.v1_10_R1.PathType)3 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)3 PathType (net.minecraft.server.v1_11_R1.PathType)3 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)3 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)3 PathType (net.minecraft.server.v1_12_R1.PathType)3 CancelReason (net.citizensnpcs.api.ai.event.CancelReason)2 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)2 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)2 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)2