From 280cf8ba514e4cd4f42d5bf3b15979e6c11e05d6 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 8 Sep 2019 11:39:08 +1000 Subject: [PATCH] SPIGOT-5310: Add Chunk.contains By: md_5 --- .../java/org/bukkit/craftbukkit/CraftChunk.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 64e2682643..2f8a399cc1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -25,7 +25,9 @@ import org.bukkit.ChunkSnapshot; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Entity; import org.bukkit.plugin.Plugin; @@ -211,6 +213,20 @@ public class CraftChunk implements Chunk { getHandle().b(ticks); } + @Override + public boolean contains(BlockData block) { + Preconditions.checkArgument(block != null, "Block cannot be null"); + + IBlockData nms = ((CraftBlockData) block).getState(); + for (ChunkSection section : getHandle().getSections()) { + if (section != null && section.getBlocks().a(nms)) { + return true; + } + } + + return false; + } + @Override public ChunkSnapshot getChunkSnapshot() { return getChunkSnapshot(true, false, false);