This commit is contained in:
themode 2022-03-01 03:18:49 +01:00
parent 69ab2c0045
commit fa5fe8f208
1 changed files with 3 additions and 6 deletions

View File

@ -112,12 +112,9 @@ final class EntityTrackerImpl implements EntityTracker {
@Override
public <T extends Entity> void nearbyEntities(@NotNull Point point, double range, @NotNull Target<T> target, @NotNull Consumer<T> query) {
final TargetEntry<Entity> entry = entries[target.ordinal()];
final int chunkRange;
// No need to loop through neighbor chunk if the point is a chunk coordinate
if (point.x() % 16 == 0 && point.z() % 16 == 0) {
chunkRange = (int) (range / Chunk.CHUNK_SECTION_SIZE);
} else {
chunkRange = (int) (range / Chunk.CHUNK_SECTION_SIZE) + 1;
int chunkRange = (int) (range / Chunk.CHUNK_SECTION_SIZE);
if (point.x() % 16 != 0 || point.z() % 16 != 0) {
chunkRange++; // Need to loop through surrounding chunks to properly support borders
}
// Loop through range
if (range % 16 == 0) {