Setting custom names + lores in custom recipes

Discussion in 'Plugin Development' started by CaLxCyMru, Jun 23, 2013.

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

    CaLxCyMru

    Hello there, I cant see why this is not working, Its giving the error on the line '
    Code:java
    1. ShapedRecipe normalWoodSword = new ShapedRecipe(normalWS.shape(" % "," % "," & ").setIngredient('%', Material.WOOD).setIngredient('&', Material.STICK);

    Here is the whole code -

    '
    Code:java
    1. ItemStack normalWS = new ItemStack(Material.WOOD_SWORD);
    2. ItemMeta im = normalWS.getItemMeta();
    3. im.setDisplayName(ChatColor.RED + "Repaired Wood Sword");
    4. List<String> lore1 = new ArrayList<String>();
    5. lore1.add(ChatColor.YELLOW + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "TYPE: " + ChatColor.RESET + "" + ChatColor.RED + "" + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Weapon");
    6. im.setLore(lore1);
    7. normalWS.setItemMeta(im);
    8. ShapedRecipe normalWoodSword = new ShapedRecipe(normalWS.shape(" % "," % "," & ").setIngredient('%', Material.WOOD).setIngredient('&', Material.STICK);
    9. ShapedRecipe woodAxe = new ShapedRecipe(new ItemStack(Material.WOOD_AXE)).shape("%%%","%& "," & ").setIngredient('%', Material.WOOD).setIngredient('&', Material.STICK);
     
  2. Offline

    travja

    Ummm... well.. I would say that maybe you need a symbol for the air... but maybe not.. And also, what is the error?
     
  3. Offline

    CaLxCyMru

    Its saying
    I get the error on the .shape part of the block of code

    http://puu.sh/3mD8W.png
     
  4. Offline

    travja

    CaLxCyMru You can't set the shape of an ItemStack What exactly are you trying to accomplish with this plugin?
     
  5. Offline

    CaLxCyMru

    travja

    I want to make it so when you craft 2 Sword together, You get a item that has a name and custom lore
     
  6. Offline

    travja

    CaLxCyMru then you are doing pretty much everything wrong. This is what I did, tested and confirmed:
    Code:java
    1. ShapelessRecipe re = new ShapelessRecipe(new ItemStack(WOOD_SWORD)).addIngredient(Material.WOOD_SWORD).addIngredient(Material.WOOD_SWORD);

    And the listener
    Code:java
    1. @EventHandler(priority = EventPriority.MONITOR)
    2. public void onCraft(PrepareItemCraftEvent event){
    3. Recipe r = event.getRecipe();
    4. if(r instanceof ShapelessRecipe){
    5. ShapelessRecipe sr = (ShapelessRecipe) r;
    6. if(sr.getIngredientList().equals(re.getIngredientList())){
    7. ItemStack sword = sr.getResult();
    8. ItemMeta sm = sword.getItemMeta();
    9. sm.setDisplayName(ChatColor.RED + "Repaired wood sword");
    10. List<String> lore1 = new ArrayList<String>();
    11. lore1.add(ChatColor.YELLOW + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "TYPE: " + ChatColor.RESET + "" + ChatColor.RED + "" + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Weapon");
    12. sm.setLore(lore1);
    13. sword.setItemMeta(sm);
    14. event.getInventory().setResult(sword);
    15. }
    16. }
    17. }


    Have fun with it! You really don't even need to add a recipe as default minecraft has one for crafting swords together, all you need to do is check if the ingredients are 2 wood swords, then change the name and things.
     
Thread Status:
Not open for further replies.

Share This Page