Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. package theishiopian.gunmod.items;
  2.  
  3. import net.minecraft.creativetab.CreativeTabs;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.init.SoundEvents;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.util.ActionResult;
  9. import net.minecraft.util.EnumActionResult;
  10. import net.minecraft.util.EnumHand;
  11. import net.minecraft.util.SoundCategory;
  12. import net.minecraft.world.World;
  13. import theishiopian.gunmod.entity.EntityBullet;
  14. import theishiopian.gunmod.init.ModItems;
  15.  
  16. public class Rifle extends Item
  17. {
  18.     public Rifle()
  19.     {
  20.         this.setUnlocalizedName("rifle");
  21.         this.setRegistryName("rifle");
  22.         this.setCreativeTab(CreativeTabs.COMBAT);
  23.         this.setMaxStackSize(1);
  24.     }
  25.  
  26.     @Override
  27.     public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
  28.     {
  29.         worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ,
  30.                 SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.HOSTILE, 2, 1);
  31.         if(!worldIn.isRemote)
  32.         {
  33.  
  34.             EntityBullet ball = new EntityBullet(worldIn, playerIn, 20);
  35.             ball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 5, 2);
  36.             ball.world.spawnEntity(ball);
  37.  
  38.         }
  39.  
  40.         playerIn.inventory.clearMatchingItems(ModItems.rifle, -1, 1, null);
  41.         playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem,
  42.                 new ItemStack(ModItems.rifle_empty));
  43.         return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(hand));
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement