Guest User

Untitled

a guest
Jun 1st, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 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 Shotgun extends Item
  17. {
  18.     public Shotgun()
  19.     {
  20.         this.setUnlocalizedName("shotgun");
  21.         this.setRegistryName("shotgun");
  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, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.HOSTILE, 2, 1);
  30.         if (!worldIn.isRemote)
  31.         {
  32.            
  33.             for(int i = 0; i!=9; i++)
  34.             {
  35.                  EntityBullet pellet = new EntityBullet(worldIn, playerIn, 3);
  36.                  pellet.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 5, 15);
  37.                  pellet.world.spawnEntity(pellet);
  38.             }  
  39.         }
  40.        
  41.         playerIn.inventory.clearMatchingItems(ModItems.shotgun, -1, 1, null);
  42.         playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, new ItemStack(ModItems.shotgun_empty));
  43.         return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(hand));
  44.     }
  45. }
Add Comment
Please, Sign In to add comment