Search in sources :

Example 6 with AIRobotSearchAndGotoBlock

use of buildcraft.robotics.ai.AIRobotSearchAndGotoBlock in project BuildCraft by BuildCraft.

the class BoardRobotPlanter method update.

@Override
public void update() {
    if (robot.getHeldItem() == null) {
        startDelegateAI(new AIRobotFetchAndEquipItemStack(robot, new AggregateFilter(filter, ActionRobotFilter.getGateFilter(robot.getLinkedStation()))));
    } else {
        final ItemStack itemStack = robot.getHeldItem();
        IBlockFilter blockFilter = new IBlockFilter() {

            @Override
            public boolean matches(World world, BlockPos pos) {
                return !BuildCraftAPI.getWorldProperty("replaceable").get(world, pos) && isPlantable(itemStack, world, pos) && !robot.getRegistry().isTaken(new ResourceIdBlock(pos));
            }
        };
        startDelegateAI(new AIRobotSearchAndGotoBlock(robot, true, blockFilter, 1));
    }
}
Also used : AIRobotSearchAndGotoBlock(buildcraft.robotics.ai.AIRobotSearchAndGotoBlock) AggregateFilter(buildcraft.lib.inventory.filter.AggregateFilter) ResourceIdBlock(buildcraft.api.robots.ResourceIdBlock) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) AIRobotFetchAndEquipItemStack(buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack) World(net.minecraft.world.World) IBlockFilter(buildcraft.core.lib.utils.IBlockFilter) AIRobotFetchAndEquipItemStack(buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack)

Example 7 with AIRobotSearchAndGotoBlock

use of buildcraft.robotics.ai.AIRobotSearchAndGotoBlock in project BuildCraft by BuildCraft.

the class BoardRobotPump method update.

@Override
public void update() {
    final IWorldProperty isFluidSource = BuildCraftAPI.getWorldProperty("fluidSource");
    FluidStack tank = robot.getTankInfo(null)[0].fluid;
    if (tank != null && tank.amount > 0) {
        startDelegateAI(new AIRobotGotoStationAndUnloadFluids(robot));
    } else {
        updateFilter();
        startDelegateAI(new AIRobotSearchAndGotoBlock(robot, false, new IBlockFilter() {

            @Override
            public boolean matches(World world, BlockPos pos) {
                if (isFluidSource.get(world, pos) && !robot.getRegistry().isTaken(new ResourceIdBlock(pos))) {
                    return matchesGateFilter(world, pos);
                } else {
                    return false;
                }
            }
        }));
    }
}
Also used : AIRobotSearchAndGotoBlock(buildcraft.robotics.ai.AIRobotSearchAndGotoBlock) FluidStack(net.minecraftforge.fluids.FluidStack) ResourceIdBlock(buildcraft.api.robots.ResourceIdBlock) AIRobotGotoStationAndUnloadFluids(buildcraft.robotics.ai.AIRobotGotoStationAndUnloadFluids) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) IWorldProperty(buildcraft.api.core.IWorldProperty) IBlockFilter(buildcraft.core.lib.utils.IBlockFilter)

Aggregations

AIRobotSearchAndGotoBlock (buildcraft.robotics.ai.AIRobotSearchAndGotoBlock)7 AIRobotFetchAndEquipItemStack (buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack)4 AIRobotGotoSleep (buildcraft.robotics.ai.AIRobotGotoSleep)4 ResourceIdBlock (buildcraft.api.robots.ResourceIdBlock)3 IBlockFilter (buildcraft.core.lib.utils.IBlockFilter)3 BlockPos (net.minecraft.util.math.BlockPos)3 World (net.minecraft.world.World)3 AIRobotGotoStationAndUnloadFluids (buildcraft.robotics.ai.AIRobotGotoStationAndUnloadFluids)2 IWorldProperty (buildcraft.api.core.IWorldProperty)1 AggregateFilter (buildcraft.lib.inventory.filter.AggregateFilter)1 AIRobotPlant (buildcraft.robotics.ai.AIRobotPlant)1 AIRobotPumpBlock (buildcraft.robotics.ai.AIRobotPumpBlock)1 AIRobotStripesHandler (buildcraft.robotics.ai.AIRobotStripesHandler)1 AIRobotUseToolOnBlock (buildcraft.robotics.ai.AIRobotUseToolOnBlock)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1