Solved Renaming items when crafted?

Discussion in 'Plugin Development' started by theCodeBro, May 7, 2013.

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

    theCodeBro

    I'm trying to make a dagger. I added a crafting recipe that will give you a stone sword. Then, using CraftItemEvent, I tried to make it so if you craft it it will get sharpness and it will be renamed to Dagger. But getting the recipe right doesn't work. Does anybody know how to fix this?

    Code:

    Code:
    ShapedRecipe dagger = new ShapedRecipe(new ItemStack(Material.STONE_SWORD))
    .shape(" ^ "," ^ "," & ")
    .setIngredient('^', Material.STONE)
    .setIngredient('&', Material.STICK);
     
    @EventHandler
        public void onItemCraft(CraftItemEvent event){
            if(event.getRecipe().equals(dagger)){
                ItemStack d = event.getCurrentItem();
                setName(d, ChatColor.WHITE+"Dagger");
                ench(d, 2, Enchantment.DAMAGE_ALL);
            }
    }
     
  2. Offline

    theCodeBro

  3. Offline

    kasszz

  4. Offline

    socram8888

  5. Offline

    Burnett1

    Make a new Itemstack set its item meta to whatever you want and then create the recipe with it instead of a new ItemStack.
     
  6. Offline

    theCodeBro

    thnx that works perfect xD
     
Thread Status:
Not open for further replies.

Share This Page