mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-15 15:16:46 +01:00
Cleanup tick preparation
This commit is contained in:
parent
a55ea6d0c2
commit
79f0d97664
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.thread;
|
||||
|
||||
import net.minestom.server.UpdateManager;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -78,14 +79,20 @@ public abstract class ThreadProvider {
|
||||
public void prepareUpdate(long time) {
|
||||
this.threadChunkMap.forEach((threadId, chunks) -> {
|
||||
BatchThread thread = threads.get(threadId);
|
||||
var chunksCopy = new ArrayList<>(chunks);
|
||||
|
||||
Map<Chunk, List<Entity>> chunkListMap = new HashMap<>(chunks.size());
|
||||
for (Chunk chunk : chunks) {
|
||||
var entities = new ArrayList<>(chunk.getInstance().getChunkEntities(chunk));
|
||||
chunkListMap.put(chunk, entities);
|
||||
}
|
||||
|
||||
thread.addRunnable(() -> {
|
||||
for (Chunk chunk : chunksCopy) {
|
||||
chunkListMap.forEach((chunk, entities) -> {
|
||||
chunk.tick(time);
|
||||
chunk.getInstance().getChunkEntities(chunk).forEach(entity -> {
|
||||
entities.forEach(entity -> {
|
||||
entity.tick(time);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user