Creating Custom Item?

Discussion in 'Plugin Development' started by Shironomia, May 14, 2015.

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

    Shironomia

    Hello all,
    I've been searching and trying to create Custom Items all day long, but just can't find anything. :/
    I actually found many results, but those only cover how to take an Item, and change it.
    What I want is to completely add a new Item into Minecraft, with own ID and everything else.
    I know that it won't work that easily if I don't add it Client-Side aswell, but that's not hard. That's actually the easy part for me.
    My problem is that I can't find any way to add an item server-side.
    Any Ideas?
    Thanks.
     
  2. Offline

    Gater12

    @Shironomia
    I don't believe there is any way with Bukkit's software.
     
  3. Offline

    ForsakenRealmz

    To add new items to Minecraft you would have to use a mod.
     
  4. Offline

    Reynergodoy

    wtf is that, adding new itens on minecraft using a non-modded-client?
     
  5. Offline

    Agentleader1

    Impossible with Bukkit, only possible with mods.

    However an alternate is to create Custom Items that have names instead, and you can use a boolean to track the name if it's the custom item.

    Create a new class:
    Code:
    package com.Agentleader1.DarkThunder.Listeners.Managers;
    
    import java.util.List;
    
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    
    public class CustomItemManager {
    
        public static ItemStack customItem(ItemStack item, String displayName, List<String> lore){
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(displayName);
            meta.setLore(lore);
            item.setItemMeta(meta);
           
            return item;
        }
        public static ItemStack customItem(Player player, ItemStack item, String displayName, List<String> lore){
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName(displayName);
            meta.setLore(lore);
            item.setItemMeta(meta);
            player.updateInventory();
            return item;
        }
        public static boolean isCustomItem(ItemStack item){
            if(item.hasItemMeta()){
                if((item.getItemMeta().hasDisplayName()) ||
                        item.getItemMeta().hasLore()){
                    return true;
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
        public static boolean isCustomItem(ItemStack item, String displayName){
            if(item.hasItemMeta()){
                if((item.getItemMeta().hasDisplayName())){
                    if(item.getItemMeta().getDisplayName().equalsIgnoreCase(displayName)){
                        return true;
                    }else{
                        return false;
                    }
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
        public static boolean isCustomItem(ItemStack item, List<String> lore){
            if(item.hasItemMeta()){
                if((item.getItemMeta().hasLore())){
                    if(item.getItemMeta().getLore().equals(lore)){
                        return true;
                    }else{
                        return false;
                    }
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
        public static boolean isCustomItem(ItemStack item, String displayName, List<String> lore){
            if(item.hasItemMeta()){
                if((item.getItemMeta().hasDisplayName()) &&
                        item.getItemMeta().hasLore()){
                    if(item.getItemMeta().getDisplayName().equalsIgnoreCase(displayName) &&
                            item.getItemMeta().getLore().equals(lore)){
                        return true;
                    }else{
                        return false;
                    }
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
    }
    
    To Use this (in other classes):
    Code:
    ItemStack anyItem = CustomItemManager.customItem(new ItemStack(1), "Swag stone"); //make a new custom item.
    
    boolean isCustom = CustomItemManager.isCustomItem(anyItem, "Swag Stone"); //seeing if an itemstack has the name "Swag Stone"
     
  6. ew
     
  7. Offline

    JoelyBob

    Dude... Seriously? That is the closest thing you'll get to a custom item (with ID and everything else). If you knew anything about Minecraft in the developers way, it is impossible. Don't get upset when you don't get what you want.
     
  8. Pardon?
     
  9. Offline

    JoelyBob

    Oh right... What I meant was "Learn something about Java and developing Minecraft PLUGINS (not mods) before you throw something out that is impossible. You can't add a whole new item into Minecraft. You can take another item, rename it, make it do custom things, but you'll have a hard time creating a whole new item.

    Secondly, don't say "ew" when someone is trying to help you. @Agentleader1 actually took time to write that up to help you with the closest thing you can get to a custom item. He could've just said nothing and not help you at all. That can be taken in quite an offensive way.

    Next time, simply say "I don't quite understand, could you elaborate?". That "ew" was completely unneeded. If you're looking for someone to create some custom items for you, I suggest looking at the couple thousand tutorials on the internet, or ask on the Plugin Requests thread. For example, with the correct information about it, I could do it, but not add a whole new item... :/ So next time, think about what you're saying before you say it, okay?

    All good.
     
    Agentleader1 likes this.
  10. Offline

    TheDiamond06

    @Shironomia Plugins can only do things that are already installed into minecraft. You cannot add ANYTHING new into bukkit plugins. Use a mod to add new things, that is what mods are for. For changing minecraft. You can make a custom item by creating an itemstack with custom ItemMeta, but not a totally different item with a different texture.
     
    JoelyBob and Agentleader1 like this.
  11. I think you're getting confused, I'm not OP..
     
  12. Offline

    JoelyBob

    You aren't overpowered...? or you aren't operator? What do you mean by OP. I'm not getting confused... I'm proving the point that maybe you replying that to @Agentleader1 isn't the best thing to do.
     
  13. original poster.
     
  14. Offline

    JoelyBob

    Or did you get a BukkitDEV username? ;) Either way, you still said 'ew'.
     
  15. Offline

    dlange

    @JoelyBob He wasn't the guy who made the post he means... But i agree it is out of order, trolling or not, don't just comment random things on here where people are trying to help someone else. They may not know as much as you, and they may be a slower learner than you, doing what you did can destroy people's confidence and the person who you aim it at might not help people again if that is how he/she/other is being treated when trying to help.
     
  16. Offline

    NathanWolf

    I would suggest the closest thing you can get to custom items is custom NBT tags on said items. Very similar to the lore/display name approach, but more or less hacky depending on your perspective.

    More hacky: It will involve using NMS code, and is not supported by the API.

    Less hacky: Using display text to identify items is a slow, roundabout way of checking for custom items that no one in their right mind would ever use if there was a good alternative (and sadly there really isn't).
     
  17. Offline

    SirMonkeyFood

    Skulls! Skulls? 1.8 Skulls? Anyone? Have a custom-named player head and you could like, make some stuff outta it, and make a sweet texture. Check it: http://heads.freshcoal.com/maincollection.php Ok, I'll go sit down Somewhere.
     
Thread Status:
Not open for further replies.

Share This Page