Search in sources :

Example 6 with AbstractBoundingBox

use of com.irtimaled.bbor.common.models.AbstractBoundingBox in project BoundingBoxOutlineReloaded by irtimaled.

the class CacheProvider method get.

@Override
public Iterable<AbstractBoundingBox> get(DimensionId dimensionId) {
    Boolean outerBoxesOnly = ConfigManager.outerBoxesOnly.get();
    Set<AbstractBoundingBox> boundingBoxes = new HashSet<>();
    BoundingBoxCache cache = getCache.apply(dimensionId);
    if (cache != null) {
        for (Map.Entry<AbstractBoundingBox, Set<AbstractBoundingBox>> entry : cache.getBoundingBoxes().entrySet()) {
            AbstractBoundingBox key = entry.getKey();
            if (BoundingBoxTypeHelper.shouldRender(key.getType()) && isWithinRenderDistance(key)) {
                if (!outerBoxesOnly) {
                    Set<AbstractBoundingBox> children = entry.getValue();
                    if (children != null && children.size() > 0) {
                        boundingBoxes.addAll(children);
                        continue;
                    }
                }
                boundingBoxes.add(key);
            }
        }
    }
    return boundingBoxes;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Map(java.util.Map) AbstractBoundingBox(com.irtimaled.bbor.common.models.AbstractBoundingBox) BoundingBoxCache(com.irtimaled.bbor.common.BoundingBoxCache) HashSet(java.util.HashSet)

Aggregations

AbstractBoundingBox (com.irtimaled.bbor.common.models.AbstractBoundingBox)6 HashSet (java.util.HashSet)4 DimensionId (com.irtimaled.bbor.common.models.DimensionId)2 Map (java.util.Map)2 Set (java.util.Set)2 AddBoundingBoxReceived (com.irtimaled.bbor.client.events.AddBoundingBoxReceived)1 BoundingBoxCache (com.irtimaled.bbor.common.BoundingBoxCache)1 PayloadBuilder (com.irtimaled.bbor.common.messages.PayloadBuilder)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Stream (java.util.stream.Stream)1 MutableBoundingBox (net.minecraft.util.math.MutableBoundingBox)1 StructurePiece (net.minecraft.world.gen.feature.structure.StructurePiece)1 StructureStart (net.minecraft.world.gen.feature.structure.StructureStart)1