Search in sources :

Example 1 with ProgWidgetInventoryImport

use of pneumaticCraft.common.progwidgets.ProgWidgetInventoryImport in project PneumaticCraft by MineMaarten.

the class ProgrammedDroneUtils method retrieveItemsAmazonStyle.

public static EntityCreature retrieveItemsAmazonStyle(World world, int x, int y, int z, ItemStack... queriedStacks) {
    if (world.isRemote)
        return null;
    if (queriedStacks.length == 0)
        throw new IllegalArgumentException("You need to query at least 1 stack!");
    if (queriedStacks.length > 65)
        throw new IllegalArgumentException("You can only query up to 65 stacks at once!");
    for (ItemStack stack : queriedStacks) {
        if (stack == null)
            throw new IllegalArgumentException("You can't query a null stack!");
        if (stack.getItem() == null)
            throw new IllegalArgumentException("You can't query a stack with a null item!");
    }
    EntityDrone drone = getChargedDispenserUpgradeDrone(world);
    //Program the drone
    int startY = world.getHeightValue(x + 30, z) + 30;
    drone.setPosition(x + 30, startY, z);
    List<IProgWidget> widgets = drone.progWidgets;
    ProgWidgetStart start = new ProgWidgetStart();
    start.setX(92);
    start.setY(41);
    widgets.add(start);
    int yBase = 52;
    for (ItemStack stack : queriedStacks) {
        ProgWidgetInventoryImport im = new ProgWidgetInventoryImport();
        im.setX(92);
        im.setY(yBase);
        im.setCount(stack.stackSize);
        im.setUseCount(true);
        widgets.add(im);
        ProgWidgetArea area = new ProgWidgetArea();
        area.setX(107);
        area.setY(yBase);
        area.x1 = x;
        area.y1 = y;
        area.z1 = z;
        widgets.add(area);
        ProgWidgetItemFilter filter = new ProgWidgetItemFilter();
        filter.setX(107);
        filter.setY(yBase + 11);
        filter.setFilter(stack);
        filter.useMetadata = true;
        filter.useNBT = true;
        widgets.add(filter);
        yBase += 22;
    }
    ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
    gotoPiece.setX(92);
    gotoPiece.setY(yBase);
    widgets.add(gotoPiece);
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = x + 30;
    area.y1 = startY;
    area.z1 = z;
    widgets.add(area);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(yBase + 11);
    widgets.add(suicide);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    world.spawnEntityInWorld(drone);
    return drone;
}
Also used : ProgWidgetInventoryImport(pneumaticCraft.common.progwidgets.ProgWidgetInventoryImport) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ProgWidgetItemFilter(pneumaticCraft.common.progwidgets.ProgWidgetItemFilter) ProgWidgetGoToLocation(pneumaticCraft.common.progwidgets.ProgWidgetGoToLocation) ProgWidgetArea(pneumaticCraft.common.progwidgets.ProgWidgetArea) ProgWidgetSuicide(pneumaticCraft.common.progwidgets.ProgWidgetSuicide) ItemStack(net.minecraft.item.ItemStack) ProgWidgetStart(pneumaticCraft.common.progwidgets.ProgWidgetStart)

Aggregations

ItemStack (net.minecraft.item.ItemStack)1 EntityDrone (pneumaticCraft.common.entity.living.EntityDrone)1 IProgWidget (pneumaticCraft.common.progwidgets.IProgWidget)1 ProgWidgetArea (pneumaticCraft.common.progwidgets.ProgWidgetArea)1 ProgWidgetGoToLocation (pneumaticCraft.common.progwidgets.ProgWidgetGoToLocation)1 ProgWidgetInventoryImport (pneumaticCraft.common.progwidgets.ProgWidgetInventoryImport)1 ProgWidgetItemFilter (pneumaticCraft.common.progwidgets.ProgWidgetItemFilter)1 ProgWidgetStart (pneumaticCraft.common.progwidgets.ProgWidgetStart)1 ProgWidgetSuicide (pneumaticCraft.common.progwidgets.ProgWidgetSuicide)1