mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 15:47:44 +01:00
cfe3ad1b0f
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 45d9c73c SPIGOT-7043: EnderChest does not implement Lidded 86b95f34 SPIGOT-7047: Add Player#getLastDeathLocation CraftBukkit Changes: b2557f6ac SPIGOT-7041: Custom BiomeProvider not used when world set to type FLAT 732c50cab SPIGOT-7043: EnderChest does not implement Lidded 6209029ea SPIGOT-7048: addPassenger() not working when vehicle is player 3aa7836df SPIGOT-7047: Add Player#getLastDeathLocation 7d522cd26 SPIGOT-7050: Enchantment data of items will not be saved correctly when saved in YAML configuration file Spigot Changes: 1dffefb4 Rebuild patches
47 lines
2.6 KiB
Diff
47 lines
2.6 KiB
Diff
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
|
|
index 1775d3c61d9c02cee6b9d89518b3ff7c97abd42d..e01f380fea580e98e62444902bdef5694dc0ffd0 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -215,7 +215,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
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
|
|
index ee71a6cc552bd2bb82beda1bd44905ea4cc14604..e89410b00c8f9ef94cd2baf621802fa847bd6456 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -333,6 +333,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
return chunk == null ? null : chunk.getFluidState(blockposition);
|
|
}
|
|
|
|
+ public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline
|
|
+ return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
|
|
+ }
|
|
+
|
|
+ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
|
+ }
|
|
+ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos blockposition) {
|
|
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
+ }
|
|
+
|
|
+ // reduces need to do isLoaded before getType
|
|
+ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos blockposition) {
|
|
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
|
+ }
|
|
+
|
|
@Override
|
|
public final ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper - final for inline
|
|
// Paper end
|