use of me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart in project pnc-repressurized by TeamPneumatic.
the class ItemLogisticsDrone method addLogisticsProgram.
private void addLogisticsProgram(BlockPos pos, 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 = pos.getX() - 16;
area.y1 = pos.getY() - 16;
area.z1 = pos.getZ() - 16;
area.x2 = pos.getX() + 16;
area.y2 = pos.getY() + 16;
area.z2 = pos.getZ() + 16;
widgets.add(area);
TileEntityProgrammer.updatePuzzleConnections(widgets);
}
use of me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method actionPerformed.
/**
* Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
*/
@Override
protected void actionPerformed(GuiButton button) {
switch(button.id) {
case // redstone button
0:
// redstoneBehaviourStat.closeWindow();
break;
case 3:
if (--widgetPage < 0)
widgetPage = maxPage;
updateVisibleProgWidgets();
return;
case 4:
if (++widgetPage > maxPage)
widgetPage = 0;
updateVisibleProgWidgets();
return;
case 5:
for (IProgWidget widget : te.progWidgets) {
if (widget instanceof ProgWidgetStart) {
programmerUnit.gotoPiece(widget);
break;
}
}
return;
case 6:
if (te.progWidgets.size() > 0) {
programmerUnit.gotoPiece(te.progWidgets.get(te.progWidgets.size() - 1));
}
return;
case 7:
NBTTagCompound mainTag = new NBTTagCompound();
te.writeProgWidgetsToNBT(mainTag);
FMLClientHandler.instance().showGuiScreen(pastebinGui = new GuiPastebin(this, mainTag));
break;
case 11:
te.progWidgets.clear();
NetworkHandler.sendToServer(new PacketProgrammerUpdate(te));
break;
case 12:
for (IProgWidget widget : te.progWidgets) {
if (widget instanceof ProgWidgetStart) {
generateRelativeOperators((ProgWidgetCoordinateOperator) widget.getOutputWidget(), null, false);
break;
}
}
break;
}
NetworkHandler.sendToServer(new PacketGuiButton(button.id));
}
use of me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart in project pnc-repressurized by TeamPneumatic.
the class DroneAIManager method setActiveWidget.
private void setActiveWidget(IProgWidget widget) {
EntityAIBase targetAI = null;
EntityAIBase ai = null;
if (widget != null) {
boolean first = widget instanceof ProgWidgetStart;
targetAI = widget.getWidgetTargetAI(drone, widget);
ai = widget.getWidgetAI(drone, widget);
// Prevent endless loops
Set<IProgWidget> visitedWidgets = new HashSet<IProgWidget>();
while (!visitedWidgets.contains(widget) && targetAI == null && ai == null) {
visitedWidgets.add(widget);
IProgWidget oldWidget = widget;
widget = widget.getOutputWidget(drone, progWidgets);
if (widget == null) {
if (first) {
return;
} else {
if (stopWhenEndReached) {
setActiveWidget(null);
} else {
gotoFirstWidget();
}
return;
}
} else if (oldWidget.getOutputWidget() != widget) {
if (addJumpBackWidget(oldWidget))
return;
}
targetAI = widget.getWidgetTargetAI(drone, widget);
ai = widget.getWidgetAI(drone, widget);
}
drone.setActiveProgram(widget);
} else {
setLabel("Stopped");
}
curActiveWidget = widget;
if (curWidgetAI != null)
removeTask(curWidgetAI);
if (curWidgetTargetAI != null)
drone.getTargetAI().removeTask(curWidgetTargetAI);
if (ai != null)
addTask(2, ai);
if (targetAI != null)
drone.getTargetAI().addTask(2, targetAI);
curWidgetAI = ai;
curWidgetTargetAI = targetAI;
}
use of me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart in project pnc-repressurized by TeamPneumatic.
the class GuiProgrammer method updateConvertRelativeState.
private void updateConvertRelativeState() {
convertToRelativeButton.enabled = false;
List<String> tooltip = new ArrayList<>();
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<>();
for (String s : tooltip) {
localizedTooltip.addAll(PneumaticCraftUtils.convertStringIntoList(I18n.format(s), 40));
}
convertToRelativeButton.setTooltipText(localizedTooltip);
}
use of me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart in project pnc-repressurized by TeamPneumatic.
the class GuiDroneDebuggerOptions method initGui.
@Override
public void initGui(IGuiScreen gui) {
GuiScreen guiScreen = (GuiScreen) gui;
screenWidth = guiScreen.width;
screenHeight = guiScreen.height;
if (PneumaticCraftRepressurized.proxy.getPlayer() != null) {
ItemStack helmet = PneumaticCraftRepressurized.proxy.getPlayer().getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (helmet != null) {
int entityId = NBTUtil.getInteger(helmet, NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE);
Entity entity = PneumaticCraftRepressurized.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