Search in sources :

Example 1 with AbstractBlockMinecoloniesConstructionTape

use of com.minecolonies.api.blocks.decorative.AbstractBlockMinecoloniesConstructionTape in project minecolonies by Minecolonies.

the class AbstractPathJob method isPassable.

/**
 * Is the space passable.
 *
 * @param block the block we are checking.
 * @return true if the block does not block movement.
 */
protected boolean isPassable(@NotNull final BlockState block, final BlockPos pos, final Node parent) {
    if (block.getMaterial() != Material.AIR) {
        final VoxelShape shape = block.getCollisionShape(world, pos);
        if (block.getMaterial().blocksMotion() && !(shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1)) {
            if (block.getBlock() instanceof TrapDoorBlock) {
                final BlockPos parentPos = parent == null ? start : parent.pos;
                final BlockPos dir = pos.subtract(parentPos);
                if (dir.getY() != 0 && dir.getX() == 0 && dir.getZ() == 0) {
                    return true;
                }
                final Direction facing = block.getValue(TrapDoorBlock.FACING);
                if (dir.getX() != 0) {
                    return facing == Direction.NORTH || facing == Direction.SOUTH;
                }
                return facing == Direction.EAST || facing == Direction.WEST;
            } else {
                return pathingOptions.canEnterDoors() && (block.getBlock() instanceof DoorBlock || block.getBlock() instanceof FenceGateBlock) || block.getBlock() instanceof AbstractBlockMinecoloniesConstructionTape || block.getBlock() instanceof PressurePlateBlock || block.getBlock() instanceof BlockDecorationController || block.getBlock() instanceof AbstractSignBlock || block.getBlock() instanceof AbstractBannerBlock;
            }
        } else if (block.getBlock() instanceof FireBlock || block.getBlock() instanceof SweetBerryBushBlock) {
            return false;
        } else {
            if (isLadder(block.getBlock(), pos)) {
                return true;
            }
            if (shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1 && !isLiquid((block)) && (block.getBlock() != Blocks.SNOW || block.getValue(SnowBlock.LAYERS) == 1)) {
                final PathNodeType pathType = block.getAiPathNodeType(world, pos);
                if (pathType == null || pathType.getDanger() == null) {
                    return true;
                }
            }
            return false;
        }
    }
    return true;
}
Also used : BlockDecorationController(com.minecolonies.coremod.blocks.BlockDecorationController) PathNodeType(net.minecraft.pathfinding.PathNodeType) Direction(net.minecraft.util.Direction) AbstractBlockMinecoloniesConstructionTape(com.minecolonies.api.blocks.decorative.AbstractBlockMinecoloniesConstructionTape) VoxelShape(net.minecraft.util.math.shapes.VoxelShape) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with AbstractBlockMinecoloniesConstructionTape

use of com.minecolonies.api.blocks.decorative.AbstractBlockMinecoloniesConstructionTape in project minecolonies by ldtteam.

the class AbstractPathJob method isPassable.

/**
 * Is the space passable.
 *
 * @param block the block we are checking.
 * @return true if the block does not block movement.
 */
protected boolean isPassable(@NotNull final BlockState block, final BlockPos pos, final Node parent) {
    if (block.getMaterial() != Material.AIR) {
        final VoxelShape shape = block.getCollisionShape(world, pos);
        if (block.getMaterial().blocksMotion() && !(shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1)) {
            if (block.getBlock() instanceof TrapDoorBlock) {
                final BlockPos parentPos = parent == null ? start : parent.pos;
                final BlockPos dir = pos.subtract(parentPos);
                if (dir.getY() != 0 && dir.getX() == 0 && dir.getZ() == 0) {
                    return true;
                }
                final Direction facing = block.getValue(TrapDoorBlock.FACING);
                if (dir.getX() != 0) {
                    return facing == Direction.NORTH || facing == Direction.SOUTH;
                }
                return facing == Direction.EAST || facing == Direction.WEST;
            } else {
                return pathingOptions.canEnterDoors() && (block.getBlock() instanceof DoorBlock || block.getBlock() instanceof FenceGateBlock) || block.getBlock() instanceof AbstractBlockMinecoloniesConstructionTape || block.getBlock() instanceof PressurePlateBlock || block.getBlock() instanceof BlockDecorationController || block.getBlock() instanceof AbstractSignBlock || block.getBlock() instanceof AbstractBannerBlock;
            }
        } else if (block.getBlock() instanceof FireBlock || block.getBlock() instanceof SweetBerryBushBlock) {
            return false;
        } else {
            if (isLadder(block.getBlock(), pos)) {
                return true;
            }
            if (shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1 && !isLiquid((block)) && (block.getBlock() != Blocks.SNOW || block.getValue(SnowBlock.LAYERS) == 1)) {
                final PathNodeType pathType = block.getAiPathNodeType(world, pos);
                if (pathType == null || pathType.getDanger() == null) {
                    return true;
                }
            }
            return false;
        }
    }
    return true;
}
Also used : BlockDecorationController(com.minecolonies.coremod.blocks.BlockDecorationController) PathNodeType(net.minecraft.pathfinding.PathNodeType) Direction(net.minecraft.util.Direction) AbstractBlockMinecoloniesConstructionTape(com.minecolonies.api.blocks.decorative.AbstractBlockMinecoloniesConstructionTape) VoxelShape(net.minecraft.util.math.shapes.VoxelShape) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

AbstractBlockMinecoloniesConstructionTape (com.minecolonies.api.blocks.decorative.AbstractBlockMinecoloniesConstructionTape)2 BlockDecorationController (com.minecolonies.coremod.blocks.BlockDecorationController)2 PathNodeType (net.minecraft.pathfinding.PathNodeType)2 Direction (net.minecraft.util.Direction)2 BlockPos (net.minecraft.util.math.BlockPos)2 VoxelShape (net.minecraft.util.math.shapes.VoxelShape)2