mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 01:47:54 +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 -> {
|
.addListener(EntityAttackEvent.class, event -> {
|
||||||
final Entity source = event.getEntity();
|
final Entity source = event.getEntity();
|
||||||
final Entity entity = event.getTarget();
|
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) {
|
if (entity instanceof Player) {
|
||||||
Player target = (Player) entity;
|
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);
|
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) {
|
if (source instanceof Player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user