Search in sources :

Example 1 with BoundingBoxCache

use of com.irtimaled.bbor.common.BoundingBoxCache 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)

Example 2 with BoundingBoxCache

use of com.irtimaled.bbor.common.BoundingBoxCache in project BoundingBoxOutlineReloaded by irtimaled.

the class ClientProxy method addBoundingBox.

private void addBoundingBox(AddBoundingBoxReceived event) {
    BoundingBoxCache cache = getOrCreateCache(event.getDimensionId());
    if (cache == null)
        return;
    cache.addBoundingBoxes(event.getKey(), event.getBoundingBoxes());
}
Also used : BoundingBoxCache(com.irtimaled.bbor.common.BoundingBoxCache)

Aggregations

BoundingBoxCache (com.irtimaled.bbor.common.BoundingBoxCache)2 AbstractBoundingBox (com.irtimaled.bbor.common.models.AbstractBoundingBox)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1