Search in sources :

Example 6 with ResourceIdBlock

use of buildcraft.api.robots.ResourceIdBlock in project BuildCraft by BuildCraft.

the class AIRobotSearchBlock method takeResource.

public boolean takeResource() {
    boolean taken = false;
    if (robot.getRegistry().take(new ResourceIdBlock(blockFound), robot)) {
        taken = true;
    }
    unreserve();
    return taken;
}
Also used : ResourceIdBlock(buildcraft.api.robots.ResourceIdBlock)

Example 7 with ResourceIdBlock

use of buildcraft.api.robots.ResourceIdBlock in project BuildCraft by BuildCraft.

the class BoardRobotGenericSearchBlock method update.

@Override
public void update() {
    updateFilter();
    startDelegateAI(new AIRobotSearchAndGotoBlock(robot, false, new IBlockFilter() {

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

Example 8 with ResourceIdBlock

use of buildcraft.api.robots.ResourceIdBlock 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 9 with ResourceIdBlock

use of buildcraft.api.robots.ResourceIdBlock in project BuildCraft by BuildCraft.

the class BoardRobotPump method releaseBlockFound.

private void releaseBlockFound() {
    if (blockFound != null) {
        robot.getRegistry().release(new ResourceIdBlock(blockFound));
        blockFound = null;
    }
}
Also used : ResourceIdBlock(buildcraft.api.robots.ResourceIdBlock)

Example 10 with ResourceIdBlock

use of buildcraft.api.robots.ResourceIdBlock 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

ResourceIdBlock (buildcraft.api.robots.ResourceIdBlock)10 IBlockFilter (buildcraft.core.lib.utils.IBlockFilter)3 AIRobotSearchAndGotoBlock (buildcraft.robotics.ai.AIRobotSearchAndGotoBlock)3 BlockPos (net.minecraft.util.math.BlockPos)3 World (net.minecraft.world.World)3 IWorldProperty (buildcraft.api.core.IWorldProperty)1 AggregateFilter (buildcraft.lib.inventory.filter.AggregateFilter)1 AIRobotFetchAndEquipItemStack (buildcraft.robotics.ai.AIRobotFetchAndEquipItemStack)1 AIRobotGotoStationAndUnloadFluids (buildcraft.robotics.ai.AIRobotGotoStationAndUnloadFluids)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1