Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lyesdoesmods.items.classes;
- import java.util.List;
- import java.util.Random;
- import com.lyesdoesmods.items.LinguamInterpresItem;
- import com.lyesdoesmods.lib.ExtraFunctions;
- import com.lyesdoesmods.lib.ReferenceVariables;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.world.World;
- import net.minecraft.world.WorldSettings.GameType;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- public class FortitudoMarsClass extends Item{
- int currIcon = 0, waitTime = 20, currTime = 0;
- @Override
- public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) {
- if(!itemStack.hasTagCompound())
- {
- NBTTagCompound tagCompound = new NBTTagCompound();
- tagCompound.setBoolean("fMarsIsActive", false);
- tagCompound.setInteger("fMarsCurrIcon", 0);
- tagCompound.setInteger("fMarsCurrTime", 0);
- itemStack.setTagCompound(tagCompound);
- }
- if(entity instanceof EntityPlayer)
- {
- EntityPlayer player = (EntityPlayer)entity;
- if(player != null)
- {
- if(itemStack.getTagCompound().getInteger("fMarsCurrTime") >= waitTime)
- {
- if(itemStack.getTagCompound().getInteger("fMarsCurrIcon") > 0 && itemStack.getTagCompound().getBoolean("fMarsIsActive"))
- {
- NBTTagCompound tagCompound = itemStack.getTagCompound();
- tagCompound.setInteger("fMarsCurrIcon", itemStack.getTagCompound().getInteger("fMarsCurrIcon") - 1);
- itemStack.setTagCompound(tagCompound);
- }
- else
- {
- NBTTagCompound tagCompound = itemStack.getTagCompound();
- tagCompound.setInteger("fMarsCurrIcon", 0);
- tagCompound.setBoolean("fMarsIsActive", false);
- itemStack.setTagCompound(tagCompound);
- }
- NBTTagCompound tagCompound = itemStack.getTagCompound();
- tagCompound.setInteger("fMarsCurrTime", 0);
- itemStack.setTagCompound(tagCompound);
- }
- if(itemStack.getTagCompound().getInteger("fMarsCurrIcon") > 0)
- {
- player.heal(100f);
- }
- }
- }
- NBTTagCompound tagCompound = itemStack.getTagCompound();
- tagCompound.setInteger("fMarsCurrTime", itemStack.getTagCompound().getInteger("fMarsCurrTime") + 1);
- itemStack.setTagCompound(tagCompound);
- }
- boolean isCreative = false;
- @Override
- public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
- boolean get;
- get = itemStack.getTagCompound().getBoolean("fMarsIsActive");
- isCreative = false;
- //IsCreativeVariableSet
- if(player instanceof EntityPlayerMP)
- {
- EntityPlayerMP pMP = (EntityPlayerMP)player;
- isCreative = pMP.theItemInWorldManager.getGameType() == GameType.CREATIVE;
- }
- if(!get == true && (player.experienceLevel >= 30 || isCreative))
- {
- if(!isCreative)
- player.addExperienceLevel(-30);
- NBTTagCompound tagCompound = itemStack.getTagCompound();
- tagCompound.setInteger("fMarsCurrIcon", 10);
- tagCompound.setBoolean("fMarsIsActive", true);
- itemStack.setTagCompound(tagCompound);
- get = true;
- }
- else
- {
- NBTTagCompound tagCompound = itemStack.getTagCompound();
- tagCompound.setBoolean("fMarsIsActive", false);
- itemStack.setTagCompound(tagCompound);
- get = false;
- }
- player.swingItem();
- return super.onItemRightClick(itemStack, world, player);
- }
- Random rand = new Random();
- int informationTickUpdate = 0;
- String currentString = "";
- String extraString = "";
- @Override
- public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
- list.add("\u00A78" + currentString);
- list.add("\u00A78" + extraString);
- informationTickUpdate++;
- if(player.inventory.hasItem(LinguamInterpresItem.item))
- {
- for(int i = 0; i < player.inventory.getSizeInventory(); i++)
- {
- if(player.inventory.getStackInSlot(i) != null)
- if(player.inventory.getStackInSlot(i).hasTagCompound())
- {
- if(player.inventory.getStackInSlot(i).getTagCompound().hasKey("linguaIsActive"))
- {
- if(player.inventory.getStackInSlot(i).getTagCompound().getBoolean("linguaIsActive") == true)
- {
- currentString = "Strength of Mars";
- extraString = "Usage: 30XP";
- return;
- }
- }
- }
- }
- }
- if(informationTickUpdate > 5)
- {
- currentString = ExtraFunctions.generateRandomString(rand, 8) + " " + ExtraFunctions.generateRandomString(rand, 2) + " " + ExtraFunctions.generateRandomString(rand, 4);
- extraString = ExtraFunctions.generateRandomString(rand, 6) + " " + ExtraFunctions.generateRandomString(rand, 4);
- informationTickUpdate = 0;
- }
- super.addInformation(itemStack, player, list, par4);
- }
- IIcon[] iconArray;
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister iconRegister)
- {
- iconArray = new IIcon[11];
- iconArray[0] = iconRegister.registerIcon(ReferenceVariables.MODID + ":FortitudoMarsItemOff");
- for(int i = 1; i <= 10; i++)
- {
- iconArray[i] = iconRegister.registerIcon(ReferenceVariables.MODID + ":FortitudoMarsItem" + String.valueOf(i));
- }
- }
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIconIndex(ItemStack stack) {
- int output = 0;
- if(stack.hasTagCompound())
- {
- output = stack.stackTagCompound.getInteger("fMarsCurrIcon");
- }
- return iconArray[output];
- }
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
- int output = 0;
- if(stack.hasTagCompound())
- {
- output = stack.stackTagCompound.getInteger("fMarsCurrIcon");
- }
- return iconArray[output];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement