use of net.minecraft.item.crafting.Ingredient in project Bewitchment by Um-Mitternacht.
the class SpinningThreadRecipe method matches.
public boolean matches(NonNullList<ItemStack> list) {
int nonEmpty = 0;
for (ItemStack is : list) {
if (is.getCount() > 0)
nonEmpty++;
}
if (nonEmpty != inputs.length) {
return false;
}
boolean[] found = new boolean[inputs.length];
ArrayList<ItemStack> comp = new ArrayList<ItemStack>(list);
for (int i = 0; i < inputs.length; i++) {
Ingredient current = inputs[i];
for (int j = 0; j < comp.size(); j++) {
ItemStack is = comp.get(j);
if (current.apply(is)) {
found[i] = true;
comp.set(j, ItemStack.EMPTY);
break;
}
}
}
for (boolean b : found) {
if (!b) {
return false;
}
}
return true;
}
use of net.minecraft.item.crafting.Ingredient in project Bewitchment by Um-Mitternacht.
the class ModSpinningThreadRecipes method init.
public static void init() {
Ingredient string = Ingredient.fromItem(Items.STRING);
web = new SpinningThreadRecipe(LibMod.MOD_ID, "spider_web", new ItemStack(Blocks.WEB), string, string, string);
// soulstring = new SpinningThreadRecipe(LibMod.MOD_ID, "soulstring", new ItemStack(ModItems.soulstring), string, string, Ingredient.fromStacks(new ItemStack(ModItems.misc, 1, 5)), Ingredient.fromStacks(new ItemStack(ModItems.flowers, 1, 1)));
registerAll();
}
use of net.minecraft.item.crafting.Ingredient in project Bewitchment by Um-Mitternacht.
the class AdapterIRitual method isValidInput.
public boolean isValidInput(List<ItemStack> ground, boolean circles) {
ArrayList<ItemStack> checklist = new ArrayList<ItemStack>(ground.size());
for (ItemStack item : ground) for (int j = 0; j < item.getCount(); j++) {
ItemStack copy = item.copy();
copy.setCount(1);
checklist.add(copy);
}
if (checklist.size() != ritual.getInput().size()) {
return false;
}
ArrayList<Ingredient> removalList = new ArrayList<Ingredient>(ritual.getInput());
for (ItemStack stack_on_ground : checklist) {
Ingredient found = null;
for (Ingredient ingredient : removalList) {
if (ingredient.apply(stack_on_ground)) {
found = ingredient;
break;
}
}
if (found == null) {
return false;
}
removalList.remove(found);
}
if (!removalList.isEmpty()) {
return false;
}
return circles;
}
use of net.minecraft.item.crafting.Ingredient in project Bewitchment by Um-Mitternacht.
the class SpinnerWrapper method getIngredients.
@Override
public void getIngredients(IIngredients ingredients) {
ArrayList<List<ItemStack>> list = new ArrayList<List<ItemStack>>();
for (Ingredient i : input) list.add(Arrays.asList(i.getMatchingStacks()));
ingredients.setInputLists(ItemStack.class, list);
ingredients.setOutput(ItemStack.class, output);
}
use of net.minecraft.item.crafting.Ingredient in project BuildCraft by BuildCraft.
the class GuideCraftingFactory method getFactory.
public static GuidePartFactory getFactory(IRecipe recipe) {
ItemStack output = recipe.getRecipeOutput();
NonNullList<Ingredient> input = recipe.getIngredients();
if (input == null || input.isEmpty() || output.isEmpty()) {
return null;
}
Ingredient[][] matrix = new Ingredient[3][3];
int maxX = recipe instanceof IShapedRecipe ? ((IShapedRecipe) recipe).getRecipeWidth() : 3;
int maxY = recipe instanceof IShapedRecipe ? ((IShapedRecipe) recipe).getRecipeHeight() : 3;
int offsetX = maxX == 1 ? 1 : 0;
int offsetY = maxY == 1 ? 1 : 0;
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
if (x < offsetX || y < offsetY) {
matrix[x][y] = Ingredient.EMPTY;
continue;
}
int i = x - offsetX + (y - offsetY) * maxX;
if (i >= input.size() || x - offsetX >= maxX) {
matrix[x][y] = Ingredient.EMPTY;
} else {
matrix[x][y] = input.get(i);
}
}
}
return new GuideCraftingFactory(matrix, output);
}
Aggregations