#Recipe Choices

1 messages ยท Page 1 of 1 (latest)

brittle pond
#

I'm confused

#

i have a few questions

maiden sorrel
#

Let's stay on the jukebox example

#

You'll get a Map<Character, RecipeChoice>

brittle pond
#

first: can you use recipe choices for items with no choices (ex: DIAMOND_BLOCK)?

maiden sorrel
#

it will look like this:
'W' -> new MaterialChoice(Material.OAK_WOOD, Material.SPRUCE_WOOD, Material.ACACIA_WOOD, ...);
'D' -> new MaterialChoice(Material.DIAMOND);

brittle pond
#

second: for things like the JUKEBOX, does the size of the material list of the recpiechoice stay constant for all items or is it different sized for the diamond and wood

brittle pond
#

ok

maiden sorrel
brittle pond
#

wouldnt it be new MaterialChoice (list)?

#

list of materials

maiden sorrel
#

imagine you have a ShapedRecipe called diamondBlockRecipe

#

one sec

brittle pond
#

kk

maiden sorrel
#
RecipeChoice diamonds = diamondBlockRecipe.getChoiceMap().get('D');
        if(diamonds instanceof RecipeChoice.MaterialChoice) {
            RecipeChoice.MaterialChoice diamondMaterials = (RecipeChoice.MaterialChoice) diamonds;
            List<Material> list = diamondMaterials.getChoices();
            // list.get(0) == Material.DIAMOND
            // The list doesn't container other entries
        }
brittle pond
#

ok thats what i was going to do

#

but im still confused to why you need to cast

#

and there's no direct method

brittle pond
#

they are

brittle pond
#

abc, def, ghi

maiden sorrel
#

beause diamonds could also be an ExactChoice

brittle pond
#

even if they are the same

brittle pond
#

oh

maiden sorrel
#

How will you know that at compile time??

brittle pond
#

i understand

#

but

maiden sorrel
#

okay ๐Ÿ˜„

brittle pond
#

idk something like getMaterialChoice and it returns null if its an exact? ok now i see why thats a bad idea

#

ty

maiden sorrel
#

you're not thinking in objects and abstraction enough yet^^

#

like, the map can contain both (in theory), 'D' could be a MaterialChoice and 'F' could be an ExactChoice

#

but they all have to fit into one Map

#

so there's the interface that connects them

#

which is the RecipeChoice

#

Just imagine you have a table in your kitchen and you have cutlery on it

#

5 knifes and 5 forks

brittle pond
#

yes

#

i already understood

maiden sorrel
#

now you can do kitchenTable.getCutlery() and some of those will be Knife, others will be fork

#

alright ๐Ÿ˜„

brittle pond
#

for some reason i was thinking that exactchoices werent a thing

#

since they arent used in vanilla

#

so

#

that would mean that all recipechoices are material choices

#

so then why would there be no direct method

maiden sorrel
#

yeah but plugins could use them^^

brittle pond
#

yes

#

i realised