use of net.minecraft.item.crafting.RecipeManager in project minecolonies by Minecolonies.
the class JEIPlugin method buildVanillaRecipesMap.
private Map<IRecipeType<?>, List<IGenericRecipe>> buildVanillaRecipesMap() {
final RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
final List<IGenericRecipe> craftingRecipes = new ArrayList<>();
for (final IRecipe<CraftingInventory> recipe : recipeManager.byType(IRecipeType.CRAFTING).values()) {
if (!recipe.canCraftInDimensions(3, 3))
continue;
tryAddingVanillaRecipe(craftingRecipes, recipe);
}
final List<IGenericRecipe> smeltingRecipes = new ArrayList<>();
for (final IRecipe<IInventory> recipe : recipeManager.byType(IRecipeType.SMELTING).values()) {
tryAddingVanillaRecipe(smeltingRecipes, recipe);
}
return new ImmutableMap.Builder<IRecipeType<?>, List<IGenericRecipe>>().put(IRecipeType.CRAFTING, craftingRecipes).put(IRecipeType.SMELTING, smeltingRecipes).build();
}
use of net.minecraft.item.crafting.RecipeManager in project minecolonies by ldtteam.
the class JEIPlugin method buildVanillaRecipesMap.
private Map<IRecipeType<?>, List<IGenericRecipe>> buildVanillaRecipesMap() {
final RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
final List<IGenericRecipe> craftingRecipes = new ArrayList<>();
for (final IRecipe<CraftingInventory> recipe : recipeManager.byType(IRecipeType.CRAFTING).values()) {
if (!recipe.canCraftInDimensions(3, 3))
continue;
tryAddingVanillaRecipe(craftingRecipes, recipe);
}
final List<IGenericRecipe> smeltingRecipes = new ArrayList<>();
for (final IRecipe<IInventory> recipe : recipeManager.byType(IRecipeType.SMELTING).values()) {
tryAddingVanillaRecipe(smeltingRecipes, recipe);
}
return new ImmutableMap.Builder<IRecipeType<?>, List<IGenericRecipe>>().put(IRecipeType.CRAFTING, craftingRecipes).put(IRecipeType.SMELTING, smeltingRecipes).build();
}
use of net.minecraft.item.crafting.RecipeManager in project Ceramics by KnightMiner.
the class JEIPlugin method registerRecipes.
@Override
public void registerRecipes(IRecipeRegistration registration) {
ClientWorld world = Minecraft.getInstance().world;
assert world != null;
RecipeManager recipeManager = world.getRecipeManager();
List<KilnRecipe> results = new ArrayList<>();
for (IRecipe<IInventory> recipe : recipeManager.getRecipes(Registration.KILN_RECIPE).values()) {
// ignore dynamic
if (recipe.isDynamic()) {
continue;
}
// validate output
ItemStack output = recipe.getRecipeOutput();
if (output.isEmpty()) {
Ceramics.LOG.error("Invalid kiln recipe {}, no output", recipe.getId());
continue;
}
List<Ingredient> ingredients = recipe.getIngredients();
if (ingredients.size() != 1) {
Ceramics.LOG.error("Invalid kiln recipe {}, wrong number of inputs", recipe.getId());
continue;
}
// recipe type
if (!(recipe instanceof KilnRecipe)) {
Ceramics.LOG.error("Invalid kiln recipe {}, wrong class", recipe.getId());
continue;
}
// add to list
results.add((KilnRecipe) recipe);
}
registration.addRecipes(results, KilnCategory.UID);
// clay repair info
List<ItemStack> clayRepair = CeramicsTags.Items.TERRACOTTA_CRACK_REPAIR.getAllElements().stream().map(ItemStack::new).collect(Collectors.toList());
registration.addIngredientInfo(clayRepair, VanillaTypes.ITEM, Ceramics.lang("jei", "clay_repair"));
}
use of net.minecraft.item.crafting.RecipeManager in project Mekanism by mekanism.
the class MekanismRecipeType method getRecipes.
@Nonnull
public List<RECIPE_TYPE> getRecipes(@Nullable World world) {
if (world == null) {
// Try to get a fallback world if we are in a context that may not have one
// If we are on the client get the client's world, if we are on the server get the current server's world
world = DistExecutor.safeRunForDist(() -> MekanismClient::tryGetClientWorld, () -> () -> ServerLifecycleHooks.getCurrentServer().overworld());
if (world == null) {
// If we failed, then return no recipes
return Collections.emptyList();
}
}
if (cachedRecipes.isEmpty()) {
RecipeManager recipeManager = world.getRecipeManager();
// TODO: Should we use the byType(RecipeType) that we ATd so that our recipes don't have to always return true for matching?
List<RECIPE_TYPE> recipes = recipeManager.getRecipesFor(this, IgnoredIInventory.INSTANCE, world);
if (this == SMELTING) {
Map<ResourceLocation, IRecipe<IInventory>> smeltingRecipes = recipeManager.byType(IRecipeType.SMELTING);
// Copy recipes our recipes to make sure it is mutable
recipes = new ArrayList<>(recipes);
for (Entry<ResourceLocation, IRecipe<IInventory>> entry : smeltingRecipes.entrySet()) {
IRecipe<IInventory> smeltingRecipe = entry.getValue();
ItemStack recipeOutput = smeltingRecipe.getResultItem();
if (!smeltingRecipe.isSpecial() && !recipeOutput.isEmpty()) {
// TODO: Can Smelting recipes even be "special", if so can we add some sort of checker to make getOutput return the correct result
NonNullList<Ingredient> ingredients = smeltingRecipe.getIngredients();
int ingredientCount = ingredients.size();
ItemStackIngredient input;
if (ingredientCount == 0) {
// Something went wrong
continue;
} else if (ingredientCount == 1) {
input = ItemStackIngredient.from(ingredients.get(0));
} else {
ItemStackIngredient[] itemIngredients = new ItemStackIngredient[ingredientCount];
for (int i = 0; i < ingredientCount; i++) {
itemIngredients[i] = ItemStackIngredient.from(ingredients.get(i));
}
input = ItemStackIngredient.createMulti(itemIngredients);
}
recipes.add((RECIPE_TYPE) new SmeltingIRecipe(entry.getKey(), input, recipeOutput));
}
}
}
cachedRecipes = recipes;
}
return cachedRecipes;
}
use of net.minecraft.item.crafting.RecipeManager in project MCMOD-Industria by M-Marvin.
the class JEIPlugin method registerRecipes.
@SuppressWarnings("resource")
@Override
public void registerRecipes(IRecipeRegistration registration) {
RecipeManager manager = Minecraft.getInstance().level.getRecipeManager();
registration.addRecipes(getRecipes(manager, ModRecipeTypes.ALLOY), JEIRecipeCategories.ALLOY_FURNACE);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.THERMAL_ZENTRIFUGE), JEIRecipeCategories.THERMAL_ZENTRIFUGE);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.SCHREDDER), JEIRecipeCategories.SCHREDDER);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.BLENDING), JEIRecipeCategories.BLENDER);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.RIFINING), JEIRecipeCategories.RIFINING);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.FLUID_BATH), JEIRecipeCategories.FLUID_BATH);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.WASHING), JEIRecipeCategories.WASHING_PLANT);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.METAL_FORM), JEIRecipeCategories.METAL_FORMER);
registration.addRecipes(getRecipes(manager, ModRecipeTypes.BLAST_FURNACE), JEIRecipeCategories.BLAST_FURNACE);
registration.addRecipes(UtilHelper.toCollection(new FluidStack(ModFluids.COMPRESSED_AIR, 1500)), JEIRecipeCategories.AIR_COMPRESSOR);
registration.addRecipes(MultipartBuildRecipes.getRecipes(), JEIRecipeCategories.MULTIPART_BUILD);
}
Aggregations