Advertisement
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 Rifle extends Item
- {
- public Rifle()
- {
- this.setUnlocalizedName("rifle");
- this.setRegistryName("rifle");
- 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)
- {
- EntityBullet ball = new EntityBullet(worldIn, playerIn, 20);
- ball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 5, 2);
- ball.world.spawnEntity(ball);
- }
- playerIn.inventory.clearMatchingItems(ModItems.rifle, -1, 1, null);
- playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem,
- new ItemStack(ModItems.rifle_empty));
- return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(hand));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement