Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.halestormxv.item;
- 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.client.renderer.texture.IIconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.enchantment.Enchantment;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.projectile.EntityArrow;
- import net.minecraft.entity.projectile.EntitySnowball;
- 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.item.ItemSword;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.item.Item.ToolMaterial;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.ChatComponentTranslation;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.util.IIcon;
- import net.minecraft.world.World;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.event.entity.player.ArrowLooseEvent;
- import net.minecraftforge.event.entity.player.ArrowNockEvent;
- public class celestialGunblade extends ItemSword
- {
- public double powerCost;
- public celestialGunblade(ToolMaterial mat)
- {
- super(mat);
- this.setMaxStackSize(1);
- this.setTextureName(RefStrings.MODID + ":celestial_gunblade");
- this.setMaxDamage(1000);
- this.setCreativeTab(CelestialCraft_creativeTabs.tabCombat);
- }
- public double getGunbladeCost(EntityPlayer shooter)
- {
- powerCost = (float)(shooter.experienceLevel) / 3;
- return powerCost;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(ItemStack par1ItemStack){
- return EnumRarity.uncommon;
- }
- @Override
- public boolean hasEffect(ItemStack par1ItemStack){
- return true;
- }
- public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
- {
- if ( par3EntityPlayer.capabilities.isCreativeMode || (par3EntityPlayer.experienceLevel > 8) )
- {
- if (!par1ItemStack.hasTagCompound())
- {
- par1ItemStack.setTagCompound(new NBTTagCompound());
- par1ItemStack.stackTagCompound.setString("Gunblade Bound To: ", par3EntityPlayer.getDisplayName());
- par1ItemStack.stackTagCompound.setInteger("Cooldown: ", 0);
- }
- else if (par1ItemStack.hasTagCompound())
- {
- String owner = par1ItemStack.stackTagCompound.getString("Gunblade Bound To: ");
- if (!owner.equals(par3EntityPlayer.getDisplayName()))
- {
- par3EntityPlayer.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You are not the owner of this gunblade!"));
- int currentDamage = par1ItemStack.getMaxDamage();
- par1ItemStack.damageItem(currentDamage, par3EntityPlayer);
- return par1ItemStack;
- }
- }
- if (par1ItemStack.stackTagCompound.getInteger("Cooldown: ") == 0 )
- {
- powerCost = getGunbladeCost(par3EntityPlayer);
- par2World.playSoundAtEntity(par3EntityPlayer, RefStrings.MODID + ":gunblade_fire", 1.0F, 1.0F);
- par3EntityPlayer.addExperienceLevel((int)-powerCost);
- par3EntityPlayer.swingItem();
- if (!par2World.isRemote){par2World.spawnEntityInWorld(new celestialBolt(par2World, par3EntityPlayer)); par1ItemStack.stackTagCompound.setInteger("Cooldown: ", 180); }
- }else{
- par3EntityPlayer.addChatComponentMessage(new ChatComponentTranslation ("\u00A74This item is on cooldown."));
- }
- }
- else
- {
- par3EntityPlayer.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You do not have enough Celestial Power to fire this weapon."));
- }
- par1ItemStack.damageItem(10, par3EntityPlayer);
- return par1ItemStack;
- }
- 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);
- }
- }
- @Override
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
- {
- par3List.add("");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "The Celestial Gunblade is a hybrid weapon.");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "It has the ability to harness your Celestial Power");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "and focus into a projectile for a proportional");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "ranged attack based on distance traveled.");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "Alternativly it can be used as a melee sword.");
- par3List.add("");
- if (par1ItemStack.stackTagCompound != null) {
- String owner = par1ItemStack.stackTagCompound.getString("Gunblade 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 + "Not Your Gunblade");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement