mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
SPIGOT-5310: Add Chunk.contains
This commit is contained in:
parent
7ef2b20d0b
commit
9aa743049f
1 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue