Skip to content

Commit

Permalink
Optimise chunk tick checking during chunk tick
Browse files Browse the repository at this point in the history
We don't need to check for this with the chunk system, as
ticking chunks are actually guaranteed to ticking. Additionally,
ticking chunks may only become non-ticking during the chunk holder
manager tick - which will not happen during chunk ticking.
  • Loading branch information
Spottedleaf committed Jul 17, 2024
1 parent 8bc6b3c commit cec8e6f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public abstract class DistanceManagerMixin implements ChunkSystemDistanceManager
value = "RETURN"
)
)
private void destroyFields(final Executor executor, final Executor executor2,
final CallbackInfo ci) {
private void destroyFields(final CallbackInfo ci) {
this.tickets = null;
this.ticketTracker = null;
this.tickingTicketsTracker = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.server.level.FullChunkStatus;
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.LevelChunk;
Expand Down Expand Up @@ -298,4 +299,36 @@ private void midTickChunks(final CallbackInfo ci) {

((ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks();
}

/**
* @reason In the chunk system, ticking chunks always have loaded entities. Of course, they are also always
* marked to be as ticking as well.
* @author Spottedleaf
*/
@Redirect(
method = "tickChunks",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;isNaturalSpawningAllowed(Lnet/minecraft/world/level/ChunkPos;)Z"
)
)
private boolean shortNaturalSpawning(final ServerLevel instance, final ChunkPos chunkPos) {
return true;
}

/**
* @reason In the chunk system, ticking chunks always have loaded entities. Of course, they are also always
* marked to be as ticking as well.
* @author Spottedleaf
*/
@Redirect(
method = "tickChunks",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;shouldTickBlocksAt(J)Z"
)
)
private boolean shortShouldTickBlocks(final ServerLevel instance, final long pos) {
return true;
}
}

0 comments on commit cec8e6f

Please sign in to comment.