Ars Nouveau

Ars Nouveau

70M Downloads

[BUG] `canTakeSourceNearby` method returns inaccurate results due to distance calculation error

Frostbite-time opened this issue · 1 comments

commented

Description:
The canTakeSourceNearby(BlockPos pos, Level world, int range) method is designed to return all available ISpecialSourceProvider entities within a specified range (distance ≤ range). However, its implementation currently filters out entities at the exact boundary distance.

Steps to Reproduce:

  1. Call canTakeSourceNearby with range=2.
  2. Observe that only entities at distance < 2 (i.e., distance=1) are returned.
  3. Entities at exactly distance=2 are incorrectly excluded.

Expected Behavior:
Entities at distance ≤ range should be included (e.g., with range=2, both distance=1 and distance=2 are valid).

Actual Behavior:
Only entities at distance < range are returned (e.g., range=2 returns only distance=1 targets).

Evidence of Inconsistency:
The canTakeSource method correctly identifies targets at distance ≤ range (e.g., SourceJarTile at 2 blocks with range=2). Meanwhile, ISpecialSourceProvider's canTakeSourceNearby fails to include targets at the exact range distance under the same conditions.

Impact:
This causes valid sources at boundary distances to be ignored, breaking functionality that relies on inclusive range checks.

commented

Simply add a 0.1 offset to the range parameter before distance calculation can fix it.
If possible, could you fix that for both 1.21.1 and 1.20.1 versions.