Use knockback method

This commit is contained in:
Németh Noel 2021-06-27 23:09:23 +02:00
parent 6c60c4d0fc
commit 1afd4b4328

View File

@ -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) {