mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-14 22:56:31 +01:00
Use knockback method
This commit is contained in:
parent
6c60c4d0fc
commit
1afd4b4328
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user