Search in sources :

Example 11 with PathPoint

use of net.minecraft.server.v1_12_R1.PathPoint 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).d(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).d(this.a, localBlockPosition1);
            AxisAlignedBB localAxisAlignedBB3 = localAxisAlignedBB1.b(0.0D, localAxisAlignedBB2.e - 0.002D, 0.0D);
            if (this.b.world.b(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.b(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.aY()) {
                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_11_R1.AxisAlignedBB) PathPoint(net.minecraft.server.v1_11_R1.PathPoint) 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) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 12 with PathPoint

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

the class PlayerPathfinder method a.

private PathEntity a(PathPoint paramPathPoint1, PathPoint paramPathPoint2, float paramFloat) {
    paramPathPoint1.e = 0.0F;
    paramPathPoint1.f = paramPathPoint1.c(paramPathPoint2);
    paramPathPoint1.g = paramPathPoint1.f;
    this.a.a();
    this.b.clear();
    this.a.a(paramPathPoint1);
    Object localObject1 = paramPathPoint1;
    int i = 0;
    while (!this.a.e()) {
        i++;
        if (i >= 2000) {
            break;
        }
        PathPoint localObject2 = this.a.c();
        if (localObject2.equals(paramPathPoint2)) {
            localObject1 = paramPathPoint2;
            break;
        }
        if (localObject2.c(paramPathPoint2) < ((PathPoint) localObject1).c(paramPathPoint2)) {
            localObject1 = localObject2;
        }
        localObject2.i = true;
        int j = this.d.a(this.c, localObject2, paramPathPoint2, paramFloat);
        for (int k = 0; k < j; k++) {
            PathPoint localPathPoint = this.c[k];
            float f1 = localObject2.c(localPathPoint);
            localPathPoint.j = (localObject2.j + f1);
            localPathPoint.k = (f1 + localPathPoint.l);
            float f2 = localObject2.e + localPathPoint.k;
            if ((localPathPoint.j < paramFloat) && ((!localPathPoint.a()) || (f2 < localPathPoint.e))) {
                localPathPoint.h = (localObject2);
                localPathPoint.e = f2;
                localPathPoint.f = (localPathPoint.c(paramPathPoint2) + localPathPoint.l);
                if (localPathPoint.a()) {
                    this.a.a(localPathPoint, localPathPoint.e + localPathPoint.f);
                } else {
                    localPathPoint.g = (localPathPoint.e + localPathPoint.f);
                    this.a.a(localPathPoint);
                }
            }
        }
    }
    if (localObject1 == paramPathPoint1) {
        return null;
    }
    Object localObject2 = a(paramPathPoint1, (PathPoint) localObject1);
    return (PathEntity) localObject2;
}
Also used : PathPoint(net.minecraft.server.v1_10_R1.PathPoint) PathEntity(net.minecraft.server.v1_10_R1.PathEntity) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 13 with PathPoint

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

the class PlayerPathfinder method a.

private PathEntity a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient, double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat) {
    this.a.a();
    this.d.a(paramIBlockAccess, paramEntityInsentient);
    PathPoint localPathPoint1 = this.d.b();
    PathPoint localPathPoint2 = this.d.a(paramDouble1, paramDouble2, paramDouble3);
    PathEntity localPathEntity = a(localPathPoint1, localPathPoint2, paramFloat);
    this.d.a();
    return localPathEntity;
}
Also used : PathPoint(net.minecraft.server.v1_10_R1.PathPoint) PathEntity(net.minecraft.server.v1_10_R1.PathEntity)

Example 14 with PathPoint

use of net.minecraft.server.v1_12_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) {
        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();
    } else {
        i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
    }
    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 = new HashSet<BlockPosition>();
        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_10_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) Block(net.minecraft.server.v1_10_R1.Block) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_10_R1.PathPoint) HashSet(java.util.HashSet)

Example 15 with PathPoint

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

the class PlayerPathfinder method a.

private PathEntity a(Entity paramEntity, PathPoint paramPathPoint1, PathPoint paramPathPoint2, float paramFloat) {
    float newF = 0.0F;
    try {
        E.set(paramPathPoint1, 0.0F);
        newF = paramPathPoint1.b(paramPathPoint2);
        F.set(paramPathPoint1, newF);
        G.set(paramPathPoint1, newF);
    } catch (IllegalArgumentException e1) {
        e1.printStackTrace();
    } catch (IllegalAccessException e1) {
        e1.printStackTrace();
    }
    this.a.a();
    this.a.a(paramPathPoint1);
    Object localObject = paramPathPoint1;
    while (!this.a.e()) {
        PathPoint localPathPoint1 = this.a.c();
        if (localPathPoint1.equals(paramPathPoint2)) {
            return a(paramPathPoint1, paramPathPoint2);
        }
        if (localPathPoint1.b(paramPathPoint2) < ((PathPoint) localObject).b(paramPathPoint2)) {
            localObject = localPathPoint1;
        }
        localPathPoint1.i = true;
        int i = this.c.a(this.b, paramEntity, localPathPoint1, paramPathPoint2, paramFloat);
        for (int j = 0; j < i; j++) {
            PathPoint localPathPoint2 = this.b[j];
            try {
                float e = E.getFloat(localObject);
                float f = e + localPathPoint1.b(localPathPoint2);
                if ((f < paramFloat * 2.0F) && ((!localPathPoint2.a()) || (f < e))) {
                    H.set(localPathPoint2, localPathPoint1);
                    E.set(localPathPoint2, f);
                    newF = localPathPoint2.b(paramPathPoint2);
                    F.set(localPathPoint2, newF);
                    if (localPathPoint2.a()) {
                        this.a.a(localPathPoint2, f + newF);
                    } else {
                        G.set(localPathPoint2, f + newF);
                        this.a.a(localPathPoint2);
                    }
                }
            } catch (IllegalArgumentException e1) {
                e1.printStackTrace();
            } catch (IllegalAccessException e1) {
                e1.printStackTrace();
            }
        }
    }
    if (localObject == paramPathPoint1) {
        return null;
    }
    return a(paramPathPoint1, (PathPoint) localObject);
}
Also used : PathPoint(net.minecraft.server.v1_8_R3.PathPoint) PathPoint(net.minecraft.server.v1_8_R3.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