Search in sources :

Example 1 with ProgWidgetStart

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);
}
Also used : ProgWidgetArea(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetArea) ProgWidgetLogistics(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetLogistics) ProgWidgetStart(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)

Example 2 with ProgWidgetStart

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));
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) PacketGuiButton(me.desht.pneumaticcraft.common.network.PacketGuiButton) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketProgrammerUpdate(me.desht.pneumaticcraft.common.network.PacketProgrammerUpdate) ProgWidgetStart(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)

Example 3 with ProgWidgetStart

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;
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) EntityAIBase(net.minecraft.entity.ai.EntityAIBase) ProgWidgetStart(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)

Example 4 with ProgWidgetStart

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);
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) ProgWidgetCoordinateOperator(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetCoordinateOperator) ArrayList(java.util.ArrayList) ProgWidgetStart(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)

Example 5 with ProgWidgetStart

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;
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) GuiScreen(net.minecraft.client.gui.GuiScreen) IGuiScreen(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IGuiScreen) ItemStack(net.minecraft.item.ItemStack) ProgWidgetStart(me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)

Aggregations

ProgWidgetStart (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)5 IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)4 ArrayList (java.util.ArrayList)1 IGuiScreen (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IGuiScreen)1 EntityDrone (me.desht.pneumaticcraft.common.entity.living.EntityDrone)1 PacketGuiButton (me.desht.pneumaticcraft.common.network.PacketGuiButton)1 PacketProgrammerUpdate (me.desht.pneumaticcraft.common.network.PacketProgrammerUpdate)1 ProgWidgetArea (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetArea)1 ProgWidgetCoordinateOperator (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetCoordinateOperator)1 ProgWidgetLogistics (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetLogistics)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 Entity (net.minecraft.entity.Entity)1 EntityAIBase (net.minecraft.entity.ai.EntityAIBase)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1