Search in sources :

Example 21 with PathType

use of net.minecraft.server.v1_14_R1.PathType in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
    EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
    PathType localObject1 = PathType.BLOCKED;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = 0; i < paramInt4; i++) {
        for (int k = 0; k < paramInt5; k++) {
            for (int m = 0; m < paramInt6; m++) {
                int n = i + paramInt1;
                int i1 = k + paramInt2;
                int i2 = m + paramInt3;
                PathType localPathType2 = a(paramIBlockAccess, n, i1, i2);
                if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
                    localPathType2 = PathType.WALKABLE;
                }
                if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
                    localPathType2 = PathType.BLOCKED;
                }
                if ((localPathType2 == PathType.RAIL) && (!(paramIBlockAccess.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramIBlockAccess.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
                    localPathType2 = PathType.FENCE;
                }
                if ((i == 0) && (k == 0) && (m == 0)) {
                    localObject1 = localPathType2;
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    PathType localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a(localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a(localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return localObject2;
}
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) BlockMinecartTrackAbstract(net.minecraft.server.v1_11_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 22 with PathType

use of net.minecraft.server.v1_14_R1.PathType 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++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
                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 23 with PathType

use of net.minecraft.server.v1_14_R1.PathType in project Citizens2 by CitizensDev.

the class PlayerNavigation method a.

private boolean a(int var0, int var1, int var2, int var3, int var4, int var5, Vec3D var6, double var7, double var9) {
    int var11 = var0 - var3 / 2;
    int var12 = var2 - var5 / 2;
    if (!this.b(var11, var1, var12, var3, var4, var5, var6, var7, var9)) {
        return false;
    } else {
        for (int var13 = var11; var13 < var11 + var3; ++var13) {
            for (int var14 = var12; var14 < var12 + var5; ++var14) {
                double var15 = var13 + 0.5D - var6.x;
                double var17 = var14 + 0.5D - var6.z;
                if (var15 * var7 + var17 * var9 >= 0.0D) {
                    PathType var19 = this.o.a(this.b, var13, var1 - 1, var14, this.a, var3, var4, var5, true, true);
                    if (var19 == PathType.WATER) {
                        return false;
                    }
                    if (var19 == PathType.LAVA) {
                        return false;
                    }
                    if (var19 == PathType.OPEN) {
                        return false;
                    }
                    var19 = this.o.a(this.b, var13, var1, var14, this.a, var3, var4, var5, true, true);
                    float var20 = this.a.a(var19);
                    if (var20 < 0.0F || var20 >= 8.0F) {
                        return false;
                    }
                    if (var19 == PathType.DAMAGE_FIRE || var19 == PathType.DANGER_FIRE || var19 == PathType.DAMAGE_OTHER) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
Also used : PathType(net.minecraft.server.v1_14_R1.PathType) PathPoint(net.minecraft.server.v1_14_R1.PathPoint)

Example 24 with PathType

use of net.minecraft.server.v1_14_R1.PathType in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

@Override
public PathPoint b() {
    int var0;
    BlockPosition var1;
    if (this.e() && this.b.isInWater()) {
        var0 = MathHelper.floor(this.b.getBoundingBox().minY);
        var1 = new MutableBlockPosition(this.b.locX, var0, this.b.locZ);
        for (IBlockData var2 = this.a.getType(var1); var2.getBlock() == Blocks.WATER || var2.p() == FluidTypes.WATER.a(false); var2 = this.a.getType(var1)) {
            ++var0;
            ((MutableBlockPosition) var1).c(this.b.locX, var0, this.b.locZ);
        }
        --var0;
    } else if (this.b.onGround) {
        var0 = MathHelper.floor(this.b.getBoundingBox().minY + 0.5D);
    } else {
        for (var1 = new BlockPosition(this.b); (this.a.getType(var1).isAir() || this.a.getType(var1).a(this.a, var1, PathMode.LAND)) && var1.getY() > 0; var1 = var1.down()) {
        }
        var0 = var1.up().getY();
    }
    var1 = new BlockPosition(this.b);
    PathType var2 = this.a(this.b, var1.getX(), var0, var1.getZ());
    if (this.b.a(var2) < 0.0F) {
        Set var3 = Sets.newHashSet();
        var3.add(new BlockPosition(this.b.getBoundingBox().minX, var0, this.b.getBoundingBox().minZ));
        var3.add(new BlockPosition(this.b.getBoundingBox().minX, var0, this.b.getBoundingBox().maxZ));
        var3.add(new BlockPosition(this.b.getBoundingBox().maxX, var0, this.b.getBoundingBox().minZ));
        var3.add(new BlockPosition(this.b.getBoundingBox().maxX, var0, this.b.getBoundingBox().maxZ));
        Iterator var5 = var3.iterator();
        while (var5.hasNext()) {
            BlockPosition var4 = (BlockPosition) var5.next();
            PathType var6 = this.a(this.b, var4);
            if (this.b.a(var6) >= 0.0F) {
                return this.a(var4.getX(), var4.getY(), var4.getZ());
            }
        }
    }
    return this.a(var1.getX(), var0, var1.getZ());
}
Also used : PathType(net.minecraft.server.v1_14_R1.PathType) IBlockData(net.minecraft.server.v1_14_R1.IBlockData) EnumSet(java.util.EnumSet) Set(java.util.Set) BlockPosition(net.minecraft.server.v1_14_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.MutableBlockPosition) PooledBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.PooledBlockPosition) Iterator(java.util.Iterator) MutableBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_14_R1.PathPoint)

Example 25 with PathType

use of net.minecraft.server.v1_14_R1.PathType in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess var0, int var1, int var2, int var3, EntityInsentient var4, int var5, int var6, int var7, boolean var8, boolean var9) {
    EnumSet var10 = EnumSet.noneOf(PathType.class);
    PathType var11 = PathType.BLOCKED;
    double var12 = var4.getWidth() / 2.0D;
    BlockPosition var14 = new BlockPosition(var4);
    var11 = this.a(var0, var1, var2, var3, var5, var6, var7, var8, var9, var10, var11, var14);
    if (var10.contains(PathType.FENCE)) {
        return PathType.FENCE;
    } else {
        PathType var15 = PathType.BLOCKED;
        Iterator var17 = var10.iterator();
        while (var17.hasNext()) {
            PathType var16 = (PathType) var17.next();
            if (var4.a(var16) < 0.0F) {
                return var16;
            }
            if (var4.a(var16) >= var4.a(var15)) {
                var15 = var16;
            }
        }
        if (var11 == PathType.OPEN && var4.a(var15) == 0.0F) {
            return PathType.OPEN;
        } else {
            return var15;
        }
    }
}
Also used : PathType(net.minecraft.server.v1_14_R1.PathType) EnumSet(java.util.EnumSet) BlockPosition(net.minecraft.server.v1_14_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.MutableBlockPosition) PooledBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.PooledBlockPosition) Iterator(java.util.Iterator)

Aggregations

PathType (net.minecraft.server.v1_10_R1.PathType)8 PathType (net.minecraft.server.v1_12_R1.PathType)8 PooledBlockPosition (net.minecraft.server.v1_14_R1.BlockPosition.PooledBlockPosition)8 PathType (net.minecraft.server.v1_14_R1.PathType)8 PathType (net.minecraft.server.v1_15_R1.PathType)8 PathType (net.minecraft.server.v1_16_R3.PathType)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)7 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)7 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)7 PathType (net.minecraft.server.v1_11_R1.PathType)7 PathType (net.minecraft.server.v1_13_R2.PathType)7 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)7 MutableBlockPosition (net.minecraft.server.v1_14_R1.BlockPosition.MutableBlockPosition)7 Iterator (java.util.Iterator)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)6 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)6 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)6 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)6