Crafting with 'Custom Items'

Discussion in 'Plugin Development' started by Bradley Hilton, Apr 29, 2013.

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

    Bradley Hilton

    I'm wanting players to be able to craft "custom items" through the usage of other "custom items", I'm using that term liberally because the so called custom items are just say wheat with metadata attached to it that has the item name colored and the name is changed. My question is this, and I'm not sure if this is vanilla behavior, but is it possible to use items with metadata attached in recipes? Because I can't seem to get it to work with Items with MetaData attached but I can with Items without any Metadata attached..
     
  2. Offline

    zeddio

    You can listen on on CraftItemEvent and when he craft your 'custom item' you just replace it with the item w/ metadata.
    Will this work? :)
    PHP:
    private Recipe recipe;
     
        @
    Override
        
    public void onEnable(){
         
            
    recipe Bukkit.getRecipesFor(new ItemStack(Material.ANVIL)).get(0);//PUT YOUR RECIPE HERE
                                                                                // this is a example
         
        
    }
     
        @
    EventHandler
        
    public void onPlayerCraft(CraftItemEvent event){
         
            if(
    event.getRecipe() == recipe){
             
                if(
    event.getCurrentItem().getType() == Material.WHEAT){
                    
    event.setCurrentItem(new ItemStack(Material.AWSOME_WHEAT));
                }
             
            }
         
        }
     
  3. Offline

    Bradley Hilton

    Yeah that won't work because that event nor the PrepareItemCraftEvent is ever called...

    --edit--
    Seems like it only happens with plugin added meta-data and not anvil added meta-data because I can rename some wheat in the anvil and use it the same as I would regular wheat, but any plugin touched wheat that has custom meta-data (just display-name) it doesn't work and I can't create bread with three of them..
     
Thread Status:
Not open for further replies.

Share This Page