use of mekanism.api.recipes.inputs.ItemStackIngredient in project Mekanism by mekanism.
the class SawmillRecipeSerializer method fromNetwork.
@Override
public RECIPE fromNetwork(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
try {
ItemStackIngredient inputIngredient = ItemStackIngredient.read(buffer);
ItemStack mainOutput = buffer.readItem();
ItemStack secondaryOutput = buffer.readItem();
double secondaryChance = buffer.readDouble();
return this.factory.create(recipeId, inputIngredient, mainOutput, secondaryOutput, secondaryChance);
} catch (Exception e) {
Mekanism.logger.error("Error reading sawmill recipe from packet.", e);
throw e;
}
}
use of mekanism.api.recipes.inputs.ItemStackIngredient in project Mekanism by mekanism.
the class BYGRecipeProvider method dye.
private void dye(Consumer<IFinishedRecipe> consumer, String basePath, IItemProvider output, boolean large, EnumColor color, String inputTag, IItemProvider... extraInputs) {
ItemStackIngredient inputIngredient = ItemStackIngredient.from(BaseRecipeProvider.createIngredient(tag(inputTag), extraInputs));
String name = large ? "large_" + color.getRegistryPrefix() : color.getRegistryPrefix();
ItemStackToItemStackRecipeBuilder.enriching(inputIngredient, new ItemStack(output, large ? 4 : 2)).addCondition(modLoaded).build(consumer, Mekanism.rl(basePath + "dye/" + name));
// Flowers -> 4x dye output (See PigmentExtractingRecipeProvider#addFlowerExtractionRecipes for note)
long flowerRate = 3 * PigmentExtractingRecipeProvider.DYE_RATE;
ItemStackToChemicalRecipeBuilder.pigmentExtracting(inputIngredient, MekanismPigments.PIGMENT_COLOR_LOOKUP.get(color).getStack(large ? 2 * flowerRate : flowerRate)).addCondition(modLoaded).build(consumer, Mekanism.rl(basePath + "pigment_extracting/" + name));
}
use of mekanism.api.recipes.inputs.ItemStackIngredient in project Mekanism by mekanism.
the class ILikeWoodRecipeProvider method addWoodType.
// TODO: Maybe move some of these into RecipeProviderUtil, so that we make sure the numbers stay consistent
public static void addWoodType(Consumer<IFinishedRecipe> consumer, ICondition condition, String basePath, IItemProvider planks, IItemProvider log, IItemProvider fences, IWoodType woodType, ICondition bedVersion, ICondition soulTorchVersion) {
String name = woodType.getName();
Item stick = ILikeWood.getItem(woodType, WoodenItemType.STICK);
// Barrel
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.BARREL)), new ItemStack(planks, 7)).addCondition(condition).build(consumer, Mekanism.rl(basePath + "barrel/" + name));
// Chest
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.CHEST)), new ItemStack(planks, 8)).addCondition(condition).build(consumer, Mekanism.rl(basePath + "chest/" + name));
// Composter
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.COMPOSTER)), new ItemStack(planks, 3), new ItemStack(fences, 4), 1).addCondition(condition).build(consumer, Mekanism.rl(basePath + "composter/" + name));
// Crafting table
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.CRAFTING_TABLE)), new ItemStack(planks, 4)).addCondition(condition).build(consumer, Mekanism.rl(basePath + "crafting_table/" + name));
// Item Frame
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getItem(woodType, WoodenItemType.ITEM_FRAME)), new ItemStack(stick, 8), new ItemStack(Items.LEATHER), 1).addCondition(condition).build(consumer, Mekanism.rl(basePath + "item_frame/" + name));
// Ladder
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.LADDER), 3), new ItemStack(stick, 7)).addCondition(condition).build(consumer, Mekanism.rl(basePath + "ladder/" + name));
// Lectern
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.LECTERN)), new ItemStack(planks, 8), new ItemStack(Items.BOOK, 3), 1).addCondition(condition).build(consumer, Mekanism.rl(basePath + "lectern/" + name));
// Panel
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.PANELS)), new ItemStack(stick, 6), MekanismItems.SAWDUST.getItemStack(), 0.25).addCondition(condition).build(consumer, Mekanism.rl(basePath + "panel/" + name));
// Post
ItemStackIngredient postIngredient;
if (woodType.getBlockTypes().contains(WoodenBlockType.STRIPPED_POST)) {
postIngredient = ItemStackIngredient.from(Ingredient.of(ILikeWood.getBlock(woodType, WoodenBlockType.POST), ILikeWood.getBlock(woodType, WoodenBlockType.STRIPPED_POST)));
} else {
postIngredient = ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.POST));
}
SawmillRecipeBuilder.sawing(postIngredient, new ItemStack(planks, 3), MekanismItems.SAWDUST.getItemStack(), 0.125).addCondition(condition).build(consumer, Mekanism.rl(basePath + "post/" + name));
// Torch
Block torch = ILikeWood.getBlock(woodType, WoodenBlockType.TORCH);
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(torch, 4), new ItemStack(stick), new ItemStack(Items.COAL), 1).addCondition(condition).build(consumer, Mekanism.rl(basePath + "torch/" + name));
// Soul Torch
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.SOUL_TORCH), 4), new ItemStack(torch, 4), new ItemStack(Blocks.SOUL_SOIL), 1).addCondition(soulTorchVersion).build(consumer, Mekanism.rl(basePath + "soul_torch/" + name));
// Wall
if (woodType.getBlockTypes().contains(WoodenBlockType.WALL)) {
SawmillRecipeBuilder.sawing(ItemStackIngredient.from(ILikeWood.getBlock(woodType, WoodenBlockType.WALL)), new ItemStack(log)).addCondition(condition).build(consumer, Mekanism.rl(basePath + "wall/" + name));
}
// Beds
addBedRecipes(consumer, bedVersion, planks, woodType, basePath + "bed/" + name + "/");
}
use of mekanism.api.recipes.inputs.ItemStackIngredient in project Mekanism by mekanism.
the class MekanismRecipeHandler method convertIngredient.
private String convertIngredient(ItemStackIngredient ingredient) {
if (ingredient instanceof ItemStackIngredient.Single) {
JsonObject serialized = ingredient.serialize().getAsJsonObject();
Ingredient vanillaIngredient = ((ItemStackIngredient.Single) ingredient).getInputRaw();
int amount = JSONUtils.getAsInt(serialized, JsonConstants.AMOUNT, 1);
String rep = basicImplicitIngredient(vanillaIngredient, amount, serialized.get(JsonConstants.INGREDIENT));
if (rep == null) {
rep = IIngredient.fromIngredient(vanillaIngredient).getCommandString();
if (amount > 1) {
return CrTConstants.CLASS_ITEM_STACK_INGREDIENT + ".from(" + rep + ", " + amount + ")";
}
}
// Note: Handled via implicit casts
return rep;
} else if (ingredient instanceof ItemStackIngredient.Multi) {
ItemStackIngredient.Multi multiIngredient = (ItemStackIngredient.Multi) ingredient;
StringBuilder builder = new StringBuilder(CrTConstants.CLASS_ITEM_STACK_INGREDIENT + ".createMulti(");
multiIngredient.forEachIngredient(i -> {
builder.append(convertIngredient(i)).append(", ");
return false;
});
// Remove trailing comma and space
builder.setLength(builder.length() - 2);
builder.append(")");
return builder.toString();
}
// Shouldn't happen
return "Unimplemented itemstack ingredient: " + ingredient;
}
use of mekanism.api.recipes.inputs.ItemStackIngredient in project Mekanism by mekanism.
the class CrTItemStackIngredient method from.
/**
* Creates a {@link ItemStackIngredient} that matches a given ingredient and amount.
*
* @param ingredient Ingredient to match
* @param amount Amount needed
*
* @return A {@link ItemStackIngredient} that matches a given ingredient and amount.
*/
@ZenCodeType.StaticExpansionMethod
public static ItemStackIngredient from(IIngredient ingredient, int amount) {
CrTIngredientHelper.assertValidAmount("ItemStackIngredients", amount);
// Note: the IIngredient cases also handle item tags/item stacks
Ingredient vanillaIngredient = ingredient.asVanillaIngredient();
if (vanillaIngredient == Ingredient.EMPTY) {
throw new IllegalArgumentException("ItemStackIngredients cannot be made using the empty ingredient: " + amount);
}
return ItemStackIngredient.from(vanillaIngredient, amount);
}
Aggregations