#Recipes

1 messages · Page 1 of 1 (latest)

frail lava
#

Soo

#

when you have a Recipe

#

check if it's a ShapedRecipe or ShapelessRecipe

#

then cast it to whateer it is

long abyss
#

Okay

frail lava
#

then you can get the ChoiceMap

#

that one contains different Entry<Character,RecipeChoice>

#

for each of those, get the RecipeChoice and cast it to either MaterialChoice or ExactChoice (whatever it is)

#

then check how often every character appears in the recipe's shape and then you can determine how many items of which materials you need

iron crow
#

If you want support for other things than crafting you need to check for the other types

#

Here are all the types: BlastingRecipe, CampfireRecipe, CookingRecipe, FurnaceRecipe, MerchantRecipe, ShapedRecipe, ShapelessRecipe, SmithingRecipe, SmokingRecipe, StonecuttingRecipe

long abyss
#

@frail lava thx

frail lava
#

np

long abyss
frail lava
#

what type of recipe do you have?

#

ShapelessRecipe, ShapedRecipe, or sth else?

long abyss
#
        for(Recipe recipe : Bukkit.getRecipesFor(new ItemStack(Material.getMaterial(args[0])))) {
            if(recipe instanceof ShapedRecipe) {
                ShapedRecipe shaped = (ShapedRecipe) recipe;

                
            }
            else if(recipe instanceof ShapelessRecipe) {
                ShapelessRecipe shapeless = (ShapelessRecipe)recipe;
            }
        }
#

This is what i have

#

what to do now?

frail lava
#

you can use spaed.getChoiceMap() or shapeless.getChoiceList()

#

both contain RecipeChoices

#

(well the map obviously contains Entry<Character,RecipeChoice> instead)

long abyss
frail lava
#

are you on 1.8 or something outdated?

long abyss
#

yup :/

frail lava
#

oh no idea then

long abyss
#

can i skip this step?

frail lava
#

you have to simply use the ingredientmap

long abyss
#

Okay.

frail lava
#

instead of RecipeChoices, it directly contains ItemStacks

#

sooo it's actually easier to use

#

the RecipeChoices were added because of all the different wood types could be used to craft the same items

frail lava
#

what are you trying to do?

long abyss
#

i want to get all items needed to craft the item

frail lava
#

getIngredientMap().entrySet() returns a Set<ItemStack>

#

sooo "basically" a list of itemstacks

long abyss
#

It worked. Thank you so much!