From 16820698c830f6c3c5c6818be20c00b34f24b461 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Tue, 25 Jul 2023 20:39:42 +0200 Subject: [PATCH] Update sweeping code to match Player.attack --- .../java/de/ellpeck/naturesaura/items/tools/ItemSword.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java index 9617ed54..d33a3d44 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java @@ -50,8 +50,7 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel { // this is just a modified copy of Player.attack's sweeping damage code var damage = (float) player.getAttributeValue(Attributes.ATTACK_DAMAGE) * 0.75F; for (var other : player.level().getEntitiesOfClass(LivingEntity.class, stack.getSweepHitBox(player, target))) { - // TODO we removed canHit here, is that okay? - if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker())) { + if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker()) && player.distanceToSqr(other) < Mth.square(player.getEntityReach())) { other.knockback(0.4F, Mth.sin(player.getYRot() * (Mth.PI / 180)), -Mth.cos(player.getYRot() * (Mth.PI / 180))); other.hurt(other.damageSources().playerAttack(player), damage); }