use of codechicken.nei.PositionedStack in project BluePower by Qmunity.
the class ProjectTableOverlayHandler method getPermutationIngredients.
private List<DistributedIngred> getPermutationIngredients(List<PositionedStack> ingredients) {
ArrayList<DistributedIngred> ingredStacks = new ArrayList<DistributedIngred>();
for (// work out what we need
PositionedStack posstack : // work out what we need
ingredients) {
for (ItemStack pstack : posstack.items) {
DistributedIngred istack = findIngred(ingredStacks, pstack);
if (istack == null)
ingredStacks.add(istack = new DistributedIngred(pstack));
istack.recipeAmount += pstack.stackSize;
}
}
return ingredStacks;
}
use of codechicken.nei.PositionedStack in project LogisticsPipes by RS485.
the class LogisticsCraftingOverlayHandler method overlayRecipe.
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
TileEntity tile;
LogisticsBaseGuiScreen gui;
if (firstGui instanceof GuiLogisticsCraftingTable) {
tile = ((GuiLogisticsCraftingTable) firstGui)._crafter;
gui = (GuiLogisticsCraftingTable) firstGui;
} else if (firstGui instanceof GuiRequestTable) {
tile = ((GuiRequestTable) firstGui)._table.container;
gui = (GuiRequestTable) firstGui;
} else {
return;
}
ItemStack[] stack = new ItemStack[9];
ItemStack[][] stacks = new ItemStack[9][];
boolean hasCanidates = false;
NEISetCraftingRecipe packet = PacketHandler.getPacket(NEISetCraftingRecipe.class);
for (PositionedStack ps : recipe.getIngredientStacks(recipeIndex)) {
int x = (ps.relx - 25) / 18;
int y = (ps.rely - 6) / 18;
int slot = x + y * 3;
if (x < 0 || x > 2 || y < 0 || y > 2 || slot < 0 || slot > 8) {
FMLClientHandler.instance().getClient().thePlayer.sendChatMessage("Internal Error. This button is broken.");
return;
}
if (slot < 9) {
stack[slot] = ps.items[0];
List<ItemStack> list = new ArrayList<>(Arrays.asList(ps.items));
Iterator<ItemStack> iter = list.iterator();
while (iter.hasNext()) {
ItemStack wildCardCheckStack = iter.next();
if (wildCardCheckStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
iter.remove();
wildCardCheckStack.getItem().getSubItems(wildCardCheckStack.getItem(), wildCardCheckStack.getItem().getCreativeTab(), list);
iter = list.iterator();
}
}
stacks[slot] = list.toArray(new ItemStack[0]);
if (stacks[slot].length > 1) {
hasCanidates = true;
} else if (stacks[slot].length == 1) {
stack[slot] = stacks[slot][0];
}
}
}
if (hasCanidates) {
gui.setSubGui(new GuiRecipeImport(tile, stacks));
} else {
MainProxy.sendPacketToServer(packet.setContent(stack).setPosX(tile.xCoord).setPosY(tile.yCoord).setPosZ(tile.zCoord));
}
}
use of codechicken.nei.PositionedStack in project PneumaticCraft by MineMaarten.
the class NEIEtchingAcidManager method getAllRecipes.
@Override
protected List<MultipleInputOutputRecipe> getAllRecipes() {
List<MultipleInputOutputRecipe> recipes = new ArrayList<MultipleInputOutputRecipe>();
MultipleInputOutputRecipe recipe = new MultipleInputOutputRecipe();
recipe.addIngredient(new PositionedStack(new ItemStack(Itemss.emptyPCB), 41, 80));
recipe.addIngredient(new PositionedStack(new ItemStack(Fluids.getBucket(Fluids.etchingAcid)), 73, 80));
recipe.addOutput(new PositionedStack(new ItemStack(Itemss.unassembledPCB), 105, 80));
recipes.add(recipe);
return recipes;
}
use of codechicken.nei.PositionedStack in project BluePower by Qmunity.
the class ProjectTableOverlayHandler method assignIngredients.
private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks) {
ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
for (// assign what we need and have
PositionedStack posstack : // assign what we need and have
ingredients) {
DistributedIngred biggestIngred = null;
ItemStack permutation = null;
int biggestSize = 0;
for (ItemStack pstack : posstack.items) {
for (int j = 0; j < ingredStacks.size(); j++) {
DistributedIngred istack = ingredStacks.get(j);
if (!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount - istack.distributed < pstack.stackSize)
continue;
int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.stackSize;
if (relsize > biggestSize) {
biggestSize = relsize;
biggestIngred = istack;
permutation = pstack;
break;
}
}
}
if (// not enough ingreds
biggestIngred == null)
return null;
biggestIngred.distributed += permutation.stackSize;
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
}
return assignedIngredients;
}
use of codechicken.nei.PositionedStack in project BluePower by Qmunity.
the class ProjectTableOverlayHandler method mapIngredSlots.
@SuppressWarnings("unchecked")
public Slot[][] mapIngredSlots(GuiContainer gui, List<PositionedStack> ingredients) {
Slot[][] recipeSlotList = new Slot[ingredients.size()][];
for (// identify slots
int i = 0; // identify slots
i < ingredients.size(); // identify slots
i++) {
LinkedList<Slot> recipeSlots = new LinkedList<Slot>();
PositionedStack pstack = ingredients.get(i);
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) {
if (slot.xDisplayPosition == pstack.relx + 9 && slot.yDisplayPosition == pstack.rely + 10) {
recipeSlots.add(slot);
break;
}
}
recipeSlotList[i] = recipeSlots.toArray(new Slot[0]);
}
return recipeSlotList;
}
Aggregations