Home›Java›Mods›ItemBuilder - Simple & Effective
ModsJava

ItemBuilder - Simple & Effective

Java mod listed for Minecraft 1.8–1.12. Download on the author's site.

⬇ Download on Spigot
Features:
Todo:
Sourcecode:

​
Code (Java):
public class ItemBuilder {

    private ItemStack itemStack ;
    private ItemMeta itemMeta ;

    public ItemBuilder ( Material material, short subID ) {
        itemStack = new ItemStack ( material, 1 , subID ) ;
        itemMeta = itemStack. getItemMeta ( ) ;
    }

    public ItemBuilder ( Material material ) {
        this ( material, ( short ) 0 ) ;
    }

    public ItemBuilder setAmount ( int amount ) {
        itemStack. setAmount ( amount ) ;
        return this ;
    }

    public ItemBuilder setName ( String name ) {
        itemMeta. setDisplayName ( name ) ;
        return this ;
    }

    public ItemBuilder setUnbreakable ( boolean state ) {
        itemMeta. spigot ( ) . setUnbreakable ( state ) ;
        return this ;
    }

    public ItemBuilder setLore ( String ... lore ) {
        itemMeta. setLore ( Arrays . asList ( lore ) ) ;
        return this ;
    }

    public ItemBuilder setLore ( List < String > lore ) {
        itemMeta. setLore ( lore ) ;
        return this ;
    }

    public ItemBuilder setGlow ( ) {
        if ( itemMeta. getEnchants ( ) . isEmpty ( ) ) {
            itemMeta. addItemFlags ( ItemFlag. HIDE_ENCHANTS ) ;
            itemMeta. addEnchant ( Enchantment. OXYGEN , 0 , true ) ;
        }
        return this ;
    }

    public ItemBuilder setSkullOwner ( String skullOwner ) {
        if ( itemStack. getType ( ) . equals ( Material. SKULL_ITEM ) ) {
            SkullMeta skullMeta = ( ( SkullMeta ) itemMeta ) ;
            skullMeta. setOwner ( skullOwner ) ;
        }
        return this ;
    }

    public ItemBuilder addEnchantment ( Enchantment enchantment, int level, boolean unsafe ) {
        itemMeta. addEnchant ( enchantment, level, unsafe ) ;
        return this ;
    }

    public ItemBuilder addEnchantments ( Map < Enchantment, Integer > enchantments, boolean unsafe ) {
        for ( Enchantment current : enchantments. keySet ( ) )
            itemMeta. addEnchant ( current, enchantments. get ( current ) , unsafe ) ;
        return this ;
    }

    public ItemBuilder setBannerColor ( DyeColor color ) {
        try {
            BannerMeta bannerMeta = ( ( BannerMeta ) itemMeta ) ;
            bannerMeta. setBaseColor ( color ) ;
        } catch ( Exception exception ) {
            System . out . println ( "Can't change banner color" + exception ) ;
        }
        return this ;
    }

    public ItemBuilder setWoolColor ( DyeColor color ) {
        if ( itemStack. getType ( ) . equals ( Material. WOOL ) ) {
            //replace this to color.getDyeData(); when you want to use 1a higher version
            itemStack. setDurability ( color. getData ( ) ) ;
        }
        return this ;
    }

    public ItemBuilder setLeatherColor ( Color color ) {
        try {
            LeatherArmorMeta leatherArmorMeta = ( ( LeatherArmorMeta ) itemMeta ) ;
            leatherArmorMeta. setColor ( color ) ;
        } catch ( Exception exception ) {
            System . out . println ( "Can't change leather color" + exception ) ;
        }
        return this ;
    }

    public ItemBuilder setDurability ( int durability ) {
        itemStack. setDurability ( ( short ) durability ) ;
        return this ;
    }

    public ItemBuilder addFlag ( ItemFlag itemFlag ) {
        itemMeta. addItemFlags ( itemFlag ) ;
        return this ;
    }

    public ItemBuilder setItemMeta ( ItemMeta itemMeta ) {
        itemStack. setItemMeta ( itemMeta ) ;
        return this ;
    }

    public ItemStack toItemStack ( ) {
        itemStack. setItemMeta ( itemMeta ) ;
        return itemStack ;
    }

}
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

ItemBuilder - Simple & Effective is a free Minecraft Java mod. Compatible with Minecraft 1.8, 1.12. Downloaded 187 times (via Spigot). Download it and open it directly in the game.

Explore more