Add asBlockIterable(World) in AABBBlock

This commit is contained in:
Marc Baloup 2021-10-10 14:16:14 +02:00
parent fdccc4195b
commit ff98d4d859
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
1 changed files with 24 additions and 0 deletions

View File

@ -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<BlockVector> {
};
}
public Iterable<Block> asBlockIterable(World w) {
return new Iterable<Block>() {
@Override
public Iterator<Block> iterator() {
return new Iterator<Block>() {
Iterator<BlockVector> 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());
}
};
}
};
}
}