diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/ScriptEntity.java index 2deeb9d8e..ccb7203cc 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntity.java @@ -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