mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-02-06 23:52:08 +01:00
Improvements on world handling the entity chunk-grid
This commit is contained in:
parent
19d3c321dc
commit
2367f4feca
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.core.world.mca;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.resources.pack.datapack.DataPack;
|
||||
@ -143,16 +144,19 @@ public WatchService<Vector2i> createRegionWatchService() throws IOException {
|
||||
@Override
|
||||
public void preloadRegionChunks(int x, int z, Predicate<Vector2i> chunkFilter) {
|
||||
blockChunkGrid.preloadRegionChunks(x, z, chunkFilter);
|
||||
entityChunkGrid.preloadRegionChunks(x, z, chunkFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateChunkCache() {
|
||||
blockChunkGrid.invalidateChunkCache();
|
||||
entityChunkGrid.invalidateChunkCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateChunkCache(int x, int z) {
|
||||
blockChunkGrid.invalidateChunkCache(x, z);
|
||||
entityChunkGrid.invalidateChunkCache(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -165,7 +169,17 @@ public void iterateEntities(int minX, int minZ, int maxX, int maxZ, Consumer<Ent
|
||||
Entity[] entities = entityChunkGrid.getChunk(x, z).getEntities();
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
entityConsumer.accept(entities[i]);
|
||||
Entity entity = entities[i];
|
||||
Vector3d pos = entity.getPos();
|
||||
int pX = pos.getFloorX();
|
||||
int pZ = pos.getFloorZ();
|
||||
|
||||
if (
|
||||
pX >= minX && pX <= maxX &&
|
||||
pZ >= minZ && pZ <= maxZ
|
||||
) {
|
||||
entityConsumer.accept(entities[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user