diff options
Diffstat (limited to 'patches/server/0228-Ability-to-get-block-entities-from-a-chunk-without-s.patch')
-rw-r--r-- | patches/server/0228-Ability-to-get-block-entities-from-a-chunk-without-s.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/patches/server/0228-Ability-to-get-block-entities-from-a-chunk-without-s.patch b/patches/server/0228-Ability-to-get-block-entities-from-a-chunk-without-s.patch new file mode 100644 index 0000000000..77ed848f4c --- /dev/null +++ b/patches/server/0228-Ability-to-get-block-entities-from-a-chunk-without-s.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Wed, 15 Aug 2018 01:16:34 -0400 +Subject: [PATCH] Ability to get block entities from a chunk without snapshots + + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +index 91d2b6eaa2af0abb1bdf11849f0fd59660f765dd..b2d85abb6c9c725955d972cd6895440849213fdf 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +@@ -174,6 +174,13 @@ public class CraftChunk implements Chunk { + + @Override + public BlockState[] getTileEntities() { ++ // Paper start ++ return getTileEntities(true); ++ } ++ ++ @Override ++ public BlockState[] getTileEntities(boolean useSnapshot) { ++ // Paper end + if (!this.isLoaded()) { + this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick + } +@@ -183,7 +190,29 @@ public class CraftChunk implements Chunk { + BlockState[] entities = new BlockState[chunk.blockEntities.size()]; + + for (BlockPos position : chunk.blockEntities.keySet()) { +- entities[index++] = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(); ++ // Paper start ++ entities[index++] = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(useSnapshot); ++ } ++ ++ return entities; ++ } ++ ++ @Override ++ public Collection<BlockState> getTileEntities(Predicate<? super Block> blockPredicate, boolean useSnapshot) { ++ Preconditions.checkNotNull(blockPredicate, "blockPredicate"); ++ if (!this.isLoaded()) { ++ this.getWorld().getChunkAt(this.x, this.z); // Transient load for this tick ++ } ++ ChunkAccess chunk = this.getHandle(ChunkStatus.FULL); ++ ++ java.util.List<BlockState> entities = new java.util.ArrayList<>(); ++ ++ for (BlockPos position : chunk.blockEntities.keySet()) { ++ Block block = this.worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); ++ if (blockPredicate.test(block)) { ++ entities.add(block.getState(useSnapshot)); ++ } ++ // Paper end + } + + return entities; |