Search in sources :

Example 66 with BlockPosition

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

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

the class PlayerPathfinderNormal method b.

protected PathType b(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
    BlockPosition localBlockPosition = new BlockPosition(paramInt1, paramInt2, paramInt3);
    IBlockData localIBlockData = paramIBlockAccess.getType(localBlockPosition);
    Block localBlock = localIBlockData.getBlock();
    Material localMaterial = localIBlockData.getMaterial();
    if (localMaterial == Material.AIR) {
        return PathType.OPEN;
    }
    if ((localBlock == Blocks.TRAPDOOR) || (localBlock == Blocks.IRON_TRAPDOOR) || (localBlock == Blocks.WATERLILY)) {
        return PathType.TRAPDOOR;
    }
    if (localBlock == Blocks.FIRE) {
        return PathType.DAMAGE_FIRE;
    }
    if (localBlock == Blocks.CACTUS) {
        return PathType.DAMAGE_CACTUS;
    }
    if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.WOOD) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
        return PathType.DOOR_WOOD_CLOSED;
    }
    if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.ORE) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
        return PathType.DOOR_IRON_CLOSED;
    }
    if (((localBlock instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
        return PathType.DOOR_OPEN;
    }
    if ((localBlock instanceof BlockMinecartTrackAbstract)) {
        return PathType.RAIL;
    }
    if (((localBlock instanceof BlockFence)) || ((localBlock instanceof BlockCobbleWall)) || (((localBlock instanceof BlockFenceGate)) && (!localIBlockData.get(BlockFenceGate.OPEN).booleanValue()))) {
        return PathType.FENCE;
    }
    if (localMaterial == Material.WATER) {
        return PathType.WATER;
    }
    if (localMaterial == Material.LAVA) {
        return PathType.LAVA;
    }
    if (localBlock.b(paramIBlockAccess, localBlockPosition)) {
        return PathType.OPEN;
    }
    return PathType.BLOCKED;
}
Also used : BlockDoor(net.minecraft.server.v1_12_R1.BlockDoor) IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockFenceGate(net.minecraft.server.v1_12_R1.BlockFenceGate) BlockCobbleWall(net.minecraft.server.v1_12_R1.BlockCobbleWall) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Block(net.minecraft.server.v1_12_R1.Block) Material(net.minecraft.server.v1_12_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_12_R1.BlockMinecartTrackAbstract) BlockFence(net.minecraft.server.v1_12_R1.BlockFence)

Example 68 with BlockPosition

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

the class PlayerPathfinderNormal method a.

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 localPathType1 = PathType.BLOCKED;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    localPathType1 = a(paramIBlockAccess, paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramBoolean1, paramBoolean2, localEnumSet, localPathType1, localBlockPosition);
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject = PathType.BLOCKED;
    for (PathType localPathType2 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType2) < 0.0F) {
            return localPathType2;
        }
        if (paramEntityInsentient.a(localPathType2) >= paramEntityInsentient.a((PathType) localObject)) {
            localObject = localPathType2;
        }
    }
    if ((localPathType1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject;
}
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)

Example 69 with BlockPosition

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

the class PlayerNavigation method b2.

private PathEntity b2(BlockPosition paramBlockPosition) {
    if (!b()) {
        return null;
    }
    if ((this.c != null) && (!this.c.b()) && (paramBlockPosition.equals(this.q))) {
        return this.c;
    }
    this.q = paramBlockPosition;
    float f1 = i();
    this.b.methodProfiler.a("pathfind");
    BlockPosition localBlockPosition = new BlockPosition(this.a);
    int i1 = (int) (f1 + 8.0F);
    ChunkCache localChunkCache = new ChunkCache(this.b, localBlockPosition.a(-i1, -i1, -i1), localBlockPosition.a(i1, i1, i1), 0);
    PathEntity localPathEntity = this.r.a(localChunkCache, this.a, this.q, f1);
    this.b.methodProfiler.b();
    return localPathEntity;
}
Also used : ChunkCache(net.minecraft.server.v1_12_R1.ChunkCache) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 70 with BlockPosition

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

the class NMSImpl method getTargetNavigator.

@Override
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest, final NavigatorParameters params) {
    List<PathPoint> list = Lists.<PathPoint>newArrayList(Iterables.<Vector, PathPoint>transform(dest, new Function<Vector, PathPoint>() {

        @Override
        public PathPoint apply(Vector input) {
            return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
        }
    }));
    PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
    final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null, true);
    return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {

        @Override
        public Boolean apply(NavigationAbstract input) {
            return input.a(path, params.speed());
        }
    });
}
Also used : PathPoint(net.minecraft.server.v1_16_R3.PathPoint) Function(com.google.common.base.Function) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) NavigationAbstract(net.minecraft.server.v1_16_R3.NavigationAbstract) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Vector(org.bukkit.util.Vector)

Aggregations

BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)57 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)36 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)34 Location (org.bukkit.Location)32 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)30 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)30 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)27 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)26 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)24 Chunk (org.bukkit.Chunk)24 ArrayList (java.util.ArrayList)22 List (java.util.List)19 Map (java.util.Map)17 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)17 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)16 Iterator (java.util.Iterator)14 Block (org.bukkit.block.Block)14 HashMap (java.util.HashMap)12 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)10 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)9