Search in sources :

Example 91 with Argument

use of mcjty.lib.network.Argument in project RFToolsControl by McJty.

the class GuiProcessor method executeCommand.

private void executeCommand(String text) {
    dumpHistory();
    sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_EXECUTE, new Argument("cmd", text));
    if (commandHistoryIndex >= 0 && commandHistoryIndex < commandHistory.size() && text.equals(commandHistory.get(commandHistoryIndex))) {
    // History command that didn't change
    } else if (!text.isEmpty()) {
        if (commandHistory.isEmpty() || !text.equals(commandHistory.get(commandHistory.size() - 1))) {
            commandHistory.add(text);
        }
        while (commandHistory.size() > 50) {
            commandHistory.remove(0);
        }
        commandHistoryIndex = -1;
    }
    command.setText("");
    window.setTextFocus(command);
}
Also used : Argument(mcjty.lib.network.Argument)

Example 92 with Argument

use of mcjty.lib.network.Argument in project RFToolsControl by McJty.

the class GuiProcessor method mouseClicked.

@Override
protected void mouseClicked(int x, int y, int button) throws IOException {
    int setupMode = getSetupMode();
    if (setupMode == -1) {
        super.mouseClicked(x, y, button);
    } else {
        Optional<Widget> widget = getWindowManager().findWidgetAtPosition(x, y);
        if (widget.isPresent()) {
            Widget<?> w = widget.get();
            if ("allowed".equals(w.getUserObject())) {
                super.mouseClicked(x, y, button);
                return;
            }
        }
        int leftx = window.getToplevel().getBounds().x;
        int topy = window.getToplevel().getBounds().y;
        x -= leftx;
        y -= topy;
        CardInfo cardInfo = tileEntity.getCardInfo(setupMode);
        int itemAlloc = cardInfo.getItemAllocation();
        int varAlloc = cardInfo.getVarAllocation();
        int fluidAlloc = cardInfo.getFluidAllocation();
        for (int i = 0; i < ProcessorTileEntity.ITEM_SLOTS; i++) {
            Slot slot = inventorySlots.getSlot(ProcessorContainer.SLOT_BUFFER + i);
            if (x >= slot.xPos && x <= slot.xPos + 17 && y >= slot.yPos && y <= slot.yPos + 17) {
                boolean allocated = ((itemAlloc >> i) & 1) != 0;
                allocated = !allocated;
                if (allocated) {
                    itemAlloc = itemAlloc | (1 << i);
                } else {
                    itemAlloc = itemAlloc & ~(1 << i);
                }
                cardInfo.setItemAllocation(itemAlloc);
                sendServerCommand(RFToolsCtrlMessages.INSTANCE, ProcessorTileEntity.CMD_ALLOCATE, new Argument("card", setupMode), new Argument("items", itemAlloc), new Argument("vars", varAlloc), new Argument("fluids", fluidAlloc));
                break;
            }
        }
    }
}
Also used : Argument(mcjty.lib.network.Argument) Slot(net.minecraft.inventory.Slot)

Example 93 with Argument

use of mcjty.lib.network.Argument in project RFToolsControl by McJty.

the class GuiCraftingCard method initGui.

