Search in sources :

Example 1 with PathNodeType

use of net.minecraft.pathfinding.PathNodeType in project MorePlanets by SteveKunG.

the class WalkNodeProcessorMP method getStart.

@Override
public PathPoint getStart() {
    int i;
    if (this.getCanSwim() && this.entity.isInWater()) {
        i = (int) this.entity.getEntityBoundingBox().minY;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER || block instanceof BlockFluidBase; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock()) {
            ++i;
            blockpos$mutableblockpos.setPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        }
    } else if (this.entity.onGround) {
        i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5D);
    } else {
        BlockPos blockpos;
        for (blockpos = new BlockPos(this.entity); (this.blockaccess.getBlockState(blockpos).getMaterial() == Material.AIR || this.blockaccess.getBlockState(blockpos).getBlock().isPassable(this.blockaccess, blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down()) {
        }
        i = blockpos.up().getY();
    }
    BlockPos blockpos2 = new BlockPos(this.entity);
    PathNodeType pathnodetype1 = this.getPathNodeType(this.entity, blockpos2.getX(), i, blockpos2.getZ());
    if (this.entity.getPathPriority(pathnodetype1) < 0.0F) {
        Set<BlockPos> set = new HashSet<>();
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, i, this.entity.getEntityBoundingBox().maxZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, i, this.entity.getEntityBoundingBox().maxZ));
        for (BlockPos blockpos1 : set) {
            PathNodeType pathnodetype = this.getPathNodeType(this.entity, blockpos1);
            if (this.entity.getPathPriority(pathnodetype) >= 0.0F) {
                return this.openPoint(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
            }
        }
    }
    return this.openPoint(blockpos2.getX(), i, blockpos2.getZ());
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) PathNodeType(net.minecraft.pathfinding.PathNodeType) PathPoint(net.minecraft.pathfinding.PathPoint) HashSet(java.util.HashSet)

Example 2 with PathNodeType

use of net.minecraft.pathfinding.PathNodeType in project MorePlanets by SteveKunG.

the class PathNavigateGroundMP method isSafeToStandAt.

private boolean isSafeToStandAt(int x, int y, int z, int sizeX, int sizeY, int sizeZ, Vec3d vec31, double xx, double zz) {
    int i = x - sizeX / 2;
    int j = z - sizeZ / 2;
    if (!this.isPositionClear(i, y, j, sizeX, sizeY, sizeZ, vec31, xx, zz)) {
        return false;
    } else {
        for (int k = i; k < i + sizeX; ++k) {
            for (int l = j; l < j + sizeZ; ++l) {
                double d0 = k + 0.5D - vec31.x;
                double d1 = l + 0.5D - vec31.z;
                if (d0 * xx + d1 * zz >= 0.0D) {
                    PathNodeType pathnodetype = this.nodeProcessor.getPathNodeType(this.world, k, y - 1, l, this.entity, sizeX, sizeY, sizeZ, true, true);
                    if (pathnodetype == PathNodeType.WATER) {
                        return false;
                    }
                    if (pathnodetype == PathNodeType.LAVA) {
                        return false;
                    }
                    if (pathnodetype == PathNodeType.OPEN) {
                        return false;
                    }
                    pathnodetype = this.nodeProcessor.getPathNodeType(this.world, k, y, l, this.entity, sizeX, sizeY, sizeZ, true, true);
                    float f = this.entity.getPathPriority(pathnodetype);
                    if (f < 0.0F || f >= 8.0F) {
                        return false;
                    }
                    if (pathnodetype == PathNodeType.DAMAGE_FIRE || pathnodetype == PathNodeType.DANGER_FIRE || pathnodetype == PathNodeType.DAMAGE_OTHER) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
Also used : PathNodeType(net.minecraft.pathfinding.PathNodeType)

Example 3 with PathNodeType

use of net.minecraft.pathfinding.PathNodeType in project MorePlanets by SteveKunG.

the class WalkNodeProcessorMP method getStart.

@Override
public PathPoint getStart() {
    int i;
    if (this.getCanSwim() && this.entity.isInWater()) {
        i = (int) this.entity.getEntityBoundingBox().minY;
        BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        for (Block block = this.blockaccess.getBlockState(mutablePos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER || block instanceof BlockFluidBase; block = this.blockaccess.getBlockState(mutablePos).getBlock()) {
            ++i;
            mutablePos.setPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        }
    } else if (this.entity.onGround) {
        i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5D);
    } else {
        BlockPos pos;
        for (pos = new BlockPos(this.entity); (this.blockaccess.getBlockState(pos).getMaterial() == Material.AIR || this.blockaccess.getBlockState(pos).getBlock().isPassable(this.blockaccess, pos)) && pos.getY() > 0; pos = pos.down()) {
        }
        i = pos.up().getY();
    }
    BlockPos blockpos2 = new BlockPos(this.entity);
    PathNodeType pathnodetype1 = this.getPathNodeType(this.entity, blockpos2.getX(), i, blockpos2.getZ());
    if (this.entity.getPathPriority(pathnodetype1) < 0.0F) {
        Set<BlockPos> set = new HashSet<>();
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, i, this.entity.getEntityBoundingBox().maxZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, i, this.entity.getEntityBoundingBox().maxZ));
        for (BlockPos blockpos1 : set) {
            PathNodeType type = this.getPathNodeType(this.entity, blockpos1);
            if (this.entity.getPathPriority(type) >= 0.0F) {
                return this.openPoint(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
            }
        }
    }
    return this.openPoint(blockpos2.getX(), i, blockpos2.getZ());
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) PathNodeType(net.minecraft.pathfinding.PathNodeType) PathPoint(net.minecraft.pathfinding.PathPoint) HashSet(java.util.HashSet)

Aggregations

PathNodeType (net.minecraft.pathfinding.PathNodeType)3 HashSet (java.util.HashSet)2 Block (net.minecraft.block.Block)2 PathPoint (net.minecraft.pathfinding.PathPoint)2 BlockPos (net.minecraft.util.math.BlockPos)2 BlockFluidBase (net.minecraftforge.fluids.BlockFluidBase)2