Guest User

Untitled

a guest
May 3rd, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1. package net.nukacraft.src;
  2.  
  3. import java.util.List;
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. import net.minecraft.client.Minecraft;
  15. import net.minecraft.creativetab.CreativeTabs;
  16. import net.minecraft.entity.Entity;
  17. import net.minecraft.entity.EntityLivingBase;
  18. import net.minecraft.entity.player.EntityPlayer;
  19. import net.minecraft.init.Items;
  20. import net.minecraft.item.EnumAction;
  21. import net.minecraft.item.Item;
  22. import net.minecraft.item.ItemStack;
  23. import net.minecraft.nbt.NBTTagCompound;
  24. import net.minecraft.tileentity.TileEntity;
  25. import net.minecraft.world.World;
  26. import net.minecraftforge.fluids.ItemFluidContainer;
  27.  
  28. import java.awt.Color;
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. import org.lwjgl.input.Keyboard;
  41. import org.lwjgl.input.Mouse;
  42. import org.lwjgl.opengl.GL11;
  43.  
  44. import com.sun.security.ntlm.Client;
  45.  
  46. import cpw.mods.fml.relauncher.Side;
  47. import cpw.mods.fml.relauncher.SideOnly;
  48.  
  49.  
  50.  
  51.  
  52. public class Gun extends Item implements IActionPrimaryKey,IActionPrimaryKey2
  53. {
  54. public int var10 = 5;
  55. private String far = "Status Working";
  56. public Gun(int i)
  57. {
  58. super();
  59. super.maxStackSize = 1;
  60. setMaxDamage(6);
  61. this.setUnlocalizedName("colt");
  62. this.setCreativeTab(CreativeTabs.tabCombat);
  63. this.setTextureName(ModInf.MODID + ":" + "Gun");
  64.  
  65.  
  66. }
  67.  
  68.  
  69. public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, EntityPlayer par3Entityplayer, int par4, boolean par5){
  70.  
  71.  
  72.  
  73.  
  74. if (Keyboard.isKeyDown(Keyboard.KEY_R)) { NukaCraft.network.sendToServer(new MessageActionWeapons(3));
  75. }
  76.  
  77.  
  78.  
  79. if(Mouse.isButtonDown(1))
  80. {
  81.  
  82. var10 = 3;
  83. }
  84. else{
  85. var10 = 5;
  86.  
  87. }
  88. }
  89.  
  90. public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) { return true; }
  91.  
  92.  
  93. public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityPlayer entityplayer, int i)
  94. {
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. if (itemstack.stackTagCompound == null) {
  102.  
  103. itemstack.stackTagCompound = new NBTTagCompound();
  104.  
  105. itemstack.stackTagCompound.setInteger("kat", 0);
  106. }
  107.  
  108.  
  109.  
  110. boolean flag = entityplayer.capabilities.isCreativeMode;
  111.  
  112. if (itemstack.getItemDamage() < getMaxDamage())
  113. {
  114.  
  115.  
  116. NukaCraft.rabbut7 = 3.4F;
  117. int j = getMaxItemUseDuration(itemstack) - i;
  118. float f = 1.0F;
  119. NukaCraft.Faf= 30;
  120. EntityBullet entitybullet = new EntityBullet(world, entityplayer, 4, var10);
  121. world.playSoundAtEntity(entityplayer, "random.bow", 1.0F, 1.0F);
  122.  
  123. itemstack.damageItem(1, entityplayer);
  124.  
  125.  
  126. if (!world.isRemote)
  127. {
  128. world.spawnEntityInWorld(entitybullet);
  129. }}
  130.  
  131.  
  132.  
  133. }
  134.  
  135.  
  136.  
  137.  
  138.  
  139. public ItemStack onFoodEaten(ItemStack itemstack, World world, EntityPlayer entityplayer)
  140. {
  141. return itemstack;
  142. }
  143.  
  144. public int getMaxItemUseDuration(ItemStack itemstack)
  145. {
  146. return 0x11940;
  147. }
  148.  
  149.  
  150.  
  151. public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
  152. {
  153. entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack));
  154. return itemstack;
  155. }
  156.  
  157. public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
  158.  
  159.  
  160. if (itemStack.stackTagCompound != null) {
  161. int var1 = itemStack.stackTagCompound.getInteger("kat");
  162. list.add("Повреждение " + String.valueOf(var1) +""+ (var1 == 1 ? "" : "%"));
  163. list.add("Урон"+var10);
  164. list.add("Тип:Пистолет");
  165. list.add("6 патрон(ов)");
  166.  
  167. }
  168. }
  169.  
  170.  
  171. @SideOnly(Side.CLIENT)
  172. public void onReloadClient(ItemStack is, World world, EntityPlayer player, boolean isPress) {
  173. if (isPress) NukaCraft.network.sendToServer(new MessageActionWeapons(3));
  174. }
  175.  
  176.  
  177. public void reload(ItemStack is, World world, EntityPlayer player) {
  178.  
  179.  
  180. if (is.getItemDamage() >= 1 && player.inventory.hasItem(NukaCraft.Magnum41))
  181. {
  182.  
  183.  
  184. int k = getMaxItemUseDuration(is) - 1;
  185. float f1 = (float)k / 20F;
  186. f1 = (f1 * f1 + f1 * 2.0F) / 3F;
  187.  
  188.  
  189.  
  190.  
  191. if (f1 >= 1.0F)
  192. {
  193.  
  194.  
  195.  
  196.  
  197. is.setItemDamage(0);
  198. world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F);
  199. player.inventory.consumeInventoryItem(NukaCraft.Magnum41);
  200. is.getTagCompound().setInteger("kat", is.getTagCompound().getInteger("kat") + 2);
  201.  
  202. }}
  203. else
  204. {
  205. world.playSoundAtEntity(player, "random.click", 1.0F, 1.0F);
  206. }
  207. }
  208.  
  209. @SideOnly(Side.CLIENT)
  210. public void onButton_leftClient(ItemStack is, World world, EntityPlayer player, boolean isPress) {
  211. if (isPress) NukaCraft.net.sendToServer(new MessageActionWeapons2(3));
  212. }
  213.  
  214. public void Button_left(ItemStack is, World world, EntityPlayer player) {
  215. //
  216.  
  217.  
  218. if (is.stackTagCompound == null) {
  219.  
  220. is.stackTagCompound = new NBTTagCompound();
  221.  
  222. is.stackTagCompound.setInteger("kat", 0);
  223. }
  224.  
  225.  
  226.  
  227. boolean flag = player.capabilities.isCreativeMode;
  228.  
  229. if (is.getItemDamage() < getMaxDamage())
  230. {
  231.  
  232.  
  233. NukaCraft.rabbut7 = 3.4F;
  234. int j = getMaxItemUseDuration(is) - 1;
  235. float f = 1.0F;
  236. NukaCraft.Faf= 30;
  237. EntityBullet entitybullet = new EntityBullet(world, player, 4, var10);
  238. world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F);
  239.  
  240. is.damageItem(1, player);
  241.  
  242.  
  243. if (!world.isRemote)
  244. {
  245. world.spawnEntityInWorld(entitybullet);
  246. }}
  247.  
  248.  
  249.  
  250. }
  251.  
  252.  
  253.  
  254.  
  255.  
  256. }
Advertisement
Add Comment
Please, Sign In to add comment