Search in sources :

Example 1 with MutableBlockPosition

use of net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition 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_12_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) Block(net.minecraft.server.v1_12_R1.Block) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 2 with MutableBlockPosition

use of net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition 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.locY());
        MutableBlockPosition varx = new MutableBlockPosition(this.b.locX(), var0, this.b.locZ());
        for (IBlockData var2 = this.a.getType(varx); var2.getBlock() == Blocks.WATER || var2.getFluid() == FluidTypes.WATER.a(false); var2 = this.a.getType(varx)) {
            ++var0;
            varx.c(this.b.locX(), var0, this.b.locZ());
        }
        --var0;
    } else if (this.b.onGround) {
        var0 = MathHelper.floor(this.b.locY() + 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<BlockPosition> 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<BlockPosition> var5 = var3.iterator();
        while (var5.hasNext()) {
            BlockPosition varb = var5.next();
            PathType var6 = this.a(this.b, varb);
            if (this.b.a(var6) >= 0.0F) {
                return this.a(varb.getX(), varb.getY(), varb.getZ());
            }
        }
    }
    return this.a(var1.getX(), var0, var1.getZ());
}
Also used : PathType(net.minecraft.server.v1_15_R1.PathType) IBlockData(net.minecraft.server.v1_15_R1.IBlockData) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_15_R1.BlockPosition.MutableBlockPosition) PooledBlockPosition(net.minecraft.server.v1_15_R1.BlockPosition.PooledBlockPosition) MutableBlockPosition(net.minecraft.server.v1_15_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_15_R1.PathPoint)

Example 3 with MutableBlockPosition

use of net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition 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 4 with MutableBlockPosition

use of net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition 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 5 with MutableBlockPosition

use of net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition 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)

Aggregations

HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 EnumSet (java.util.EnumSet)1 Set (java.util.Set)1 BoundingBox (net.citizensnpcs.api.util.BoundingBox)1 Block (net.minecraft.server.v1_10_R1.Block)1 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)1 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)1 PathType (net.minecraft.server.v1_10_R1.PathType)1 Block (net.minecraft.server.v1_11_R1.Block)1 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)1 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)1 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)1 PathType (net.minecraft.server.v1_11_R1.PathType)1 Block (net.minecraft.server.v1_12_R1.Block)1 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)1 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)1 PathPoint (net.minecraft.server.v1_12_R1.PathPoint)1 PathType (net.minecraft.server.v1_12_R1.PathType)1