Solved 100% stumped recipe trouble

Discussion in 'Plugin Development' started by Fiddy_percent, Jul 30, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    So Im trying to make a system that lets me change the recipe based on metadata and not just material data
    Basicly this is just raw setup it removes the result item then puts the arraylist in to the next class the skull item can be any item so dont worry about that
    It works but... only for the first recipe and I cant figure out why
    1. public void crafting(PrepareItemCraftEvent e){
    2. Player p = (Player)e.getViewers().get(0);
    3. ItemStack[] items = e.getInventory().getContents();
    4. ArrayList<ItemStack> correct = new ArrayList<ItemStack>();
    5. for(ItemStack i : items){
    6. correct.add(i);
    7. }
    8. correct.remove(0);
    9. ItemStack result = e.getRecipe().getResult();
    10. Recipe r = new Recipe(plugin);
    11. ItemStack fail = new ItemStack(Material.SKULL);
    12. ItemStack rc = r.recipeCheck(correct);
    13. if(!rc.isSimilar(fail)){
    14. Bukkit.broadcastMessage(ChatColor.RED + "is not a skull item + " +rc.toString() );
    15. e.getInventory().setItem(0,rc);
    16. }else{
    18. }
    19. if(plugin.cantCraft(result) == false){
    20. e.getInventory().setItem(0, plugin.getFailedDish());
    21. }
    22. }

    The meat is here

    So what it does is takes a itemstack, gets the name (checks if it has a general item that has quality levels) then compares it to a set recipe (right now its on equals) and if they match its suppose to set the result of the prepair crafting event with that itemstack but it only does that for the spicey chicken not the normal one I HAVE NO CLUE WHY D: ive tried contains contains all ect it even matches the recipe and says its return the item but then it just stops unless its the spicey chicken

    I have the recipes set up so it does call the event

    1. public void hotRawChicken() {
    2. ItemStack item = new ItemStack(Material.ROTTEN_FLESH);
    3. ShapelessRecipe hotRawChicken = new ShapelessRecipe(item);
    4. hotRawChicken.addIngredient(Material.NETHER_STALK);
    5. hotRawChicken.addIngredient(Material.PUMPKIN_SEEDS);
    6. hotRawChicken.addIngredient(Material.MELON_SEEDS);
    7. hotRawChicken.addIngredient(Material.RAW_CHICKEN);
    8. Bukkit.addRecipe(hotRawChicken);
    9. }
    11. public void PreparedChicken() {
    12. ItemStack item = new ItemStack(Material.ROTTEN_FLESH);
    13. ShapelessRecipe PreparedChicken = new ShapelessRecipe(item);
    14. PreparedChicken.addIngredient(Material.PUMPKIN_SEEDS);
    15. PreparedChicken.addIngredient(Material.MELON_SEEDS);
    16. PreparedChicken.addIngredient(Material.RAW_CHICKEN);
    17. Bukkit.addRecipe(PreparedChicken);
    18. }

    NO errors at all spicey chicken gets the itemstack with all the meta and season get rotten flesh;

    Figured it out XD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page