[BUG] `canTakeSourceNearby` method returns inaccurate results due to distance calculation error
Frostbite-time opened this issue · 1 comments
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:
- Call
canTakeSourceNearbywithrange=2. - Observe that only entities at distance < 2 (i.e., distance=1) are returned.
- 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.