Added new knockback function with x y and z knockback power parameters.

This commit is contained in:
luisc committed 2021-09-23 03:02:58 -05:00
1 parent a5f9ec103f
commit 58a1ccc3e7
1 file changed
+14
@@ -461,6 +461,20 @@ public class ScriptEntity {
entity.motionZ *= 0.6D;
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
}
/**
* @param xpower How strong the knockback is on the x axis
* @param ypower How strong the knockback is on the y axis
* @param zpower How strong the knockback is on the z axis
* @param direction The direction in which he flies back (0-360). Usually based on getRotation()
*/
public void knockback(int xpower, int ypower, int zpower, float direction){
float v = direction * (float)Math.PI / 180.0F;
entity.addVelocity(-MathHelper.sin(v) * (float)xpower, ypower, MathHelper.cos(v) * (float)zpower);
entity.motionX *= 0.6D;
entity.motionZ *= 0.6D;
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
}
/**
* @since 1.7.10c