Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tlhpoe.darkorigins.item;
- import java.awt.List;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.util.ChunkCoordinates;
- import net.minecraft.world.World;
- import tlhpoe.darkorigins.helper.CreativeTabHelper;
- import tlhpoe.darkorigins.util.InfoUtil;
- public class ItemExpContainer extends ItemBase
- {
- public ItemExpContainer(int id, String name)
- {
- super(id, name);
- setMaxStackSize(1);
- setUnlocalizedName(name);
- setCreativeTab(CreativeTabHelper.items);
- }
- public static void createNBT(ItemStack itemStack)
- {
- InfoUtil.print("Creating NBTTag...");
- itemStack.stackTagCompound = new NBTTagCompound();
- itemStack.stackTagCompound.setFloat("stored", 0.0F);
- itemStack.stackTagCompound.setInteger("mode", 0);
- }
- @Override
- public void onCreated(ItemStack itemStack, World world, EntityPlayer player)
- {
- createNBT(itemStack);
- }
- public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
- {
- if(itemStack.stackTagCompound == null)
- {
- createNBT(itemStack);
- }
- float amount = itemStack.stackTagCompound.getFloat("stored");
- int mode = itemStack.stackTagCompound.getInteger("mode");
- String modeD = "";
- switch(mode)
- {
- case(0):{modeD = "Deposit";}
- case(1):{modeD = "Withdraw";}
- }
- list.add("Exp Stored: " + amount);
- list.add("Mode: " + modeD);
- }
- @Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
- {
- if(itemStack.stackTagCompound == null)
- {
- createNBT(itemStack);
- }
- if(player.isSneaking())
- {
- int mode = itemStack.stackTagCompound.getInteger("mode");
- switch(mode)
- {
- case(0):{itemStack.stackTagCompound.setInteger("mode", 1);}
- case(1):{itemStack.stackTagCompound.setInteger("mode", 0);}
- }
- }
- if(!player.isSneaking())
- {
- int mode = itemStack.stackTagCompound.getInteger("mode");
- float xp = itemStack.stackTagCompound.getFloat("stored");
- switch(mode)
- {
- case(0):
- {
- if(player.experienceLevel >= 1)
- {
- player.experienceLevel--;
- itemStack.stackTagCompound.setFloat("stored", xp++);
- }
- }
- case(1):
- {
- if(xp >= 1)
- {
- player.experienceLevel++;
- itemStack.stackTagCompound.setFloat("stored", xp--);
- }
- }
- }
- }
- return itemStack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement