From 1afd4b4328a950bedf5a482a125d5efdb7ca396b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9meth=20Noel?= Date: Sun, 27 Jun 2021 23:09:23 +0200 Subject: [PATCH] Use knockback method --- src/test/java/demo/PlayerInit.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/test/java/demo/PlayerInit.java b/src/test/java/demo/PlayerInit.java index 485347368..9048b56a9 100644 --- a/src/test/java/demo/PlayerInit.java +++ b/src/test/java/demo/PlayerInit.java @@ -50,16 +50,12 @@ public class PlayerInit { .addListener(EntityAttackEvent.class, event -> { final Entity source = event.getEntity(); final Entity entity = event.getTarget(); + + entity.takeKnockback(0.4f, Math.sin(source.getPosition().getYaw() * 0.017453292), -Math.cos(source.getPosition().getYaw() * 0.017453292)); + if (entity instanceof Player) { Player target = (Player) entity; - Vector velocity = source.getPosition().clone().getDirection().multiply(4); - velocity.setY(3.5f); - target.setVelocity(velocity); target.damage(DamageType.fromEntity(source), 5); - } else { - Vector velocity = source.getPosition().clone().getDirection().multiply(3); - velocity.setY(3f); - entity.setVelocity(velocity); } if (source instanceof Player) {