Shaped recipes not working! But shapeless are?

Discussion in 'Plugin Development' started by PsycoNova, Jul 5, 2014.

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

    PsycoNova

    Hey everyone!

    I'm not much of a bukkit plugin developer, but I can't say "no" when my little bro asks for some custom plugins. I've been programming for years so java really isn't the issue, but for some reason I can't get the ShapedRecipe(s) to give me the ItemStack. :confused: It is not throwing any errors and I know the code somewhat works, because the ShapelessRecipe(s) do work.

    Can anyone tell me whats wrong with this section of code? Thanks! ;)

    Code:java
    1. ItemStack b = new ItemStack(Material.BOW);
    2.  
    3. for(BowType type : BowType.values())
    4. {
    5. ItemStack temp = b;
    6. ItemMeta meta = temp.getItemMeta();
    7.  
    8. meta.setDisplayName(ChatColor.LIGHT_PURPLE + type.getName());
    9. meta.setLore(Arrays.asList(type.getLore()));
    10.  
    11. temp.setItemMeta(meta);
    12.  
    13. ShapedRecipe shaped = new ShapedRecipe(temp);
    14. ShapelessRecipe shapeless = new ShapelessRecipe(temp);
    15. shapeless.addIngredient(Material.BOW);
    16.  
    17.  
    18. switch(type)
    19. {
    20. case ExplosiveBow:
    21. explosiveBow = temp;
    22. shaped.shape(new String[] {" |~", "|^~", " |~"});
    23. shaped.setIngredient('^', Material.SULPHUR);
    24. shapeless.addIngredient(Material.SULPHUR);
    25. break;
    26. case TNTBow:
    27. tntBow = temp;
    28. shaped.shape(new String[] {" |~", "|^~", " |~"});
    29. shaped.setIngredient('^', Material.TNT);
    30. shapeless.addIngredient(Material.TNT);
    31. break;
    32. case SpawnBow:
    33. spawnBow = temp;
    34. shaped.shape(new String[] {" |~", "|^~", " |~"});
    35. shaped.setIngredient('^', Material.EGG);
    36. shapeless.addIngredient(Material.EGG);
    37. break;
    38. case LightBow:
    39. lightBow = temp;
    40. shaped.shape(new String[] {" |~", "|^~", " |~"});
    41. shaped.setIngredient('^', Material.TORCH);
    42. shapeless.addIngredient(Material.TORCH);
    43. break;
    44. case TeleportBow:
    45. teleportBow = temp;
    46. shaped.shape(new String[] {" |~", "|^~", " |~"});
    47. shaped.setIngredient('^', Material.ENDER_PEARL);
    48. shapeless.addIngredient(Material.ENDER_PEARL);
    49. break;
    50. case IceBow:
    51. iceBow = temp;
    52. shaped.shape(new String[] {" |~", "|^~", " |~"});
    53. shaped.setIngredient('^', Material.SNOW_BLOCK);
    54. shapeless.addIngredient(Material.SNOW_BLOCK);
    55. break;
    56. case LightningBow:
    57. lightningBow = temp;
    58. shaped.shape(new String[] {" |~", "|^~", " |~"});
    59. shaped.setIngredient('^', Material.IRON_BLOCK);
    60. shapeless.addIngredient(Material.IRON_BLOCK);
    61. break;
    62. case LifeStealBow:
    63. lifeStealBow = temp;
    64. shaped.shape(new String[] {" |~", "|^~", " |~"});
    65. shaped.setIngredient('^', Material.FISHING_ROD);
    66. shapeless.addIngredient(Material.FISHING_ROD);
    67. break;
    68. case GravityBow:
    69. gravityBow = temp;
    70. shapeless.addIngredient(Material.BLAZE_POWDER);
    71. shaped.shape(new String[] {" |~", "|^~", " |~"});
    72. shaped.setIngredient('^', Material.BLAZE_POWDER);
    73. break;
    74. case SlowBow:
    75. slowBow = temp;
    76. shaped.shape(new String[] {" |~", "|^~", " |~"});
    77. shaped.setIngredient('^', Material.SOUL_SAND);
    78. shapeless.addIngredient(Material.SOUL_SAND);
    79. break;
    80. case HealthBow:
    81. healthBow = temp;
    82. shaped.shape(new String[] {" |~", "|^~", " |~"});
    83. shaped.setIngredient('^', Material.GOLDEN_APPLE);
    84. shapeless.addIngredient(Material.GOLDEN_APPLE);
    85. break;
    86. case GrowBow:
    87. growBow = temp;
    88. shaped.shape(new String[] {"*|~", "*^~", " |~"});
    89. Dye d = new Dye();
    90. d.setColor(DyeColor.WHITE);
    91. shaped.setIngredient('^', d);
    92. shaped.setIngredient('*', Material.DIAMOND);
    93. shapeless.addIngredient(d);
    94. shapeless.addIngredient(2, Material.DIAMOND);
    95. break;
    96. default:
    97. }
    98.  
    99. shaped.setIngredient(' ', Material.AIR);
    100. shaped.setIngredient('|', Material.STICK);
    101. shaped.setIngredient('~', Material.STRING);
    102.  
    103. Bukkit.addRecipe(shaped);
    104. Bukkit.addRecipe(shapeless);
    105.  
    106.  
    107. }
     
  2. Your problem is the ingredients, you set the ingredient char to '^', but you don't use it at all.
     
  3. Offline

    PsycoNova


    I looked at all of them and the middle row middle column on every rec has the '^' char. They usually look something like "|^~". Unless I'm misunderstanding, then sorry.
     
  4. Now I see it, but about the other chars, you don't specify what material is it.
     
  5. Offline

    PsycoNova

    these? From line 99 to 101?

    shaped.setIngredient(' ', Material.AIR);
    shaped.setIngredient('|', Material.STICK);
    shaped.setIngredient('~', Material.STRING);
     
  6. Offline

    Msrules123

    First, these won't have any selected value. They need to be included in each and every cases, otherwise the recipe will not be able to be crafted, which is your exact problem. I believe this will fix it, if you follow my instructions above.
     
  7. Offline

    fireblast709

    PsycoNova you don't need to set the AIR value
     
    PsycoNova likes this.
Thread Status:
Not open for further replies.

Share This Page