@Override
public void initGui() {
    super.initGui();
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).setBackground(iconLocation);
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    toplevel.addChild(new Label(mc, this).setText("Regular 3x3 crafting recipe").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setLayoutHint(new PositionalLayout.PositionalHint(10, 4, 160, 14)));
    toplevel.addChild(new Label(mc, this).setText("or more complicated recipes").setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setLayoutHint(new PositionalLayout.PositionalHint(10, 17, 160, 14)));
    toplevel.addChild(new Button(mc, this).setText("Update").setTooltips("Update the item in the output", "slot to the recipe in the", "3x3 grid").addButtonEvent(parent -> RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketSendServerCommand(RFToolsControl.MODID, CommandHandler.CMD_TESTRECIPE, Arguments.EMPTY))).setLayoutHint(new PositionalLayout.PositionalHint(110, 57, 60, 14)));
    ToggleButton toggle = new ToggleButton(mc, this).setCheckMarker(true).setText("NBT").setTooltips("Enable this if you want", "opcodes like 'get_ingredients'", "to strictly match on NBT").setLayoutHint(new PositionalLayout.PositionalHint(110, 74, 60, 14));
    ItemStack heldItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
    if (!heldItem.isEmpty()) {
        toggle.setPressed(CraftingCardItem.isStrictNBT(heldItem));
    }
    toggle.addButtonEvent(parent -> {
        RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketUpdateNBTItemCard(new Argument("strictnbt", toggle.isPressed())));
    });
    toplevel.addChild(toggle);
    for (int y = 0; y < GRID_HEIGHT; y++) {
        for (int x = 0; x < GRID_WIDTH; x++) {
            int idx = y * GRID_WIDTH + x;
            createDummySlot(toplevel, idx, new PositionalLayout.PositionalHint(x * 18 + 10, y * 18 + 37, 18, 18), createSelectionEvent(idx));
        }
    }
    createDummySlot(toplevel, INPUT_SLOTS, new PositionalLayout.PositionalHint(10 + 8 * 18, 37, 18, 18), createSelectionEvent(INPUT_SLOTS));
    updateSlots();
    window = new Window(this, toplevel);
}
Also used : Window(mcjty.lib.gui.Window) PacketSendServerCommand(mcjty.lib.network.PacketSendServerCommand) Argument(mcjty.lib.network.Argument) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Rectangle(java.awt.Rectangle) ItemStack(net.minecraft.item.ItemStack)

Example 94 with Argument

use of mcjty.lib.network.Argument in project RFToolsControl by McJty.

the class GuiCraftingStation method cancelRequest.

private void cancelRequest() {
    int selected = requestList.getSelected();
    if (selected == -1) {
        return;
    }
    sendServerCommand(RFToolsCtrlMessages.INSTANCE, CraftingStationTileEntity.CMD_CANCEL, new Argument("index", selected));
}
Also used : Argument(mcjty.lib.network.Argument)

Example 95 with Argument

use of mcjty.lib.network.Argument in project XNet by McJty.

the class TileEntityController method updateConnector.

private void updateConnector(int channel, SidedPos pos, Map<String, Argument> args) {
    WorldBlob worldBlob = XNetBlobData.getBlobData(getWorld()).getWorldBlob(getWorld());
    ConsumerId consumerId = worldBlob.getConsumerAt(pos.getPos().offset(pos.getSide()));
    for (Map.Entry<SidedConsumer, ConnectorInfo> entry : channels[channel].getConnectors().entrySet()) {
        SidedConsumer key = entry.getKey();
        if (key.getConsumerId().equals(consumerId) && key.getSide().getOpposite().equals(pos.getSide())) {
            Map<String, Object> data = new HashMap<>();
            for (Map.Entry<String, Argument> e : args.entrySet()) {
                data.put(e.getKey(), e.getValue().getValue());
            }
            channels[channel].getConnectors().get(key).getConnectorSettings().update(data);
            networkDirty();
            markDirtyQuick();
            return;
        }
    }
}
Also used : ConnectorInfo(mcjty.xnet.clientinfo.ConnectorInfo) Argument(mcjty.lib.network.Argument) SidedConsumer(mcjty.xnet.api.keys.SidedConsumer) ConsumerId(mcjty.xnet.api.keys.ConsumerId) WorldBlob(mcjty.xnet.multiblock.WorldBlob)

Aggregations

Argument (mcjty.lib.network.Argument)97 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)8 Window (mcjty.lib.gui.Window)7 Panel (mcjty.lib.gui.widgets.Panel)6 ItemStack (net.minecraft.item.ItemStack)6 PacketServerCommand (mcjty.lib.network.PacketServerCommand)4 ArrayList (java.util.ArrayList)3 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)3 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)3 Label (mcjty.lib.gui.widgets.Label)3 PacketRequestIntegerFromServer (mcjty.lib.network.PacketRequestIntegerFromServer)3 java.awt (java.awt)2 Rectangle (java.awt.Rectangle)2 StyleConfig (mcjty.lib.base.StyleConfig)2 GenericEnergyStorageTileEntity (mcjty.lib.entity.GenericEnergyStorageTileEntity)2 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)2 VerticalLayout (mcjty.lib.gui.layout.VerticalLayout)2 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)2 ChoiceLabel (mcjty.lib.gui.widgets.ChoiceLabel)2 TextField (mcjty.lib.gui.widgets.TextField)2