use of pneumaticCraft.common.progwidgets.ProgWidgetStart in project PneumaticCraft by MineMaarten.
the class GuiProgrammer method updateConvertRelativeState.
private void updateConvertRelativeState() {
convertToRelativeButton.enabled = false;
List<String> tooltip = new ArrayList<String>();
tooltip.add("gui.programmer.button.convertToRelative.desc");
boolean startFound = false;
for (IProgWidget startWidget : te.progWidgets) {
if (startWidget instanceof ProgWidgetStart) {
startFound = true;
IProgWidget widget = startWidget.getOutputWidget();
if (widget instanceof ProgWidgetCoordinateOperator) {
ProgWidgetCoordinateOperator operatorWidget = (ProgWidgetCoordinateOperator) widget;
if (!operatorWidget.getVariable().equals("")) {
try {
if (generateRelativeOperators(operatorWidget, tooltip, true)) {
convertToRelativeButton.enabled = true;
} else {
tooltip.add("gui.programmer.button.convertToRelative.notEnoughRoom");
}
} catch (NullPointerException e) {
tooltip.add("gui.programmer.button.convertToRelative.cantHaveVariables");
}
} else {
tooltip.add("gui.programmer.button.convertToRelative.noVariableName");
}
} else {
tooltip.add("gui.programmer.button.convertToRelative.noBaseCoordinate");
}
}
}
if (!startFound)
tooltip.add("gui.programmer.button.convertToRelative.noStartPiece");
List<String> localizedTooltip = new ArrayList<String>();
for (String s : tooltip) {
localizedTooltip.addAll(PneumaticCraftUtils.convertStringIntoList(I18n.format(s), 40));
}
convertToRelativeButton.setTooltipText(localizedTooltip);
}
use of pneumaticCraft.common.progwidgets.ProgWidgetStart in project PneumaticCraft by MineMaarten.
the class ProgrammedDroneUtils method deliverFluidAmazonStyle.
public static EntityCreature deliverFluidAmazonStyle(World world, int x, int y, int z, FluidStack deliveredFluid) {
if (world.isRemote)
return null;
if (deliveredFluid == null)
throw new IllegalArgumentException("Can't deliver a null FluidStack");
if (deliveredFluid.amount <= 0)
throw new IllegalArgumentException("Can't deliver a FluidStack with an amount of <= 0");
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);
ProgWidgetLiquidExport export = new ProgWidgetLiquidExport();
export.setX(92);
export.setY(52);
widgets.add(export);
ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
gotoPiece.setX(92);
gotoPiece.setY(74);
widgets.add(gotoPiece);
ProgWidgetSuicide suicide = new ProgWidgetSuicide();
suicide.setX(92);
suicide.setY(85);
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 + 30;
area.y1 = startY;
area.z1 = z;
widgets.add(area);
TileEntityProgrammer.updatePuzzleConnections(widgets);
drone.getTank().fill(deliveredFluid, true);
world.spawnEntityInWorld(drone);
return drone;
}
use of pneumaticCraft.common.progwidgets.ProgWidgetStart 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;
}
use of pneumaticCraft.common.progwidgets.ProgWidgetStart in project PneumaticCraft by MineMaarten.
the class ProgrammedDroneUtils method retrieveFluidAmazonStyle.
public static EntityCreature retrieveFluidAmazonStyle(World world, int x, int y, int z, FluidStack queriedFluid) {
if (world.isRemote)
return null;
if (queriedFluid == null)
throw new IllegalArgumentException("Can't query a null FluidStack");
if (queriedFluid.amount <= 0)
throw new IllegalArgumentException("Can't query a FluidStack with an amount of <= 0");
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;
ProgWidgetLiquidImport im = new ProgWidgetLiquidImport();
im.setX(92);
im.setY(yBase);
im.setCount(queriedFluid.amount);
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);
ProgWidgetLiquidFilter filter = new ProgWidgetLiquidFilter();
filter.setX(107);
filter.setY(yBase + 11);
filter.setFluid(queriedFluid.getFluid());
widgets.add(filter);
yBase += 22;
ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
gotoPiece.setX(92);
gotoPiece.setY(yBase);
widgets.add(gotoPiece);
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;
}
use of pneumaticCraft.common.progwidgets.ProgWidgetStart in project PneumaticCraft by MineMaarten.
the class GuiDroneDebuggerOptions method initGui.
@Override
public void initGui(IGuiScreen gui) {
GuiScreen guiScreen = (GuiScreen) gui;
screenWidth = guiScreen.width;
screenHeight = guiScreen.height;
if (PneumaticCraft.proxy.getPlayer() != null) {
ItemStack helmet = PneumaticCraft.proxy.getPlayer().getCurrentArmor(3);
if (helmet != null) {
int entityId = NBTUtil.getInteger(helmet, NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE);
Entity entity = PneumaticCraft.proxy.getClientWorld().getEntityByID(entityId);
if (entity instanceof EntityDrone) {
selectedDrone = (EntityDrone) entity;
}
}
}
int spacing = 20;
programmingStartX = spacing;
programmingWidth = guiScreen.width - spacing * 2;
programmingHeight = guiScreen.height - spacing - PROGRAMMING_START_Y;
programmerUnit = new DebugInfoProgrammerUnit(selectedDrone != null ? selectedDrone.getProgWidgets() : new ArrayList<IProgWidget>(), gui.getFontRenderer(), 0, 0, guiScreen.width, guiScreen.height, 100, programmingStartX, PROGRAMMING_START_Y, programmingWidth, programmingHeight, 0, 0, 0);
if (selectedDrone != null) {
for (IProgWidget widget : selectedDrone.getProgWidgets()) {
if (widget instanceof ProgWidgetStart) {
programmerUnit.gotoPiece(widget);
break;
}
}
}
}
Aggregations