Guest User

bowcode1.7.2

a guest
Aug 29th, 2014
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. package com.MoreToolsNBlocks.MoreToolsNBlocksmod;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.client.renderer.texture.IIconRegister;
  6. import net.minecraft.creativetab.CreativeTabs;
  7. import net.minecraft.enchantment.Enchantment;
  8. import net.minecraft.enchantment.EnchantmentHelper;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import net.minecraft.entity.projectile.EntityArrow;
  11. import net.minecraft.init.Items;
  12. import net.minecraft.item.EnumAction;
  13. import net.minecraft.item.ItemBow;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.util.IIcon;
  16. import net.minecraft.world.World;
  17.  
  18. public class WSobow extends ItemBow {
  19.  
  20. public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"};
  21.  
  22. private static final String __OBFID = "CL_00001777";
  23.  
  24. public WSobow()
  25. {
  26. this.maxStackSize = 1;
  27. this.setMaxDamage(380);
  28. this.setCreativeTab(CreativeTabs.tabCombat);
  29. }
  30.  
  31. //Called when the player releases the use item button. Args: ItemStack, World, EntityPlayer, itemInUseCount
  32. public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
  33. {
  34. boolean var5 = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
  35.  
  36. if (var5 || par3EntityPlayer.inventory.hasItem(Items.arrow))
  37. {
  38. int var6 = this.getMaxItemUseDuration(par1ItemStack) - par4;
  39. float var7 = (float)var6 / 20.0F;
  40. var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
  41.  
  42. if ((double)var7 < 0.1D)
  43. {
  44. return;
  45. }
  46.  
  47. if (var7 > 1.0F)
  48. {
  49. var7 = 1.0F;
  50. }
  51.  
  52. EntityArrow var8 = new EntityArrow(par2World, par3EntityPlayer, var7 * 2.0F);
  53.  
  54. if (var7 == 1.0F)
  55. {
  56. var8.setIsCritical(true);
  57. }
  58.  
  59. int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack);
  60.  
  61. if (var9 > 0)
  62. {
  63. var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
  64. }
  65.  
  66. int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack);
  67.  
  68. if (var10 > 0)
  69. {
  70. var8.setKnockbackStrength(var10);
  71. }
  72.  
  73. if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0)
  74. {
  75. var8.setFire(100);
  76. }
  77.  
  78. par1ItemStack.damageItem(1, par3EntityPlayer);
  79. par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
  80.  
  81. if (var5)
  82. {
  83. var8.canBePickedUp = 2;
  84. }
  85. else
  86. {
  87. par3EntityPlayer.inventory.consumeInventoryItem(Items.arrow);
  88. }
  89.  
  90. if (!par2World.isRemote)
  91. {
  92. par2World.spawnEntityInWorld(var8);
  93. }
  94. }
  95. }
  96.  
  97. public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  98. {
  99. return par1ItemStack;
  100. }
  101.  
  102. //How long it takes to use or consume an item
  103. public int getMaxItemUseDuration(ItemStack par1ItemStack)
  104. {
  105. return 72000;
  106. }
  107.  
  108. //Returns the action that specifies what animation to play when the items is being used
  109. public EnumAction getItemUseAction(ItemStack par1ItemStack)
  110. {
  111. return EnumAction.bow;
  112. }
  113.  
  114. //Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
  115. public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  116. {
  117. if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.arrow))
  118. {
  119. par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
  120. }
  121.  
  122. return par1ItemStack;
  123. }
  124.  
  125. //Return the enchantability factor of the item, most of the time is based on material.
  126. public int getItemEnchantability()
  127. {
  128. return 0;
  129. }
  130.  
  131. //Used to cycle through icons based on their used duration, i.e. for the bow
  132.  
  133.  
  134.  
  135.  
  136.  
  137. public IIcon getItemIconForUseDuration(int par1)
  138. {
  139. return this.iconArray[par1];
  140. }
  141. @Override
  142. @SideOnly(Side.CLIENT)
  143. public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
  144. if (usingItem == null) { return itemIcon; }
  145. int ticksInUse = stack.getMaxItemUseDuration() - useRemaining;
  146. if (ticksInUse > 17) {
  147. return iconArray[2];
  148. } else if (ticksInUse > 13) {
  149. return iconArray[1];
  150. } else if (ticksInUse > 0) {
  151. return iconArray[0];
  152. } else {
  153. return itemIcon;
  154. }
  155. }
  156.  
  157. IIcon[] iconArray;
  158.  
  159. public void registerIcons(IIconRegister iconRegister){
  160. iconArray = new IIcon[4];
  161. iconArray[0] = iconRegister.registerIcon("sonyikaonemod:bow_standby");
  162. iconArray[1] = iconRegister.registerIcon("sonyikaonemod:bow_pulling_0");
  163. iconArray[2] = iconRegister.registerIcon("sonyikaonemod:bow_pulling_1");
  164. iconArray[3] = iconRegister.registerIcon("sonyikaonemod:bow_pulling_2");
  165. itemIcon = iconRegister.registerIcon("sonyikaonemod:bow_standby");
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment