Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ilan321.transmutation.items;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.world.World;
- import java.util.List;
- /**
- * Created by Ilan on 9/30/14.
- */
- public class BasicTransmutationStone extends CommonItem {
- public BasicTransmutationStone()
- {
- super();
- this.maxStackSize = 1;
- this.setUnlocalizedName("basicStone");
- }
- @Override
- public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack)
- {
- return false;
- }
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player,
- List list, boolean par4)
- {
- if (stack.stackTagCompound != null)
- {
- String owner = stack.stackTagCompound.getString("owner");
- Integer uses = stack.stackTagCompound.getInteger("uses");
- list.add("Owner: " + owner);
- if (uses > 95)
- {
- list.add("Uses: " + EnumChatFormatting.GREEN + uses);
- }
- if ((uses > 63) && (uses < 96))
- {
- list.add("Uses: " + EnumChatFormatting.YELLOW + uses);
- }
- if ((uses < 64) && (uses > 2))
- {
- list.add("Uses: " + EnumChatFormatting.RED + uses);
- }
- if (uses.equals(1))
- {
- list.add("Uses: " + EnumChatFormatting.DARK_RED + uses);
- }
- }
- }
- public void removeItem(EntityPlayer ep, ItemStack item)
- {
- IInventory inv = ep.inventory;
- for (int i = 0; i < inv.getSizeInventory(); i++)
- {
- if (inv.getStackInSlot(i) != null)
- {
- ItemStack j = inv.getStackInSlot(i);
- if (j.getItem() != null && j.getItem() == item.getItem())
- {
- inv.setInventorySlotContents(i, null);
- return;
- }
- }
- }
- }
- @Override
- public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
- {
- if (stack.stackTagCompound != null)
- {
- stack.stackTagCompound.setInteger("uses", stack.stackTagCompound.getInteger("uses") - 1);
- if (stack.stackTagCompound.getInteger("uses") < 1)
- {
- removeItem(player, stack);
- }
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement