Players learn recipe

Discussion in 'Spigot Discussion' started by Donkelyn, Aug 29, 2020.

  1. /recipe give @a clock

    I just need a way to reproduce this command. I currently have a for loop for all players but can't find the right way for them to learn the recipe for the clock.
     
  2. You can just listen for a player join event and use what ShaneBee suggested if it's their first join.
     
  3. Oh cool, do I have to make the recipe for each item, cause I wanna use vanilla items but I don't wanna waste space on remaking the recipe for each item.
     
  4. Just iterate through the recipes which already will be registered, and teach the player the recipe.
    Code (Text):
    for(Iterator<Recipe> recipes = s.recipeIterator(); recipes.hasNext();) {
    Recipe r = recipes.next();
    if(r instanceof Keyed)
    player.discoverRecipe(((Keyed)r).getKey());
    }
     
  5. if you know the recipe you can just create the key, ie:
    NamespacedKey.minecraft("some_recipe_here");