Skip to content

Commit

Permalink
refactor: range in findNearbyPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Duzos committed Sep 30, 2024
1 parent d0a7fee commit 4a17750
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void tick() {
}

private void tryApply() {
PlayerEntity found = findNearbyPlayer().orElse(null);
PlayerEntity found = findNearbyPlayer(0.25f).orElse(null);

if (found == null) return;

Expand All @@ -97,8 +97,8 @@ private void tryApply() {
}
}

private Optional<PlayerEntity> findNearbyPlayer() {
EntityHitResult ray = ProjectileUtil.getEntityCollision(this.getWorld(), this, this.getPos(), this.getPos().offset(this.getMovementDirection().getOpposite(), 0.25f).add(0, 1.5, 0), this.getBoundingBox().stretch(this.getVelocity()).expand(1.0), (entity -> (entity instanceof PlayerEntity)));;
private Optional<PlayerEntity> findNearbyPlayer(float range) {
EntityHitResult ray = ProjectileUtil.getEntityCollision(this.getWorld(), this, this.getPos(), this.getPos().offset(this.getMovementDirection().getOpposite(), range).add(0, 1.5, 0), this.getBoundingBox().stretch(this.getVelocity()).expand(1.0), (entity -> (entity instanceof PlayerEntity)));;
if (ray == null) return Optional.empty();
return Optional.of((PlayerEntity) ray.getEntity());
}
Expand Down

0 comments on commit 4a17750

Please sign in to comment.