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
|
2022-09-26 08:02:51 +00:00
|
|
|
index e235531d694e3e904042f2d42641c1ffbecfd5a3..d935fbdbee8b20f0efa09438b7d4c4a0da93abcc 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
|
2022-07-27 19:49:24 +00:00
|
|
|
@@ -216,7 +216,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
|
2022-09-26 08:02:51 +00:00
|
|
|
index 65fd3a3c1f0a55d034e6f91c4f222e6454e7166c..62c54a0c789ca460ec29b0c653f5abd113736fb9 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
|
2022-06-09 08:51:45 +00:00
|
|
|
@@ -333,6 +333,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
2021-06-11 12:02:28 +00:00
|
|
|
return chunk == null ? null : chunk.getFluidState(blockposition);
|
|
|
|
}
|
2021-12-05 23:32:02 +00:00
|
|
|
|
2021-06-11 12:02:28 +00:00
|
|
|
+ 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
|
|
|
+ }
|
|
|
|
+
|
2021-12-05 23:32:02 +00:00
|
|
|
+ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
|
2021-06-11 12:02:28 +00:00
|
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
|
|
+ }
|
2021-12-05 23:32:02 +00:00
|
|
|
+ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos blockposition) {
|
2021-06-11 12:02:28 +00:00
|
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // reduces need to do isLoaded before getType
|
2021-12-05 23:32:02 +00:00
|
|
|
+ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos blockposition) {
|
|
|
|
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
2021-06-11 12:02:28 +00:00
|
|
|
+ }
|
2021-12-05 23:32:02 +00:00
|
|
|
+
|
2021-06-11 12:02:28 +00:00
|
|
|
@Override
|
2021-12-05 23:32:02 +00:00
|
|
|
public final ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper - final for inline
|
|
|
|
// Paper end
|