mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
59 lines
3.6 KiB
Diff
59 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Thu, 16 Apr 2020 16:13:59 -0700
|
|
Subject: [PATCH] Optimize ChunkProviderServer's chunk level checking helper
|
|
methods
|
|
|
|
These can be hot functions (i.e entity ticking and block ticking),
|
|
so inline where possible, and avoid the abstraction of the
|
|
Either class.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.Packet;
|
|
import net.minecraft.server.MCUtil;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.progress.ChunkProgressListener;
|
|
-import net.minecraft.util.Mth;
|
|
import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.util.thread.BlockableEventLoop;
|
|
import net.minecraft.world.entity.Entity;
|
|
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
|
|
|
|
public final boolean isInEntityTickingChunk(Entity entity) { return this.isEntityTickingChunk(entity); } // Paper - OBFHELPER
|
|
@Override public boolean isEntityTickingChunk(Entity entity) {
|
|
- long i = ChunkPos.asLong(Mth.floor(entity.getX()) >> 4, Mth.floor(entity.getZ()) >> 4);
|
|
-
|
|
- return this.checkChunkFuture(i, (Function<ChunkHolder, CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>>>) ChunkHolder::getEntityTickingChunkFuture); // CraftBukkit - decompile error
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // entity ticking
|
|
+ ChunkHolder playerChunk = this.getVisibleChunkIfPresent(MCUtil.getCoordinateKey(entity));
|
|
+ return playerChunk != null && playerChunk.isEntityTickingReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
public final boolean isEntityTickingChunk(ChunkPos chunkcoordintpair) { return this.isEntityTickingChunk(chunkcoordintpair); } // Paper - OBFHELPER
|
|
@Override public boolean isEntityTickingChunk(ChunkPos pos) {
|
|
- return this.checkChunkFuture(pos.toLong(), (Function<ChunkHolder, CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>>>) ChunkHolder::getEntityTickingChunkFuture); // CraftBukkit - decompile error
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // is entity ticking ready
|
|
+ ChunkHolder playerChunk = this.getVisibleChunkIfPresent(MCUtil.getCoordinateKey(pos));
|
|
+ return playerChunk != null && playerChunk.isEntityTickingReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
@Override
|
|
public boolean isTickingChunk(BlockPos pos) {
|
|
- long i = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);
|
|
-
|
|
- return this.checkChunkFuture(i, (Function<ChunkHolder, CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>>>) ChunkHolder::getTickingChunkFuture); // CraftBukkit - decompile error
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // is ticking ready
|
|
+ ChunkHolder playerChunk = this.getVisibleChunkIfPresent(MCUtil.getCoordinateKey(pos));
|
|
+ return playerChunk != null && playerChunk.isTickingReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
private boolean checkChunkFuture(long pos, Function<ChunkHolder, CompletableFuture<Either<LevelChunk, ChunkHolder.ChunkLoadingFailure>>> futureFunction) {
|