From ff98d4d85946d4f5424f576057cde70fa77c528a Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 10 Oct 2021 14:16:14 +0200 Subject: [PATCH] Add asBlockIterable(World) in AABBBlock --- .../pandacube/lib/paper/util/AABBBlock.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java b/Paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java index 2723909..6b7cc4e 100644 --- a/Paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java +++ b/Paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java @@ -3,6 +3,8 @@ package fr.pandacube.lib.paper.util; import java.util.Iterator; import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.util.BlockVector; import org.bukkit.util.BoundingBox; @@ -115,4 +117,26 @@ public class AABBBlock implements Iterable { }; } + + public Iterable asBlockIterable(World w) { + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + Iterator nested = AABBBlock.this.iterator(); + @Override + public boolean hasNext() { + return nested.hasNext(); + } + @Override + public Block next() { + BlockVector bv = nested.next(); + return w.getBlockAt(bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()); + } + }; + } + }; + } + + }