Jump to content

Knockback Projectiles


Xawolf

Recommended Posts

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();

 

           

        }

    }

 

}

]

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.