testserver/patches/server/0116-Optimize-World.isLoade...

24 lines
1.2 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
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 World.isLoaded(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
2021-11-23 13:22:49 +00:00
index 8142f6c2d3bd17aec313d46141910f0743c6345e..ca2e81b9eace4124b83588c604a88a0e5595c6e6 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
2021-11-23 13:22:49 +00:00
@@ -320,6 +320,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
2021-06-11 12:02:28 +00:00
return chunk == null ? null : chunk.getFluidState(blockposition);
}
+ @Override
2021-06-11 12:02:28 +00:00
+ public final boolean hasChunkAt(BlockPos pos) {
+ return getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4) != null; // Paper
+ }
+
public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline
2021-06-17 21:39:36 +00:00
return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
2021-06-11 12:02:28 +00:00
}