aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0456-Optimize-ChunkProviderServer-s-chunk-level-checking-.patch
blob: 368e1ea8c285aabb03b8cf4095ebe04ca96e40e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index d1f832db33f21f8ba910d2c0c163af78718d298f..91755cd7313d87bae85584dff140acbc6467428f 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -618,21 +618,29 @@ public class ChunkProviderServer extends IChunkProvider {
 
     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);
-
-        return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
+        // 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) {
-        return this.a(chunkcoordintpair.pair(), (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
+        // 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);
-
-        return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error
+        // 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) {