2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 18 Mar 2016 20:16:03 -0400
|
|
|
|
Subject: [PATCH] Add World Util Methods
|
|
|
|
|
|
|
|
Methods that can be used for other patches to help improve logic.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
2024-07-17 20:08:28 +02:00
|
|
|
index 32b42d25631aecdd31db4954a8bbf38bcda98d6b..dfb349ed8a0fb981b3234baf040bd3297a555ebf 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
|
2024-06-13 19:30:39 +02:00
|
|
|
@@ -341,6 +341,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-11 14:02:28 +02:00
|
|
|
return chunk == null ? null : chunk.getFluidState(blockposition);
|
|
|
|
}
|
2021-12-06 00:32:02 +01:00
|
|
|
|
2021-06-11 14:02:28 +02:00
|
|
|
+ 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
|
|
|
+ }
|
|
|
|
+
|
2021-12-06 00:32:02 +01:00
|
|
|
+ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
|
2021-06-11 14:02:28 +02:00
|
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
|
|
+ }
|
2021-12-06 00:32:02 +01:00
|
|
|
+ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos blockposition) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // reduces need to do isLoaded before getType
|
2021-12-06 00:32:02 +01:00
|
|
|
+ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos blockposition) {
|
|
|
|
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2021-12-06 00:32:02 +01:00
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
@Override
|
2024-07-17 20:08:28 +02:00
|
|
|
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
2021-12-06 00:32:02 +01:00
|
|
|
// Paper end
|