Posted June 22, 20169 yr I would like to add projectiles that have knockback. Unfortunately, I don't know how to add knockback to projectiles. When I try it only knocks mobs back when I aim at the positive coords but when I don't it sends them upwards. How do I fix this? [package mymod.projectiles; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class MyEntityPushProjectile extends EntityThrowable { private float test; public MyEntityPushProjectile(World par1World) { super(par1World); } public MyEntityPushProjectile(World par1World, EntityLivingBase par2EntityLivingBase) { super(par1World, par2EntityLivingBase); } public MyEntityPushProjectile(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } /** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { byte b0 = 5; par1MovingObjectPosition.entityHit.addVelocity(this.motionX * 1.6000000238418579D, this.motionZ * 1.6000000238418579D, entityCollisionReduction); } if (!this.worldObj.isRemote) { this.setDead(); } } } ]
June 24, 20169 yr Author Thanks a ton! I fixed it by adding a MotionY into it like you said and it worked.
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.