use of pneumaticCraft.common.progwidgets.ProgWidgetArea in project PneumaticCraft by MineMaarten.
the class ItemLogisticsDrone method addLogisticsProgram.
private void addLogisticsProgram(int x, int y, int z, List<IProgWidget> widgets) {
ProgWidgetStart start = new ProgWidgetStart();
start.setX(0);
start.setY(0);
widgets.add(start);
ProgWidgetLogistics logistics = new ProgWidgetLogistics();
logistics.setX(0);
logistics.setY(11);
widgets.add(logistics);
ProgWidgetArea area = new ProgWidgetArea();
area.setX(15);
area.setY(11);
area.x1 = x - 16;
area.y1 = y - 16;
area.z1 = z - 16;
area.x2 = x + 16;
area.y2 = y + 16;
area.z2 = z + 16;
widgets.add(area);
TileEntityProgrammer.updatePuzzleConnections(widgets);
}
use of pneumaticCraft.common.progwidgets.ProgWidgetArea in project PneumaticCraft by MineMaarten.
the class ProgWidgetCC method getArea.
private Set<ChunkPosition> getArea(int x1, int y1, int z1, int x2, int y2, int z2, String areaType) throws IllegalArgumentException {
ProgWidgetArea.EnumAreaType type = null;
for (ProgWidgetArea.EnumAreaType t : ProgWidgetArea.EnumAreaType.values()) {
if (t.toString().equals(areaType)) {
type = t;
break;
}
}
if (type == null)
throw new IllegalArgumentException("Invalid area type: " + areaType);
ProgWidgetArea helperWidget = new ProgWidgetArea();
helperWidget.x1 = x1;
helperWidget.y1 = y1;
helperWidget.z1 = z1;
helperWidget.x2 = x2;
helperWidget.y2 = y2;
helperWidget.z2 = z2;
helperWidget.type = type;
Set<ChunkPosition> a = new HashSet<ChunkPosition>();
helperWidget.getArea(a);
return a;
}
use of pneumaticCraft.common.progwidgets.ProgWidgetArea in project PneumaticCraft by MineMaarten.
the class ProgrammedDroneUtils method deliverItemsAmazonStyle.
public static EntityCreature deliverItemsAmazonStyle(World world, int x, int y, int z, ItemStack... deliveredStacks) {
if (world.isRemote)
return null;
if (deliveredStacks.length == 0)
throw new IllegalArgumentException("You need to deliver at least 1 stack!");
if (deliveredStacks.length > 65)
throw new IllegalArgumentException("You can only deliver up to 65 stacks at once!");
for (ItemStack stack : deliveredStacks) {
if (stack == null)
throw new IllegalArgumentException("You can't supply a null stack to be delivered!");
if (stack.getItem() == null)
throw new IllegalArgumentException("You can't supply a stack with a null item to be delivered!");
}
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);
ProgWidgetInventoryExport export = new ProgWidgetInventoryExport();
export.setX(92);
export.setY(52);
widgets.add(export);
ProgWidgetDropItem drop = new ProgWidgetDropItem();
drop.setX(92);
drop.setY(74);
widgets.add(drop);
ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
gotoPiece.setX(92);
gotoPiece.setY(96);
widgets.add(gotoPiece);
ProgWidgetSuicide suicide = new ProgWidgetSuicide();
suicide.setX(92);
suicide.setY(107);
widgets.add(suicide);
ProgWidgetArea area = new ProgWidgetArea();
area.setX(107);
area.setY(52);
area.x1 = x;
area.y1 = y;
area.z1 = z;
widgets.add(area);
area = new ProgWidgetArea();
area.setX(107);
area.setY(74);
area.x1 = x;
area.z1 = z;
if (drone.isBlockValidPathfindBlock(x, y, z)) {
for (int i = 0; i < 5 && drone.isBlockValidPathfindBlock(area.x1, i + y + 1, area.z1); i++) {
area.y1 = y + i;
}
} else {
area.y1 = world.getHeightValue(x, z) + 10;
//Worst case scenario, there are definately no blocks here.
if (!drone.isBlockValidPathfindBlock(area.x1, area.y1, area.z1))
area.y1 = 260;
}
widgets.add(area);
area = new ProgWidgetArea();
area.setX(107);
area.setY(96);
area.x1 = x + 30;
area.y1 = startY;
area.z1 = z;
widgets.add(area);
TileEntityProgrammer.updatePuzzleConnections(widgets);
for (int i = 0; i < deliveredStacks.length; i++) {
drone.getInventory().setInventorySlotContents(i, deliveredStacks[i].copy());
}
world.spawnEntityInWorld(drone);
return drone;
}
Aggregations