SPIGOT-6779: Fix LivingEntity#attack for Player entities

This commit is contained in:
Doc 2021-11-02 18:33:35 +11:00 committed by md_5
parent 747a73ec92
commit 376edf4fe5
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -651,8 +651,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
Preconditions.checkArgument(target != null, "target == null"); Preconditions.checkArgument(target != null, "target == null");
Preconditions.checkState(!getHandle().generation, "Cannot attack during world generation"); Preconditions.checkState(!getHandle().generation, "Cannot attack during world generation");
if (getHandle() instanceof EntityHuman) {
((EntityHuman) getHandle()).attack(((CraftEntity) target).getHandle());
} else {
getHandle().attackEntity(((CraftEntity) target).getHandle()); getHandle().attackEntity(((CraftEntity) target).getHandle());
} }
}
@Override @Override
public void swingMainHand() { public void swingMainHand() {