Paper/Spigot-Server-Patches/0478-Optimize-ChunkProviderServer-s-chunk-level-checking-.patch
Aikar 36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00

63 lines
3.2 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/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 746b5b55896eaf39edf92073f61796d7096c48c2..c2e4e4f6f1895850bcac3552eee5bfedfb98c933 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -615,27 +615,37 @@ 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, PlayerChunk::b);
+ // 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(), PlayerChunk::b);
+ // 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, PlayerChunk::a);
+ // 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
}
public boolean b(Entity entity) {
- long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
-
- return this.a(i, PlayerChunk::c);
+ // Paper start - optimize is ticking ready type functions
+ // is full chunk ready
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(entity));
+ return playerChunk != null && playerChunk.isFullChunkReady();
+ // Paper end - optimize is ticking ready type functions
}
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {