Paper/patches/server/0119-Optimize-Level.hasChunkAt-BlockPosition-Z.patch

24 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 2 Dec 2016 00:11:43 -0500
Subject: [PATCH] Optimize Level.hasChunkAt(BlockPosition)Z
Reduce method invocations for World.isLoaded(BlockPosition)Z
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index edcab2dd4070703101ed9bef86f320093be6c1cb..004dd17181a49df5c2255a9eeca03f5a354920aa 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -341,6 +341,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return chunk == null ? null : chunk.getFluidState(blockposition);
}
+ @Override
+ public final boolean hasChunkAt(BlockPos pos) {
+ return getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4) != null; // Paper - Perf: Optimize Level.hasChunkAt(BlockPosition)Z
+ }
+
public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline
return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
}