use of org.dynmap.utils.DynIntHashMap 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 {
NBTTagCompound 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;
}
use of org.dynmap.utils.DynIntHashMap in project dynmap by webbukkit.
the class ForgeMapChunkCache method prepChunkSnapshot.
// Prep snapshot and add to cache
private SnapshotRec prepChunkSnapshot(DynmapChunk chunk, CompoundNBT nbt) {
ChunkSnapshot ss = new ChunkSnapshot(nbt, dw.worldheight);
DynIntHashMap tileData = new DynIntHashMap();
ListNBT tiles = nbt.getList("TileEntities", 10);
if (tiles == null)
tiles = new ListNBT();
/* Get tile entity data */
List<Object> vals = new ArrayList<Object>();
for (int tid = 0; tid < tiles.size(); tid++) {
CompoundNBT tc = tiles.getCompound(tid);
int tx = tc.getInt("x");
int ty = tc.getInt("y");
int tz = tc.getInt("z");
int cx = tx & 0xF;
int cz = tz & 0xF;
DynmapBlockState blk = ss.getBlockType(cx, ty, cz);
String[] te_fields = HDBlockModels.getTileEntityFieldsNeeded(blk);
if (te_fields != null) {
vals.clear();
for (String id : te_fields) {
INBT v = tc.get(id);
/* Get field */
if (v != null) {
Object val = getNBTValue(v);
if (val != null) {
vals.add(id);
vals.add(val);
}
}
}
if (vals.size() > 0) {
Object[] vlist = vals.toArray(new Object[vals.size()]);
tileData.put(getIndexInChunk(cx, ty, cz), vlist);
}
}
}
SnapshotRec ssr = new SnapshotRec();
ssr.ss = ss;
ssr.tileData = tileData;
DynmapPlugin.plugin.sscache.putSnapshot(dw.getName(), chunk.x, chunk.z, ssr, blockdata, biome, biomeraw, highesty);
return ssr;
}
use of org.dynmap.utils.DynIntHashMap in project dynmap by webbukkit.
the class FluidStateRenderer method init.
private static final void init(RenderPatchFactory rpf) {
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
// Create meshes for flat topped blocks
meshcache = new DynIntHashMap();
for (int i = 0; i < 10; i++) {
list.clear();
CustomRenderer.addBox(rpf, list, 0.0, 1.0, 0.0, 1.0 - (i / 9.0), 0.0, 1.0, still_patches);
putCachedModel(9 - i, 9 - i, 9 - i, 9 - i, list.toArray(new RenderPatch[list.size()]));
}
bottom = rpf.getPatch(0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, SideVisible.TOP, PATCH_STILL);
// For full height, build culled cache - eliminate surfaces adjacent to other fluid blocks
fullculledcache = new DynIntHashMap();
RenderPatch[] fullblkmodel = getCachedModel(9, 9, 9, 9);
for (int i = 0; i < 64; i++) {
list.clear();
for (int f = 0; f < 6; f++) {
if ((i & (1 << f)) != 0) {
// Index by face list order: see which we need to keep (bit N=1 means keep face N patch)
list.add(fullblkmodel[f]);
}
}
fullculledcache.put(i, list.toArray(new RenderPatch[list.size()]));
}
}
use of org.dynmap.utils.DynIntHashMap in project dynmap by webbukkit.
the class ForgeMapChunkCache method prepChunkSnapshot.
// Prep snapshot and add to cache
private SnapshotRec prepChunkSnapshot(DynmapChunk chunk, NBTTagCompound nbt) {
ChunkSnapshot ss = new ChunkSnapshot(nbt, dw.worldheight);
DynIntHashMap tileData = new DynIntHashMap();
NBTTagList tiles = nbt.getTagList("TileEntities", 10);
if (tiles == null)
tiles = new NBTTagList();
/* Get tile entity data */
List<Object> vals = new ArrayList<Object>();
for (int tid = 0; tid < tiles.tagCount(); tid++) {
NBTTagCompound tc = tiles.getCompoundTagAt(tid);
int tx = tc.getInteger("x");
int ty = tc.getInteger("y");
int tz = tc.getInteger("z");
int cx = tx & 0xF;
int cz = tz & 0xF;
DynmapBlockState blk = ss.getBlockType(cx, ty, cz);
String[] te_fields = HDBlockModels.getTileEntityFieldsNeeded(blk);
if (te_fields != null) {
vals.clear();
for (String id : te_fields) {
NBTBase v = tc.getTag(id);
/* Get field */
if (v != null) {
Object val = getNBTValue(v);
if (val != null) {
vals.add(id);
vals.add(val);
}
}
}
if (vals.size() > 0) {
Object[] vlist = vals.toArray(new Object[vals.size()]);
tileData.put(getIndexInChunk(cx, ty, cz), vlist);
}
}
}
SnapshotRec ssr = new SnapshotRec();
ssr.ss = ss;
ssr.tileData = tileData;
DynmapPlugin.plugin.sscache.putSnapshot(dw.getName(), chunk.x, chunk.z, ssr, blockdata, biome, biomeraw, highesty);
return ssr;
}
use of org.dynmap.utils.DynIntHashMap 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;
}
Aggregations