use of net.minecraft.item.crafting.Ingredient in project Adventurers-Toolbox by the-realest-stu.
the class ModRecipes method getToolHeadSchematicRecipe.
private static IRecipe getToolHeadSchematicRecipe(ItemStack output, String material, String type, int cost) {
NonNullList<Ingredient> inputs = NonNullList.withSize(cost + 1, Ingredient.EMPTY);
ItemStack schematic = new ItemStack(ModItems.schematic);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString(ItemSchematic.type_tag, type);
schematic.setTagCompound(nbt);
Ingredient schematicIngredient = new IngredientNBT(schematic) {
};
inputs.set(0, schematicIngredient);
for (int i = 1; i <= cost; i++) {
inputs.set(i, new OreIngredient(material));
}
return new ShapelessOreRecipe(null, inputs, output);
}
use of net.minecraft.item.crafting.Ingredient in project Adventurers-Toolbox by the-realest-stu.
the class CommonProxy method processRecipes.
protected void processRecipes() {
if (ForgeRegistries.RECIPES instanceof IForgeRegistryModifiable) {
IForgeRegistryModifiable registry = (IForgeRegistryModifiable) ForgeRegistries.RECIPES;
Entry<ResourceLocation, IRecipe>[] recipeEntries = ForgeRegistries.RECIPES.getEntries().toArray(new Entry[ForgeRegistries.RECIPES.getEntries().size()]);
for (int recipeIndex = 0; recipeIndex < recipeEntries.length; recipeIndex++) {
Entry<ResourceLocation, IRecipe> recipeEntry = recipeEntries[recipeIndex];
IRecipe recipe = recipeEntry.getValue();
NonNullList<Ingredient> ingredients = recipe.getIngredients();
Item output = recipe.getRecipeOutput().getItem();
String rp = output.getRegistryName().getResourcePath();
if ((output instanceof ItemHoe || output instanceof ItemAxe || output instanceof ItemSpade || output instanceof ItemPickaxe || output instanceof ItemSword) || (output instanceof ItemTool && (rp.contains("pick") || rp.contains("axe") || rp.contains("shovel") || rp.contains("spade"))) || (output instanceof ItemTool && (output.getRegistryName().getResourceDomain().equals("thermalfoundation") && rp.contains("hammer")))) {
String materialName = output instanceof ItemHoe ? ((ItemHoe) output).getMaterialName() : output instanceof ItemSword ? ((ItemSword) output).getToolMaterialName() : ((ItemTool) output).getToolMaterialName();
if (Materials.canReplaceMaterial(materialName, recipe.getRecipeOutput())) {
// System.out.println(materialName);
registry.remove(recipeEntry.getKey());
registry.register(new IRecipe() {
private ResourceLocation registryName;
@Override
public IRecipe setRegistryName(ResourceLocation name) {
this.registryName = name;
return this;
}
@Override
public ResourceLocation getRegistryName() {
return this.registryName;
}
@Override
public Class<IRecipe> getRegistryType() {
return IRecipe.class;
}
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
return false;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return ItemStack.EMPTY;
}
@Override
public boolean canFit(int width, int height) {
return false;
}
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
}
}.setRegistryName(recipeEntry.getKey()));
removed_recipes.add(recipeEntry.getKey());
} else {
System.out.println(output.getRegistryName() + " -> " + materialName);
}
} else {
for (int i = 0; i < ingredients.size(); i++) {
ItemStack[] matchingStacks = ingredients.get(i).getMatchingStacks();
boolean flag = false;
Item ingredientItem = null;
for (int j = 0; j < matchingStacks.length && !flag; j++) {
Item item = matchingStacks[j].getItem();
if (!getToolReplacement(item).isEmpty()) {
ingredientItem = item;
flag = true;
}
}
if (flag && ingredientItem != null && !getToolReplacement(ingredientItem).isEmpty()) {
ingredients.set(i, new IngredientNBT(getToolReplacement(ingredientItem)) {
});
}
}
}
}
}
}
use of net.minecraft.item.crafting.Ingredient in project BloodMagic by WayofTime.
the class BloodMagicRecipeRegistrar method addAlchemyTable.
@Override
public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks, @Nonnegative int minimumTier, @Nonnull Ingredient... input) {
Preconditions.checkNotNull(output, "output cannot be null.");
Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
Preconditions.checkNotNull(input, "input cannot be null.");
NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
alchemyRecipes.add(new RecipeAlchemyTable(inputs, output, syphon, ticks, minimumTier));
}
use of net.minecraft.item.crafting.Ingredient in project BloodMagic by WayofTime.
the class BloodMagicRecipeRegistrar method addTartaricForge.
public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain, @Nonnull Object... input) {
Preconditions.checkNotNull(output, "output cannot be null.");
Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
Preconditions.checkNotNull(input, "input cannot be null.");
List<Ingredient> ingredients = Lists.newArrayList();
for (Object object : input) {
if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb) {
ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
continue;
}
ingredients.add(CraftingHelper.getIngredient(object));
}
addTartaricForge(output, minimumSouls, soulDrain, ingredients.toArray(new Ingredient[0]));
}
use of net.minecraft.item.crafting.Ingredient in project BloodMagic by WayofTime.
the class BloodMagicRecipeRegistrar method addAlchemyTable.
public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks, @Nonnegative int minimumTier, @Nonnull Object... input) {
Preconditions.checkNotNull(output, "output cannot be null.");
Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
Preconditions.checkNotNull(input, "input cannot be null.");
List<Ingredient> ingredients = Lists.newArrayList();
for (Object object : input) {
if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb) {
ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
continue;
}
ingredients.add(CraftingHelper.getIngredient(object));
}
addAlchemyTable(output, syphon, ticks, minimumTier, ingredients.toArray(new Ingredient[0]));
}
Aggregations