Search in sources :

Example 6 with DimensionId

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

the class CommonProxy method sendToPlayer.

private void sendToPlayer(int playerId, ServerPlayer player) {
    for (Map.Entry<DimensionId, BoundingBoxCache> entry : dimensionCache.entrySet()) {
        DimensionId dimensionId = entry.getKey();
        BoundingBoxCache boundingBoxCache = entry.getValue();
        if (boundingBoxCache == null)
            return;
        Set<AbstractBoundingBox> playerBoundingBoxes = playerBoundingBoxesCache.computeIfAbsent(playerId, k -> new HashSet<>());
        Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxMap = boundingBoxCache.getBoundingBoxes();
        for (AbstractBoundingBox key : boundingBoxMap.keySet()) {
            if (playerBoundingBoxes.contains(key)) {
                continue;
            }
            Set<AbstractBoundingBox> boundingBoxes = boundingBoxMap.get(key);
            PayloadBuilder payload = AddBoundingBox.getPayload(dimensionId, key, boundingBoxes);
            if (payload != null)
                player.sendPacket(payload);
            playerBoundingBoxes.add(key);
        }
    }
}
Also used : PayloadBuilder(com.irtimaled.bbor.common.messages.PayloadBuilder) Set(java.util.Set) HashSet(java.util.HashSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) DimensionId(com.irtimaled.bbor.common.models.DimensionId) AbstractBoundingBox(com.irtimaled.bbor.common.models.AbstractBoundingBox)

Example 7 with DimensionId

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

the class CommonProxy method structuresLoaded.

private void structuresLoaded(StructuresLoaded event) {
    DimensionId dimensionId = event.getDimensionId();
    StructureProcessor structureProcessor = getStructureProcessor(dimensionId);
    structureProcessor.process(event.getStructures());
}
Also used : DimensionId(com.irtimaled.bbor.common.models.DimensionId)

Example 8 with DimensionId

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

the class CommonProxy method worldLoaded.

private void worldLoaded(WorldLoaded event) {
    DimensionId dimensionId = event.getDimensionId();
    long seed = event.getSeed();
    if (dimensionId == DimensionId.OVERWORLD) {
        setSeed(seed);
        setWorldSpawn(event.getSpawnX(), event.getSpawnZ());
    }
    Logger.info("create world dimension: %s (seed: %d)", dimensionId, seed);
}
Also used : DimensionId(com.irtimaled.bbor.common.models.DimensionId)

Example 9 with DimensionId

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

the class CustomSphereProvider method add.

public static void add(Point center, double radius) {
    DimensionId dimensionId = Player.getDimensionId();
    int cacheKey = center.hashCode();
    BoundingBoxSphere sphere = new BoundingBoxSphere(center, radius, BoundingBoxType.Custom);
    getCache(dimensionId).put(cacheKey, sphere);
}
Also used : DimensionId(com.irtimaled.bbor.common.models.DimensionId) Point(com.irtimaled.bbor.client.models.Point) BoundingBoxSphere(com.irtimaled.bbor.client.models.BoundingBoxSphere)

Example 10 with DimensionId

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

the class CustomSphereProvider method remove.

public static boolean remove(Point center) {
    DimensionId dimensionId = Player.getDimensionId();
    int cacheKey = center.hashCode();
    return getCache(dimensionId).remove(cacheKey) != null;
}
Also used : DimensionId(com.irtimaled.bbor.common.models.DimensionId) Point(com.irtimaled.bbor.client.models.Point)

Aggregations

DimensionId (com.irtimaled.bbor.common.models.DimensionId)13 Point (com.irtimaled.bbor.client.models.Point)4 AbstractBoundingBox (com.irtimaled.bbor.common.models.AbstractBoundingBox)2 HashSet (java.util.HashSet)2 AddBoundingBoxReceived (com.irtimaled.bbor.client.events.AddBoundingBoxReceived)1 BoundingBoxBeacon (com.irtimaled.bbor.client.models.BoundingBoxBeacon)1 BoundingBoxLine (com.irtimaled.bbor.client.models.BoundingBoxLine)1 BoundingBoxSphere (com.irtimaled.bbor.client.models.BoundingBoxSphere)1 PayloadBuilder (com.irtimaled.bbor.common.messages.PayloadBuilder)1 BoundingBoxCuboid (com.irtimaled.bbor.common.models.BoundingBoxCuboid)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Minecraft (net.minecraft.client.Minecraft)1 StructureStart (net.minecraft.world.gen.feature.structure.StructureStart)1 SaveFormat (net.minecraft.world.storage.SaveFormat)1