2525package de .bluecolored .bluemap .core .world .mca ;
2626
2727import com .flowpowered .math .vector .Vector2i ;
28+ import com .flowpowered .math .vector .Vector3d ;
2829import com .flowpowered .math .vector .Vector3i ;
2930import de .bluecolored .bluemap .core .logger .Logger ;
3031import de .bluecolored .bluemap .core .resources .pack .datapack .DataPack ;
@@ -143,16 +144,19 @@ public WatchService<Vector2i> createRegionWatchService() throws IOException {
143144 @ Override
144145 public void preloadRegionChunks (int x , int z , Predicate <Vector2i > chunkFilter ) {
145146 blockChunkGrid .preloadRegionChunks (x , z , chunkFilter );
147+ entityChunkGrid .preloadRegionChunks (x , z , chunkFilter );
146148 }
147149
148150 @ Override
149151 public void invalidateChunkCache () {
150152 blockChunkGrid .invalidateChunkCache ();
153+ entityChunkGrid .invalidateChunkCache ();
151154 }
152155
153156 @ Override
154157 public void invalidateChunkCache (int x , int z ) {
155158 blockChunkGrid .invalidateChunkCache (x , z );
159+ entityChunkGrid .invalidateChunkCache (x , z );
156160 }
157161
158162 @ Override
@@ -165,7 +169,17 @@ public void iterateEntities(int minX, int minZ, int maxX, int maxZ, Consumer<Ent
165169 Entity [] entities = entityChunkGrid .getChunk (x , z ).getEntities ();
166170 //noinspection ForLoopReplaceableByForEach
167171 for (int i = 0 ; i < entities .length ; i ++) {
168- entityConsumer .accept (entities [i ]);
172+ Entity entity = entities [i ];
173+ Vector3d pos = entity .getPos ();
174+ int pX = pos .getFloorX ();
175+ int pZ = pos .getFloorZ ();
176+
177+ if (
178+ pX >= minX && pX <= maxX &&
179+ pZ >= minZ && pZ <= maxZ
180+ ) {
181+ entityConsumer .accept (entities [i ]);
182+ }
169183 }
170184 }
171185 }
0 commit comments