Search in sources :

Example 11 with SnapshotRec

use of org.dynmap.forge_1_12_2.SnapshotCache.SnapshotRec in project dynmap by webbukkit.

the class ForgeMapChunkCache method tryChunkCache.

private boolean tryChunkCache(DynmapChunk chunk, boolean vis) {
    /* Check if cached chunk snapshot found */
    ChunkSnapshot ss = null;
    SnapshotRec ssr = DynmapPlugin.plugin.sscache.getSnapshot(dw.getName(), chunk.x, chunk.z, blockdata, biome, biomeraw, highesty);
    if (ssr != null) {
        ss = ssr.ss;
        if (!vis) {
            if (hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN) {
                ss = STONE;
            } else if (hidestyle == HiddenChunkStyle.FILL_OCEAN) {
                ss = OCEAN;
            } else {
                ss = EMPTY;
            }
        }
        int idx = (chunk.x - x_min) + (chunk.z - z_min) * x_dim;
        snaparray[idx] = ss;
        snaptile[idx] = ssr.tileData;
    }
    return (ssr != null);
}
Also used : SnapshotRec(org.dynmap.forge_1_15_2.SnapshotCache.SnapshotRec)

Example 12 with SnapshotRec

use of org.dynmap.forge_1_12_2.SnapshotCache.SnapshotRec in project dynmap by webbukkit.

the class ForgeMapChunkCache method readChunks.

public int readChunks(int max_to_load) {
    if (!dw.isLoaded()) {
        isempty = true;
        unloadChunks();
        return 0;
    }
    int cnt = 0;
    if (iterator == null) {
        iterator = chunks.listIterator();
    }
    DynmapCore.setIgnoreChunkLoads(true);
    // Load the required chunks.
    while ((cnt < max_to_load) && iterator.hasNext()) {
        long startTime = System.nanoTime();
        DynmapChunk chunk = iterator.next();
        int chunkindex = (chunk.x - x_min) + (chunk.z - z_min) * x_dim;
        // Skip if already processed
        if (snaparray[chunkindex] != null)
            continue;
        boolean vis = isChunkVisible(chunk);
        /* Check if cached chunk snapshot found */
        if (tryChunkCache(chunk, vis)) {
            endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT);
        } else {
            CompoundNBT nbt = readChunk(chunk.x, chunk.z);
            // If read was good
            if (nbt != null) {
                ChunkSnapshot ss;
                DynIntHashMap tileData;
                // If hidden
                if (!vis) {
                    if (hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN) {
                        ss = STONE;
                    } else if (hidestyle == HiddenChunkStyle.FILL_OCEAN) {
                        ss = OCEAN;
                    } else {
                        ss = EMPTY;
                    }
                    tileData = new DynIntHashMap();
                } else {
                    // Prep snapshot
                    SnapshotRec ssr = prepChunkSnapshot(chunk, nbt);
                    ss = ssr.ss;
                    tileData = ssr.tileData;
                }
                snaparray[chunkindex] = ss;
                snaptile[chunkindex] = tileData;
                endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS);
            } else {
                endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS);
            }
        }
        cnt++;
    }
    DynmapCore.setIgnoreChunkLoads(false);
    if (iterator.hasNext() == false) /* If we're done */
    {
        isempty = true;
        /* Fill missing chunks with empty dummy chunk */
        for (int i = 0; i < snaparray.length; i++) {
            if (snaparray[i] == null) {
                snaparray[i] = EMPTY;
            } else if (snaparray[i] != EMPTY) {
                isempty = false;
            }
        }
    }
    return cnt;
}
Also used : DynmapChunk(org.dynmap.DynmapChunk) SnapshotRec(org.dynmap.forge_1_14_4.SnapshotCache.SnapshotRec) CompoundNBT(net.minecraft.nbt.CompoundNBT) DynIntHashMap(org.dynmap.utils.DynIntHashMap)

Aggregations

DynIntHashMap (org.dynmap.utils.DynIntHashMap)9 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 DynmapChunk (org.dynmap.DynmapChunk)6 SnapshotRec (org.dynmap.forge_1_12_2.SnapshotCache.SnapshotRec)4 SnapshotRec (org.dynmap.forge_1_14_4.SnapshotCache.SnapshotRec)4 SnapshotRec (org.dynmap.forge_1_15_2.SnapshotCache.SnapshotRec)4 ArrayList (java.util.ArrayList)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)3 INBT (net.minecraft.nbt.INBT)2 ListNBT (net.minecraft.nbt.ListNBT)2 ServerWorld (net.minecraft.world.server.ServerWorld)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 NBTBase (net.minecraft.nbt.NBTBase)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 NBTTagString (net.minecraft.nbt.NBTTagString)1