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);
}
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;
}
}
}
}
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);
}
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));
}
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;
}
}
}
Aggregations