123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package me.km.api;
- import net.minecraft.block.Block;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- public class ItemStackBuilder
- {
- private final ItemStack stack;
-
- public ItemStackBuilder(Block b, int amount)
- {
- stack = new ItemStack(b, amount);
- }
-
- public ItemStackBuilder(Block b, int amount, int meta)
- {
- stack = new ItemStack(b, amount, meta);
- }
-
- public ItemStackBuilder(Item i, int amount)
- {
- stack = new ItemStack(i, amount);
- }
-
- public ItemStackBuilder(Item i, int amount, int meta)
- {
- stack = new ItemStack(i, amount, meta);
- }
-
- public ItemStackBuilder(ItemStack stack, int amount)
- {
- this.stack = stack.copy();
- this.stack.setCount(amount);
- }
- public ItemStack build()
- {
- return stack;
- }
-
- public void drop(World w, BlockPos l)
- {
- Block.spawnAsEntity(w, l, stack);
- }
-
- public ItemStackBuilder setName(String name)
- {
- stack.setStackDisplayName(name);
- return this;
- }
-
- public ItemStackBuilder addToName(String name)
- {
- stack.setStackDisplayName(stack.getDisplayName() + name);
- return this;
- }
-
- public ItemStackBuilder addLore(String line)
- {
- //TODO
- return this;
- }
-
- public ItemStackBuilder addLimitedLore(String whole, int limit, String addition)
- {
- //TODO
- /*ItemMeta meta = stack.getItemMeta();
- meta.setLore(Utils.buildLimitedLore(whole, limit, addition));
- stack.setItemMeta(meta);*/
- return this;
- }
-
- public ItemStackBuilder addLimitedLore(String whole, String addition)
- {
- return addLimitedLore(whole, 25, addition);
- }
-
- public ItemStackBuilder hideTags()
- {
- //TODO
- /*stack.setTagCompound(nbt);
- ItemMeta meta = stack.getItemMeta();
- meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
- meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
- meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- stack.setItemMeta(meta);*/
- return this;
- }
-
- public ItemStackBuilder addGlow()
- {
- //TODO
- //stack.addUnsafeEnchantment(Enchantment.LUCK, 1);
- return this;
- }
- }
|