use of mcjty.rftoolscontrol.api.parameters.Inventory in project RFToolsControl by McJty.
the class CraftingStationTileEntity method craftOk.
public ItemStack craftOk(ProcessorTileEntity processor, String ticket, ItemStack stack) {
CraftingRequest foundRequest = null;
for (CraftingRequest request : activeCraftingRequests) {
if (ticket.equals(request.getTicket())) {
foundRequest = request;
break;
}
}
if (foundRequest != null) {
markDirty();
foundRequest.decrTodo();
if (foundRequest.getTodo() <= 0) {
foundRequest.setOk(System.currentTimeMillis() + 1000);
} else {
processor.fireCraftEvent(ticket, foundRequest.getStack());
}
if (!stack.isEmpty()) {
Inventory inventory = getInventoryFromTicket(ticket);
if (inventory != null) {
IItemHandler handlerAt = processor.getItemHandlerAt(inventory);
if (handlerAt == null) {
throw new ProgException(ExceptionType.EXCEPT_INVALIDINVENTORY);
}
return ItemHandlerHelper.insertItem(handlerAt, stack, false);
} else {
return ItemHandlerHelper.insertItem(getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null), stack, false);
}
}
}
return stack;
}
use of mcjty.rftoolscontrol.api.parameters.Inventory in project RFToolsControl by McJty.
the class InventoryEditor method build.
@Override
public void build(Minecraft mc, Gui gui, Panel panel, ParameterEditorCallback callback) {
Panel constantPanel = new Panel(mc, gui).setLayout(new VerticalLayout());
nameLabel = new TextField(mc, gui).addTextEvent((o, text) -> callback.valueChanged(readValue())).addTextEnterEvent((parent, newText) -> closeWindow()).setDesiredWidth(50).setDesiredHeight(14);
constantPanel.addChild(createLabeledPanel(mc, gui, "Node name:", nameLabel, "Optional name of a node in the network"));
sideLabel = new ChoiceLabel(mc, gui).addChoices("*", "Down", "Up", "North", "South", "West", "East").addChoiceEvent((parent, newChoice) -> callback.valueChanged(readValue())).setDesiredWidth(60);
constantPanel.addChild(createLabeledPanel(mc, gui, "Side:", sideLabel, "Side relative to processor or node", "for the desired inventory"));
intSideLabel = new ChoiceLabel(mc, gui).addChoices("*", "Down", "Up", "North", "South", "West", "East").addChoiceEvent((parent, newChoice) -> callback.valueChanged(readValue())).setDesiredWidth(60);
constantPanel.addChild(createLabeledPanel(mc, gui, "Access:", intSideLabel, "Optional side from which we want to", "access the given inventory"));
createEditorPanel(mc, gui, panel, callback, constantPanel, ParameterType.PAR_INVENTORY);
}
use of mcjty.rftoolscontrol.api.parameters.Inventory in project RFToolsControl by McJty.
the class InventoryTools method inventoryFromString.
@Nullable
public static Inventory inventoryFromString(String s) {
if (s == null) {
return null;
}
int indexOf = s.lastIndexOf('/');
if (indexOf == -1) {
return null;
}
if (s.length() <= indexOf + 1) {
return null;
}
EnumFacing side = getSideFromChar(s.charAt(indexOf - 1));
if (side == null) {
// Side == null is invalid for Inventory
return null;
}
EnumFacing intSide = getSideFromChar(s.charAt(indexOf + 1));
int indexSpace = s.lastIndexOf(' ');
if (indexSpace <= 0) {
return new Inventory(null, side, intSide);
}
return new Inventory(s.substring(0, indexSpace), side, intSide);
}
use of mcjty.rftoolscontrol.api.parameters.Inventory in project RFToolsControl by McJty.
the class InventoryEditor method parseInventorySafe.
private static Inventory parseInventorySafe(String name, String sideS, String intSideS) {
EnumFacing side;
if ("*".equals(sideS)) {
return null;
} else {
side = EnumFacing.byName(StringUtils.lowerCase(sideS));
}
EnumFacing intSide;
if ("*".equals(intSideS)) {
intSide = null;
} else {
intSide = EnumFacing.byName(StringUtils.lowerCase(intSideS));
}
return new Inventory(name, side, intSide);
}
use of mcjty.rftoolscontrol.api.parameters.Inventory in project RFToolsControl by McJty.
the class InventoryEditor method writeConstantValue.
@Override
protected void writeConstantValue(ParameterValue value) {
if (value == null || value.getValue() == null) {
sideLabel.setChoice("*");
} else {
Inventory inv = (Inventory) value.getValue();
nameLabel.setText(inv.getNodeName() == null ? "" : inv.getNodeName());
sideLabel.setChoice(StringUtils.capitalize(inv.getSide().toString()));
if (inv.getIntSide() == null) {
intSideLabel.setChoice("*");
} else {
intSideLabel.setChoice(StringUtils.capitalize(inv.getIntSide().toString()));
}
}
}
Aggregations