use of pneumaticCraft.common.progwidgets.ProgWidgetItemFilter in project PneumaticCraft by MineMaarten.
the class ProgWidgetCC method getItemFilter.
private ProgWidgetItemFilter getItemFilter(String itemName, int damage, boolean useMetadata, boolean useNBT, boolean useOreDict, boolean useModSimilarity) throws IllegalArgumentException {
if (!itemName.contains(":"))
throw new IllegalArgumentException("Item/Block name doesn't contain a ':'!");
String[] itemParts = itemName.split(":");
Item item = GameRegistry.findItem(itemParts[0], itemParts[1]);
if (item == null)
throw new IllegalArgumentException("Item not found for the name \"" + itemName + "\"!");
ProgWidgetItemFilter itemFilter = new ProgWidgetItemFilter();
itemFilter.setFilter(new ItemStack(item, 1, damage));
itemFilter.specificMeta = damage;
itemFilter.useMetadata = useMetadata;
itemFilter.useNBT = useNBT;
itemFilter.useOreDict = useOreDict;
itemFilter.useModSimilarity = useModSimilarity;
return itemFilter;
}
use of pneumaticCraft.common.progwidgets.ProgWidgetItemFilter 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;
}
Aggregations