Skip to content

Commit

Permalink
revert to old raytrace method
Browse files Browse the repository at this point in the history
  • Loading branch information
Steanky committed Jul 14, 2023
1 parent 06fe5cc commit 6891b50
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.steanky.element.core.annotation.document.Description;
import com.github.steanky.toolkit.collection.Wrapper;
import net.minestom.server.collision.BoundingBox;
import net.minestom.server.collision.CollisionUtils;
import net.minestom.server.coordinate.Point;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.coordinate.Vec;
Expand Down Expand Up @@ -88,12 +89,14 @@ public boolean leftClick() {
.raytraceCandidates(eyePos, targetPos, EntityTracker.Target.LIVING_ENTITIES, hit -> {
if (mobStore.hasMob(hit.getUuid())) {
BoundingBox boundingBox = hit.getBoundingBox();
Pos hitPosition = hit.getPosition();

RayUtils.rayTrace(boundingBox, hit.getPosition(), eyePos).ifPresent(vec -> {
RayUtils.rayTrace(boundingBox, hitPosition, eyePos).ifPresent(vec -> {
HitResult closestHit = closest.get();
if ((closestHit == null ||
vec.distanceSquared(eyePos) < closestHit.pos.distanceSquared(eyePos)) &&
player.hasLineOfSight(hit)) {
CollisionUtils.isLineOfSightReachingShape(instance, player.getChunk(),
eyePos, hitPosition, boundingBox)) {
closest.set(new HitResult(hit, vec));
}
});
Expand Down

0 comments on commit 6891b50

Please sign in to comment.