mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 07:17:46 +01:00
#1369: Add World#getIntersectingChunks(BoundingBox)
By: Flo0 <flo.roma@web.de>
This commit is contained in:
parent
3f9e7c4e39
commit
779b5137f8
@ -146,6 +146,7 @@ import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.BiomeSearchResult;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.StructureSearchResult;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -462,6 +463,25 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return ret.entrySet().stream().collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, (entry) -> entry.getValue().build()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Chunk> getIntersectingChunks(@NotNull BoundingBox boundingBox) {
|
||||
List<Chunk> chunks = new ArrayList<>();
|
||||
|
||||
int minX = NumberConversions.floor(boundingBox.getMinX()) >> 4;
|
||||
int maxX = NumberConversions.floor(boundingBox.getMaxX()) >> 4;
|
||||
int minZ = NumberConversions.floor(boundingBox.getMinZ()) >> 4;
|
||||
int maxZ = NumberConversions.floor(boundingBox.getMaxZ()) >> 4;
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
chunks.add(getChunkAt(x, z, false));
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkForceLoaded(int x, int z) {
|
||||
return getHandle().getForcedChunks().contains(ChunkCoordIntPair.asLong(x, z));
|
||||
|
Loading…
Reference in New Issue
Block a user