use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.
the class RecipeShapedIngredient method saveIngredients.
public static Object[] saveIngredients(Object... recipe) {
Object[] converted = new Object[recipe.length];
String shape = "";
boolean shapeDone = false;
for (int i = 0; i < converted.length; i++) {
converted[i] = recipe[i];
if (!shapeDone)
if (recipe[i] instanceof String[]) {
String[] parts = ((String[]) recipe[i]);
for (String s : parts) shape += s;
} else if (recipe[i] instanceof String)
shape += (String) recipe[i];
if (recipe[i] instanceof Character) {
if (!shapeDone) {
shapeDone = true;
tempIngredients = new IngredientStack[shape.length()];
}
Character chr = (Character) recipe[i];
Object in = recipe[i + 1];
IngredientStack ingredient = ApiUtils.createIngredientStack(in);
if (ingredient != null) {
//Temp Replacement, fixed in constructor
recipe[i + 1] = Blocks.FIRE;
for (int j = 0; j < shape.length(); j++) if (chr.charValue() == shape.charAt(j))
tempIngredients[j] = ingredient;
}
}
}
return converted;
}
use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.
the class RecipeShapelessIngredient method setIngredients.
public RecipeShapelessIngredient setIngredients(IngredientStack[] ingr) {
ingredients = new ArrayList();
input.clear();
for (IngredientStack stack : ingr) if (stack != null) {
ingredients.add(stack);
input.add(stack.getShapedRecipeInput());
}
return this;
}
use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.
the class RecipeShapelessIngredient method saveIngredients.
public static Object[] saveIngredients(Object... recipe) {
Object[] converted = new Object[recipe.length];
tempIngredients = new IngredientStack[recipe.length];
for (int i = 0; i < recipe.length; i++) {
IngredientStack ingr = ApiUtils.createIngredientStack(recipe[i]);
if (ingr != null) {
tempIngredients[i] = ingr;
converted[i] = Blocks.FIRE;
}
}
return converted;
}
use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project DefiledLands by Lykrast.
the class CompatImmersiveEngineering method postInit.
@Override
public void postInit() {
// Garden Cloche
// Mostly copied from the vanilla registering
// Uses same numbers as Sugar Cane and Mushrooms
IngredientStack vilespineSoil = new IngredientStack(ImmutableList.of(new ItemStack(ModBlocks.dirtDefiled), new ItemStack(ModBlocks.grassDefiled), new ItemStack(ModBlocks.sandDefiled)));
BelljarHandler.stackingHandler.register(new ItemStack(ModBlocks.vilespine), new ItemStack[] { new ItemStack(ModBlocks.vilespine, 2) }, vilespineSoil, ModBlocks.vilespine.getDefaultState(), ModBlocks.vilespine.getDefaultState().withProperty(BlockVilespine.TOPMOST, true));
BelljarHandler.cropHandler.register(new ItemStack(ModBlocks.scuronotte), new ItemStack[] { new ItemStack(ModBlocks.scuronotte, 2) }, vilespineSoil, ModBlocks.scuronotte.getDefaultState());
IngredientStack blastemSoil = new IngredientStack(ImmutableList.of(new ItemStack(ModBlocks.dirtDefiled), new ItemStack(ModBlocks.grassDefiled)));
BelljarHandler.cropHandler.register(new ItemStack(ModBlocks.blastem), new ItemStack[] { new ItemStack(ModItems.blastemFruit) }, blastemSoil, ModBlocks.blastem.getDefaultState());
}
use of blusunrize.immersiveengineering.api.crafting.IngredientStack in project ImmersiveEngineering by BluSunrize.
the class TileEntityAssembler method consumeIngredients.
public boolean consumeIngredients(AssemblerHandler.RecipeQuery[] queries, ArrayList<ItemStack> itemStacks, boolean doConsume, @Nullable NonNullList<ItemStack> gridItems) {
if (!doConsume) {
ArrayList<ItemStack> dupeList = new ArrayList<>(itemStacks.size());
for (ItemStack stack : itemStacks) dupeList.add(stack.copy());
itemStacks = dupeList;
}
for (int i = 0; i < queries.length; i++) {
AssemblerHandler.RecipeQuery recipeQuery = queries[i];
if (recipeQuery != null && recipeQuery.query != null) {
FluidStack fs = recipeQuery.query instanceof FluidStack ? (FluidStack) recipeQuery.query : (recipeQuery.query instanceof IngredientStack && ((IngredientStack) recipeQuery.query).fluid != null) ? ((IngredientStack) recipeQuery.query).fluid : null;
int querySize = recipeQuery.querySize;
if (fs != null) {
boolean hasFluid = false;
for (FluidTank tank : tanks) if (tank.getFluid() != null && tank.getFluid().containsFluid(fs)) {
hasFluid = true;
if (doConsume)
tank.drain(fs.amount, true);
break;
}
if (hasFluid)
continue;
else
querySize = 1;
}
Iterator<ItemStack> it = itemStacks.iterator();
while (it.hasNext()) {
ItemStack next = it.next();
if (!next.isEmpty() && ApiUtils.stackMatchesObject(next, recipeQuery.query, true)) {
int taken = Math.min(querySize, next.getCount());
ItemStack forGrid = next.splitStack(taken);
if (gridItems != null)
gridItems.set(i, forGrid);
if (next.getCount() <= 0)
it.remove();
querySize -= taken;
if (querySize <= 0)
break;
}
}
if (querySize > 0)
return false;
}
}
return true;
}
Aggregations