use of codechicken.nei.PositionedStack in project PneumaticCraft by MineMaarten.
the class NEIAssemblyControllerRecipeManager method getShape.
protected MultipleInputOutputRecipe getShape(int programMetadata, int recipeIndex) {
AssemblyProgram program = ItemAssemblyProgram.getProgramFromItem(programMetadata);
AssemblyRecipe recipe = program.getRecipeList().get(recipeIndex);
MultipleInputOutputRecipe shape = new MultipleInputOutputRecipe();
//for now not useful to put it in an array, but supports when adding multiple input/output.
ItemStack[] inputStacks = new ItemStack[] { recipe.getInput() };
for (int i = 0; i < inputStacks.length; i++) {
PositionedStack stack = new PositionedStack(inputStacks[i], 29 + i % 2 * 18, 66 + i / 2 * 18);
shape.addIngredient(stack);
}
ItemStack[] outputStacks = new ItemStack[] { recipe.getOutput() };
for (int i = 0; i < outputStacks.length; i++) {
PositionedStack stack = new PositionedStack(outputStacks[i], 96 + i % 2 * 18, 66 + i / 2 * 18);
shape.addOutput(stack);
}
shape.addIngredient(new PositionedStack(new ItemStack(Itemss.assemblyProgram, 1, programMetadata), 133, 22));
ItemStack[] requiredMachines = getMachinesFromEnum(program.getRequiredMachines());
for (int i = 0; i < requiredMachines.length; i++) {
shape.addIngredient(new PositionedStack(requiredMachines[i], 5 + i * 18, 25));
}
return shape;
}
use of codechicken.nei.PositionedStack in project LogisticsPipes by RS485.
the class NEISolderingStationRecipeManager method getShape.
private ShapedRecipeHandler.CachedShapedRecipe getShape(SolderingStationRecipe recipe) {
ShapedRecipeHandler.CachedShapedRecipe shape = new ShapedRecipeHandler.CachedShapedRecipe(0, 0, null, recipe.result);
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
if (recipe.source[y * 3 + x] == null) {
continue;
}
PositionedStack stack = new PositionedStack(recipe.source[y * 3 + x], 39 + x * 18, 6 + y * 18);
stack.setMaxSize(1);
shape.ingredients.add(stack);
}
}
PositionedStack stack = new PositionedStack(new ItemStack(Items.iron_ingot, 1), 102, 6);
stack.setMaxSize(1);
shape.ingredients.add(stack);
shape.result.relx = 136;
shape.result.rely = 36;
return shape;
}
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