2021-06-11 14:02:28 +02: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
|
2023-09-21 22:35:39 +02:00
|
|
|
index efb2c0f5f7b3acd127f9a570d00c5826c9e9bb6f..936f21b61589a6bcd9bf19c7466b9b1b9a14f280 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
2023-09-10 04:28:03 +02:00
|
|
|
@@ -427,6 +427,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-11 14:02:28 +02:00
|
|
|
return chunk == null ? null : chunk.getFluidState(blockposition);
|
|
|
|
}
|
|
|
|
|
2021-06-12 09:24:28 +02:00
|
|
|
+ @Override
|
2021-06-11 14:02:28 +02: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 23:39:36 +02:00
|
|
|
return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|