Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package theishiopian.gunmod.items;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ActionResult;
- import net.minecraft.util.EnumActionResult;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.SoundCategory;
- import net.minecraft.world.World;
- import theishiopian.gunmod.entity.EntityBullet;
- import theishiopian.gunmod.init.ModItems;
- public class Shotgun extends Item
- {
- public Shotgun()
- {
- this.setUnlocalizedName("shotgun");
- this.setRegistryName("shotgun");
- this.setCreativeTab(CreativeTabs.COMBAT);
- this.setMaxStackSize(1);
- }
- @Override
- public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
- {
- worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.HOSTILE, 2, 1);
- if (!worldIn.isRemote)
- {
- for(int i = 0; i!=9; i++)
- {
- EntityBullet pellet = new EntityBullet(worldIn, playerIn, 3);
- pellet.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 5, 15);
- pellet.world.spawnEntity(pellet);
- }
- }
- playerIn.inventory.clearMatchingItems(ModItems.shotgun, -1, 1, null);
- playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, new ItemStack(ModItems.shotgun_empty));
- return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(hand));
- }
- }
Add Comment
Please, Sign In to add comment