diff --git a/patches/net/minecraft/server/level/ChunkMap.java.patch b/patches/net/minecraft/server/level/ChunkMap.java.patch index d6dcc91909..e8f758a180 100644 --- a/patches/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/net/minecraft/server/level/ChunkMap.java.patch @@ -48,6 +48,27 @@ p_294215_.connection.chunkSender.dropChunk(p_294215_, p_294758_); } +@@ -955,6 +_,20 @@ + } + } + ++ void collectForceTickingChunks(List list) { ++ var itr = distanceManager.forcedTickets.long2ObjectEntrySet().fastIterator(); ++ while (itr.hasNext()) { ++ var entry = itr.next(); ++ ChunkHolder holder = this.visibleChunkMap.get(entry.getLongKey()); ++ if (holder != null && !entry.getValue().isEmpty()) { ++ var chunk = holder.getTickingChunk(); ++ if (chunk != null) { ++ list.add(chunk); ++ } ++ } ++ } ++ } ++ + boolean anyPlayerCloseEnoughForSpawning(ChunkPos p_183880_) { + return !this.distanceManager.hasPlayersNearby(p_183880_.toLong()) ? false : this.anyPlayerCloseEnoughForSpawningInternal(p_183880_); + } @@ -1059,6 +_,7 @@ this.playerMap.unIgnorePlayer(p_140185_); } diff --git a/patches/net/minecraft/server/level/DistanceManager.java.patch b/patches/net/minecraft/server/level/DistanceManager.java.patch index fb0d048821..34d75c7433 100644 --- a/patches/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/net/minecraft/server/level/DistanceManager.java.patch @@ -4,7 +4,7 @@ final Executor mainThreadExecutor; private long ticketTickCounter; private int simulationDistance = 10; -+ private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); ++ final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); protected DistanceManager(Executor p_140774_, Executor p_140775_) { TaskScheduler taskscheduler = TaskScheduler.wrapExecutor("player ticket throttler", p_140775_); @@ -13,8 +13,8 @@ this.ticketTracker.update(p_140785_, p_140786_.getTicketLevel(), true); } + if (p_140786_.isForceTicks()) { -+ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.create(4)); -+ tickets.addOrGet(ticket); ++ SortedArraySet> tickets = forcedTickets.computeIfAbsent(p_140785_, e -> SortedArraySet.create(4)); ++ tickets.addOrGet(ticket); + } } @@ -25,10 +25,10 @@ this.ticketTracker.update(p_140819_, getTicketLevelAt(sortedarrayset), false); + + if (p_140820_.isForceTicks()) { -+ SortedArraySet> tickets = forcedTickets.get(p_140819_); -+ if (tickets != null) { -+ tickets.remove(p_140820_); -+ } ++ SortedArraySet> tickets = forcedTickets.get(p_140819_); ++ if (tickets != null) { ++ tickets.remove(p_140820_); ++ } + } } @@ -63,8 +63,8 @@ + } + + public boolean shouldForceTicks(long chunkPos) { -+ SortedArraySet> tickets = forcedTickets.get(chunkPos); -+ return tickets != null && !tickets.isEmpty(); ++ SortedArraySet> tickets = forcedTickets.get(chunkPos); ++ return tickets != null && !tickets.isEmpty(); } private void dumpTickets(String p_143208_) { diff --git a/patches/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/net/minecraft/server/level/ServerChunkCache.java.patch index d56419a092..36cf9ecf4d 100644 --- a/patches/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/net/minecraft/server/level/ServerChunkCache.java.patch @@ -28,15 +28,19 @@ ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL); if (chunkaccess1 != null) { this.storeInCache(i, chunkaccess1, ChunkStatus.FULL); -@@ -384,7 +_,7 @@ +@@ -384,10 +_,11 @@ private void collectTickingChunks(List p_363421_) { this.chunkMap.forEachSpawnCandidateChunk(p_381767_ -> { LevelChunk levelchunk = p_381767_.getTickingChunk(); - if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos())) { -+ if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos()) || this.distanceManager.shouldForceTicks(p_381767_.getPos().toLong())) { ++ if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_381767_.getPos()) && !this.distanceManager.shouldForceTicks(p_381767_.getPos().toLong())) { // Neo: we add force ticked chunks in the list below p_363421_.add(levelchunk); } }); ++ chunkMap.collectForceTickingChunks(p_363421_); + } + + private void tickChunks(ProfilerFiller p_364065_, long p_361343_, List p_360873_) { @@ -480,11 +_,17 @@ }