From ddb6545d736a20dd4e86653979c8568517823d41 Mon Sep 17 00:00:00 2001 From: KaseToatz Date: Tue, 17 Feb 2026 02:05:25 +0100 Subject: [PATCH] Use expanded bounding box for target selection Replace predictive distance logic with a simpler bounding-box expansion when searching for nearby LivingEntity targets. The predictDistance method and unused imports (PlayerEntity, Box, Vec3d) were removed; getEntitiesByClass now uses client.player.getBoundingBox().expand(client.player.getAttributeValue(EntityAttributes.ENTITY_INTERACTION_RANGE) + client.player.getVelocity().length()) and a simpler predicate (exclude self). This simplifies target acquisition and avoids the previous predictive calculation. --- .../java/com/kasetoatz/elytramace/ElytraMace.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/main/java/com/kasetoatz/elytramace/ElytraMace.java b/src/main/java/com/kasetoatz/elytramace/ElytraMace.java index 241afd1..db29de6 100644 --- a/src/main/java/com/kasetoatz/elytramace/ElytraMace.java +++ b/src/main/java/com/kasetoatz/elytramace/ElytraMace.java @@ -4,14 +4,11 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.*; import net.minecraft.registry.tag.ItemTags; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Hand; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; import java.util.Comparator; @@ -47,14 +44,6 @@ public class ElytraMace implements ClientModInitializer return index; } - private double predictDistance(PlayerEntity source, LivingEntity target) - { - Vec3d difference = target.getEyePos().subtract(source.getEyePos()); - Vec3d relativeVelocity = source.getVelocity().subtract(target.getVelocity()); - double speed = relativeVelocity.dotProduct(difference.normalize()); - return source.getAttributeValue(EntityAttributes.ENTITY_INTERACTION_RANGE) + speed * 2; - } - @Override public void onInitializeClient() { @@ -63,7 +52,7 @@ public class ElytraMace implements ClientModInitializer { return; } - LivingEntity target = client.world.getEntitiesByClass(LivingEntity.class, Box.of(client.player.getEyePos(), 10.0, 10.0, 10.0), e -> e != client.player && client.player.distanceTo(e) <= predictDistance(client.player, e)).stream().min(Comparator.comparingDouble(client.player::squaredDistanceTo)).orElse(null); + LivingEntity target = client.world.getEntitiesByClass(LivingEntity.class, client.player.getBoundingBox().expand(client.player.getAttributeValue(EntityAttributes.ENTITY_INTERACTION_RANGE) + client.player.getVelocity().length()), e -> e != client.player).stream().min(Comparator.comparingDouble(client.player::squaredDistanceTo)).orElse(null); if (target == null || client.player.fallDistance < 1.5) { return;