Posted March 24, 201411 yr I am creating a gun mod and I have almost everything set except the guns do not shoot, because I do not know how to make a projectile launch on a left click with an item. Thanks in advance, ZapterX
March 24, 201411 yr Author Thank you, but I have never codded a gun before and wanted to know if you could provide a more specific example.
March 25, 201411 yr Author I tried running that in gradlew.bat but it would not allow me to type, it auto closed.
March 25, 201411 yr This is from the snowball class and might be what your looking for. Just put this in your class for the gun. You probably need to change this around because whenever you right click, the gun dissapears too. /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); } return par1ItemStack; }
March 25, 201411 yr Here's a tutorial that I found out to come in handy with creating a rifle/gun. http://www.minecraftforge.net/wiki/Tutorials/Basic_Shooter_Item_-_Blaster_Rifle Might help you out as well.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.