|
2 | 2 |
|
3 | 3 | import ca.spottedleaf.concurrentutil.executor.queue.PrioritisedTaskQueue; |
4 | 4 | import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet; |
5 | | -import ca.spottedleaf.moonrise.common.util.TickThread; |
6 | 5 | import it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet; |
7 | 6 | import it.unimi.dsi.fastutil.longs.LongOpenHashSet; |
8 | 7 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; |
@@ -44,11 +43,18 @@ public class LevelChunkRegion { |
44 | 43 | public final List<TickingBlockEntity> pendingBlockEntityTickers = new ReferenceArrayList<>(); |
45 | 44 | private final ObjectOpenHashSet<Mob> navigatingMobs = new ObjectOpenHashSet<>(); |
46 | 45 | private final ObjectLinkedOpenHashSet<BlockEventData> blockEvents = new ObjectLinkedOpenHashSet<>(); |
| 46 | + private volatile long lastAccessTick; |
47 | 47 | public ArrayDeque<RedstoneTorchBlock.Toggle> redstoneUpdateInfos; |
48 | 48 |
|
49 | 49 | public LevelChunkRegion(ServerLevel level, RegionPos regionPos) { |
50 | 50 | this.level = level; |
51 | 51 | this.regionPos = regionPos; |
| 52 | + |
| 53 | + this.bumpLastAccess(); |
| 54 | + } |
| 55 | + |
| 56 | + public void bumpLastAccess() { |
| 57 | + this.lastAccessTick = this.level.levelData.getGameTime(); |
52 | 58 | } |
53 | 59 |
|
54 | 60 | public synchronized void add(LevelChunk levelChunk) { |
@@ -210,7 +216,8 @@ public synchronized void removeBlockEventsIf(Predicate<BlockEventData> predicate |
210 | 216 | } |
211 | 217 |
|
212 | 218 | public boolean isEmpty() { |
213 | | - return levelChunks.isEmpty() |
| 219 | + return this.lastAccessTick < this.level.levelData.getGameTime() - 20 |
| 220 | + && levelChunks.isEmpty() |
214 | 221 | && playerTickingChunkRequests.isEmpty() |
215 | 222 | && tickingEntities.size() == 0 |
216 | 223 | && scheduledTasks.isEmpty() |
|
0 commit comments