mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Added new knockback function with x y and z knockback power parameters.
This commit is contained in:
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
|
||||
|
||||
Reference in new issue
Block a user