Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Morpheus420.mortem;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.item.Item;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.world.World;
- import java.util.List;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class matterJar extends Item
- {
- private static final int maxSouls = 5000;
- public matterJar()
- {
- super();
- this.setMaxStackSize(1);
- }
- @Override
- public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
- {
- if (hasSoulsTag(itemStackIn))
- {
- if (itemStackIn.getTagCompound().getInteger("storedSouls") + 100 <= maxSouls)
- itemStackIn.getTagCompound().setInteger("storedSouls", itemStackIn.getTagCompound().getInteger("storedSouls") + 100);
- else
- itemStackIn.getTagCompound().setInteger("storedSouls", maxSouls);
- }
- else
- {
- itemStackIn.setTagCompound(new NBTTagCompound());
- itemStackIn.getTagCompound().setInteger("storedSouls", 100);
- }
- return itemStackIn;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
- {
- if (hasSoulsTag(stack))
- tooltip.add(stack.getTagCompound().getInteger("storedSouls") + " : " + maxSouls);
- else
- tooltip.add("0 : " + maxSouls);
- }
- private boolean hasSoulsTag(ItemStack stack)
- {
- return stack.hasTagCompound() && stack.getTagCompound().hasKey("storedSouls");
- }
- public int getStoredSouls(ItemStack stack)
- {
- if (hasSoulsTag(stack))
- return stack.getTagCompound().getInteger("storedSouls");
- else
- return 0;
- }
- public void useSouls(ItemStack stack, int amount)
- {
- if (hasSoulsTag(stack))
- stack.getTagCompound().setInteger("storedSouls", stack.getTagCompound().getInteger("storedSouls") - amount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement