Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.halestormxv.item.gifts;
- import java.util.List;
- import com.halestormxv.creativetabs.CelestialCraft_creativeTabs;
- import com.halestormxv.entity.celestialBolt;
- import com.halestormxv.lib.RefStrings;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.enchantment.Enchantment;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.effect.EntityLightningBolt;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.projectile.EntityArrow;
- import net.minecraft.init.Items;
- import net.minecraft.item.EnumAction;
- import net.minecraft.item.EnumRarity;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.ChatComponentTranslation;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.world.World;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.event.entity.player.ArrowLooseEvent;
- public class leoGift extends Item
- {
- public double powerCost;
- public leoGift()
- {
- this.setMaxStackSize(1);
- this.setTextureName(RefStrings.MODID + ":leo_gift");
- this.setMaxDamage(-1);
- this.setCreativeTab(CelestialCraft_creativeTabs.tabTools);
- }
- public boolean isDamageable()
- {
- return false;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(ItemStack par1ItemStack){
- return EnumRarity.uncommon;
- }
- @Override
- public boolean hasEffect(ItemStack par1ItemStack){
- return true;
- }
- @Override
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
- {
- par3List.add("");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "An artifact from Leo, argued to be");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "one of the most powerful spirits.");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "True power is held within.");
- par3List.add("");
- par3List.add(EnumChatFormatting.UNDERLINE + "Calls down Celestial Power on surrounding enemies.");
- if (par1ItemStack.stackTagCompound != null)
- {
- String owner = par1ItemStack.stackTagCompound.getString("Artifact Bound To: ");
- int cooldownRemain = par1ItemStack.stackTagCompound.getInteger("Cooldown: ");
- if (owner.equals(par2EntityPlayer.getDisplayName()))
- {
- par3List.add((EnumChatFormatting.GREEN + "Bound To: " + owner));
- par3List.add((EnumChatFormatting.GREEN + "Cooldown: " + cooldownRemain));
- } else {
- par3List.add(EnumChatFormatting.RED + "This isn't your artifact.");
- }
- }
- }
- public double getUsageCost(EntityPlayer user)
- {
- powerCost = (float)(user.experienceLevel) / 4;
- return powerCost;
- }
- public int getMaxItemUseDuration(ItemStack itemstack)
- {
- return 72000;
- }
- public EnumAction getItemUseAction(ItemStack itemstack)
- {
- return EnumAction.block;
- }
- public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityPlayer player, int chargedTime)
- {
- int j = this.getMaxItemUseDuration(itemstack) - chargedTime;
- ArrowLooseEvent event = new ArrowLooseEvent(player, itemstack, j);
- MinecraftForge.EVENT_BUS.post(event);
- if (event.isCanceled())
- {
- return;
- }
- j = event.charge;
- if (itemstack.stackTagCompound.getInteger("Cooldown: ") == 0 )
- {
- powerCost = getUsageCost(player);
- player.addExperienceLevel((int)-powerCost);
- player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
- if (j > 400){ j = 400;}
- j = Math.round(j / 40);
- List<EntityLivingBase> targetList = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, player.boundingBox.expand(8.0F + j, 8.0F + j, 8.0F + j));
- for (EntityLivingBase targets : targetList)
- {
- if ( targets != null)
- {
- if ( targets != player )
- {
- player.worldObj.spawnEntityInWorld(new EntityLightningBolt(world, targets.posX, targets.posY, targets.posZ) );
- targets.clearActivePotions();
- world.createExplosion(targets, targets.posX, targets.posY, targets.posZ, 3.2F + (j / 2), true);
- targets.setHealth(targets.getHealth() - j);
- world.playSoundAtEntity(targets, RefStrings.MODID + ":leo_gift_execute", 1.4F, 1.0F);
- }
- }
- }
- itemstack.stackTagCompound.setInteger("Cooldown: ", 300);
- }else{
- player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74This item is on cooldown."));
- }
- }
- public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
- {
- if ( player.capabilities.isCreativeMode || (player.experienceLevel > 8) )
- {
- if (!itemstack.hasTagCompound())
- {
- itemstack.setTagCompound(new NBTTagCompound());
- itemstack.stackTagCompound.setString("Artifact Bound To: ", player.getDisplayName());
- itemstack.stackTagCompound.setInteger("Cooldown: ", 0);
- }
- else if (itemstack.hasTagCompound())
- {
- String owner = itemstack.stackTagCompound.getString("Artifact Bound To: ");
- if (!owner.equals(player.getDisplayName()))
- {
- player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You are not the owner of this Artifact!"));
- return itemstack;
- }
- }
- if (itemstack.stackTagCompound.getInteger("Cooldown: ") == 0 )
- {
- player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
- world.playSoundAtEntity(player, RefStrings.MODID + ":leo_gift_cast", 1.0F, 1.0F);
- }else{
- player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74This item is on cooldown."));
- }
- }else{
- player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74Not have enough Celestial Power to use Artifact."));
- }
- return itemstack;
- }
- public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5)
- {
- EntityPlayer player = (EntityPlayer) entity;
- ItemStack equipped = player.getCurrentEquippedItem();
- if (itemStack.hasTagCompound() && itemStack.stackTagCompound.getInteger("Cooldown: ") > 0)
- {
- int cooldownCounter = itemStack.stackTagCompound.getInteger("Cooldown: ") - 1;
- itemStack.stackTagCompound.setInteger("Cooldown: ", cooldownCounter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement