2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-04-17 05:47:15 +02:00
|
|
|
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.
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
2021-06-11 08:29:15 +02:00
|
|
|
index 48d0c37a1d7df9b7ac8077e1e82420566dc42718..d8355caf6f86e0bb8c16ad0b58b81d7926bc7bff 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkProviderServer.java
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -643,21 +643,29 @@ public class ChunkProviderServer extends IChunkProvider {
|
2020-04-17 05:47:15 +02:00
|
|
|
|
|
|
|
public final boolean isInEntityTickingChunk(Entity entity) { return this.a(entity); } // Paper - OBFHELPER
|
|
|
|
@Override public boolean a(Entity entity) {
|
|
|
|
- long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
|
|
|
|
-
|
2020-06-26 03:53:21 +02:00
|
|
|
- return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
|
2020-04-17 05:47:15 +02:00
|
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
|
|
+ // entity ticking
|
|
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(entity));
|
|
|
|
+ return playerChunk != null && playerChunk.isEntityTickingReady();
|
|
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isEntityTickingChunk(ChunkCoordIntPair chunkcoordintpair) { return this.a(chunkcoordintpair); } // Paper - OBFHELPER
|
|
|
|
@Override public boolean a(ChunkCoordIntPair chunkcoordintpair) {
|
2020-06-26 03:53:21 +02:00
|
|
|
- return this.a(chunkcoordintpair.pair(), (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
|
2020-04-17 05:47:15 +02:00
|
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
|
|
+ // is entity ticking ready
|
|
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(chunkcoordintpair));
|
|
|
|
+ return playerChunk != null && playerChunk.isEntityTickingReady();
|
|
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean a(BlockPosition blockposition) {
|
|
|
|
- long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
-
|
2020-06-26 03:53:21 +02:00
|
|
|
- return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error
|
2020-04-17 05:47:15 +02:00
|
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
|
|
+ // is ticking ready
|
|
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(blockposition));
|
|
|
|
+ return playerChunk != null && playerChunk.isTickingReady();
|
|
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {
|