2021-06-11 12:02:28 +00: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/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2021-11-23 12:15:10 +00:00
|
|
|
index 032e1e08413f2d0f601cdc32fe12145e2c1fec5f..19c97a14cbf23130db2de80e3f7f6e0c4ff27662 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2021-11-23 12:15:10 +00:00
|
|
|
@@ -206,7 +206,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2021-06-11 12:02:28 +00:00
|
|
|
public final LevelStorageSource.LevelStorageAccess convertable;
|
|
|
|
public final UUID uuid;
|
|
|
|
|
|
|
|
- public LevelChunk getChunkIfLoaded(int x, int z) {
|
|
|
|
+ @Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
|
|
|
return this.chunkSource.getChunk(x, z, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 12:15:10 +00:00
|
|
|
index 79764895307139b34f2b018f3be86d6610503b64..507d38a8e7b643712fe235c73f440c0a52b6d8b2 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 12:15:10 +00:00
|
|
|
@@ -313,11 +313,27 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- public FluidState getFluidIfLoaded(BlockPos blockposition) {
|
|
|
|
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
|
|
|
|
ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
|
|
|
|
return chunk == null ? null : chunk.getFluidState(blockposition);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
|
|
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
|
|
+ }
|
|
|
|
+ public final LevelChunk getChunkIfLoaded(BlockPos blockposition) {
|
|
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // reduces need to do isLoaded before getType
|
|
|
|
+ public final BlockState getTypeIfLoadedAndInBounds(BlockPos blockposition) {
|
2021-06-17 21:39:36 +00:00
|
|
|
+ return getWorldBorder().isWithinBounds(blockposition) ? getTypeIfLoaded(blockposition) : null;
|
2021-06-11 12:02:28 +00:00
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
@Override
|