Search in sources :

Example 1 with ItemFrameCluster

use of com.bergerkiller.bukkit.common.internal.map.ItemFrameCluster in project BKCommonLib by bergerhealer.

the class ItemFrameInfo method recalculateUUID.

void recalculateUUID() {
    // Find out the tile information of this item frame
    // This is a slow and lengthy procedure; hopefully it does not happen too often
    // What we do is: we add all neighbours, then find the most top-left item frame
    // Subtracting coordinates will give us the tile x/y of this item frame
    IntVector3 itemFramePosition = this.coordinates;
    ItemFrameCluster cluster = this.controller.findCluster(itemFrameHandle, itemFramePosition);
    // If not fully loaded, 'park' this item frame until surrounding chunks are loaded too
    World world = this.getWorld();
    boolean fullyLoaded = true;
    for (ItemFrameCluster.ChunkDependency dependency : cluster.chunk_dependencies) {
        fullyLoaded &= this.controller.checkClusterChunkDependency(world, dependency);
    }
    if (!fullyLoaded) {
        this.requiresFurtherLoading = true;
        return;
    }
    // Calculate UUID of this item frame
    this.recalculateUUIDInCluster(cluster);
    // as otherwise there is a tick delay until these other item frames initialize.
    if (cluster.hasMultipleTiles()) {
        for (ItemFrameInfo itemFrame : this.controller.findClusterItemFrames(cluster)) {
            if (itemFrame == this) {
                continue;
            }
            if ((itemFrame.lastFrameItemUpdateNeeded && itemFrame.checkItemChanged()) || itemFrame.requiresFurtherLoading) {
                itemFrame.recalculateUUIDInCluster(cluster);
            }
        }
    }
}
Also used : ItemFrameCluster(com.bergerkiller.bukkit.common.internal.map.ItemFrameCluster) World(org.bukkit.World) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3)

Aggregations

IntVector3 (com.bergerkiller.bukkit.common.bases.IntVector3)1 ItemFrameCluster (com.bergerkiller.bukkit.common.internal.map.ItemFrameCluster)1 World (org.bukkit.World)1