Advertisement
Guest User

Untitled

a guest
Oct 21st, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. package com.halestormxv.item;
  2.  
  3. import java.util.List;
  4.  
  5. import com.halestormxv.creativetabs.CelestialCraft_creativeTabs;
  6. import com.halestormxv.entity.celestialBolt;
  7. import com.halestormxv.lib.RefStrings;
  8.  
  9. import cpw.mods.fml.relauncher.Side;
  10. import cpw.mods.fml.relauncher.SideOnly;
  11. import net.minecraft.client.renderer.texture.IIconRegister;
  12. import net.minecraft.creativetab.CreativeTabs;
  13. import net.minecraft.enchantment.Enchantment;
  14. import net.minecraft.enchantment.EnchantmentHelper;
  15. import net.minecraft.entity.Entity;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.entity.projectile.EntityArrow;
  18. import net.minecraft.entity.projectile.EntitySnowball;
  19. import net.minecraft.init.Items;
  20. import net.minecraft.item.EnumAction;
  21. import net.minecraft.item.EnumRarity;
  22. import net.minecraft.item.Item;
  23. import net.minecraft.item.ItemStack;
  24. import net.minecraft.item.ItemSword;
  25. import net.minecraft.nbt.NBTTagCompound;
  26. import net.minecraft.item.Item.ToolMaterial;
  27. import net.minecraft.potion.Potion;
  28. import net.minecraft.potion.PotionEffect;
  29. import net.minecraft.util.ChatComponentTranslation;
  30. import net.minecraft.util.EnumChatFormatting;
  31. import net.minecraft.util.IIcon;
  32. import net.minecraft.world.World;
  33. import net.minecraftforge.common.MinecraftForge;
  34. import net.minecraftforge.event.entity.player.ArrowLooseEvent;
  35. import net.minecraftforge.event.entity.player.ArrowNockEvent;
  36.  
  37. public class celestialGunblade extends ItemSword
  38. {
  39. public double powerCost;
  40.  
  41. public celestialGunblade(ToolMaterial mat)
  42. {
  43. super(mat);
  44. this.setMaxStackSize(1);
  45. this.setTextureName(RefStrings.MODID + ":celestial_gunblade");
  46. this.setMaxDamage(1000);
  47. this.setCreativeTab(CelestialCraft_creativeTabs.tabCombat);
  48.  
  49. }
  50.  
  51. public double getGunbladeCost(EntityPlayer shooter)
  52. {
  53. powerCost = (float)(shooter.experienceLevel) / 3;
  54. return powerCost;
  55. }
  56.  
  57. @Override
  58. @SideOnly(Side.CLIENT)
  59. public EnumRarity getRarity(ItemStack par1ItemStack){
  60. return EnumRarity.uncommon;
  61. }
  62.  
  63. @Override
  64. public boolean hasEffect(ItemStack par1ItemStack){
  65. return true;
  66. }
  67.  
  68.  
  69. public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  70. {
  71. if ( par3EntityPlayer.capabilities.isCreativeMode || (par3EntityPlayer.experienceLevel > 8) )
  72. {
  73. if (!par1ItemStack.hasTagCompound())
  74. {
  75. par1ItemStack.setTagCompound(new NBTTagCompound());
  76. par1ItemStack.stackTagCompound.setString("Gunblade Bound To: ", par3EntityPlayer.getDisplayName());
  77. par1ItemStack.stackTagCompound.setInteger("Cooldown: ", 0);
  78. }
  79. else if (par1ItemStack.hasTagCompound())
  80. {
  81. String owner = par1ItemStack.stackTagCompound.getString("Gunblade Bound To: ");
  82. if (!owner.equals(par3EntityPlayer.getDisplayName()))
  83. {
  84. par3EntityPlayer.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You are not the owner of this gunblade!"));
  85. int currentDamage = par1ItemStack.getMaxDamage();
  86. par1ItemStack.damageItem(currentDamage, par3EntityPlayer);
  87. return par1ItemStack;
  88. }
  89. }
  90.  
  91. if (par1ItemStack.stackTagCompound.getInteger("Cooldown: ") == 0 )
  92. {
  93. powerCost = getGunbladeCost(par3EntityPlayer);
  94. par2World.playSoundAtEntity(par3EntityPlayer, RefStrings.MODID + ":gunblade_fire", 1.0F, 1.0F);
  95. par3EntityPlayer.addExperienceLevel((int)-powerCost);
  96. par3EntityPlayer.swingItem();
  97. if (!par2World.isRemote){par2World.spawnEntityInWorld(new celestialBolt(par2World, par3EntityPlayer)); par1ItemStack.stackTagCompound.setInteger("Cooldown: ", 180); }
  98. }else{
  99. par3EntityPlayer.addChatComponentMessage(new ChatComponentTranslation ("\u00A74This item is on cooldown."));
  100. }
  101. }
  102. else
  103. {
  104.  
  105. par3EntityPlayer.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You do not have enough Celestial Power to fire this weapon."));
  106. }
  107. par1ItemStack.damageItem(10, par3EntityPlayer);
  108. return par1ItemStack;
  109. }
  110.  
  111. public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5)
  112. {
  113. EntityPlayer player = (EntityPlayer) entity;
  114. ItemStack equipped = player.getCurrentEquippedItem();
  115. if (itemStack.hasTagCompound() && itemStack.stackTagCompound.getInteger("Cooldown: ") > 0)
  116. {
  117. int cooldownCounter = itemStack.stackTagCompound.getInteger("Cooldown: ") - 1;
  118. itemStack.stackTagCompound.setInteger("Cooldown: ", cooldownCounter);
  119. }
  120. }
  121.  
  122.  
  123. @Override
  124. public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
  125. {
  126. par3List.add("");
  127. par3List.add(EnumChatFormatting.LIGHT_PURPLE + "The Celestial Gunblade is a hybrid weapon.");
  128. par3List.add(EnumChatFormatting.LIGHT_PURPLE + "It has the ability to harness your Celestial Power");
  129. par3List.add(EnumChatFormatting.LIGHT_PURPLE + "and focus into a projectile for a proportional");
  130. par3List.add(EnumChatFormatting.LIGHT_PURPLE + "ranged attack based on distance traveled.");
  131. par3List.add(EnumChatFormatting.LIGHT_PURPLE + "Alternativly it can be used as a melee sword.");
  132. par3List.add("");
  133. if (par1ItemStack.stackTagCompound != null) {
  134. String owner = par1ItemStack.stackTagCompound.getString("Gunblade Bound To: ");
  135. int cooldownRemain = par1ItemStack.stackTagCompound.getInteger("Cooldown: ");
  136. if (owner.equals(par2EntityPlayer.getDisplayName()))
  137. {
  138. par3List.add((EnumChatFormatting.GREEN + "Bound To: " + owner));
  139. par3List.add((EnumChatFormatting.GREEN + "Cooldown: " + cooldownRemain));
  140. } else {
  141. par3List.add(EnumChatFormatting.RED + "Not Your Gunblade");
  142. }
  143. }
  144. }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement