public ChunkProviderLoadOrGenerate(World world, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { chunks = new Chunk[1024]; lastQueriedChunkXPos = unchecked((int) 0xc4653601); lastQueriedChunkZPos = unchecked((int) 0xc4653601); blankChunk = new EmptyChunk(world, new byte[32768], 0, 0); worldObj = world; chunkLoader = ichunkloader; chunkProvider = ichunkprovider; }
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { field_725_a = new HashSet(); id2ChunkMap = new HashMap(); field_727_f = new ArrayList(); field_724_b = new EmptyChunk(worldserver, new byte[32768], 0, 0); world = worldserver; field_729_d = ichunkloader; field_730_c = ichunkprovider; }
public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound) { int i = nbttagcompound.getInteger("xPos"); int j = nbttagcompound.getInteger("zPos"); var chunk = new Chunk(world, i, j); chunk.blocks = nbttagcompound.getByteArray("Blocks"); chunk.data = new NibbleArray(nbttagcompound.getByteArray("Data")); chunk.skylightMap = new NibbleArray(nbttagcompound.getByteArray("SkyLight")); chunk.blocklightMap = new NibbleArray(nbttagcompound.getByteArray("BlockLight")); chunk.heightMap = nbttagcompound.getByteArray("HeightMap"); chunk.isTerrainPopulated = nbttagcompound.getBoolean("TerrainPopulated"); if (!chunk.data.isValid()) { chunk.data = new NibbleArray(chunk.blocks.Length); } if (chunk.heightMap == null || !chunk.skylightMap.isValid()) { chunk.heightMap = new byte[256]; chunk.skylightMap = new NibbleArray(chunk.blocks.Length); chunk.func_353_b(); } if (!chunk.blocklightMap.isValid()) { chunk.blocklightMap = new NibbleArray(chunk.blocks.Length); chunk.func_348_a(); } NBTTagList nbttaglist = nbttagcompound.getTagList("Entities"); if (nbttaglist != null) { for (int k = 0; k < nbttaglist.tagCount(); k++) { var nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(k); Entity entity = EntityList.createEntityFromNBT(nbttagcompound1, world); chunk.hasEntities = true; if (entity != null) { chunk.addEntity(entity); } } } NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities"); if (nbttaglist1 != null) { for (int l = 0; l < nbttaglist1.tagCount(); l++) { var nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l); TileEntity tileentity = TileEntity.createAndLoadEntity(nbttagcompound2); if (tileentity != null) { chunk.func_349_a(tileentity); } } } return chunk; }
public static void storeChunkInCompound(Chunk chunk, World world, NBTTagCompound nbttagcompound) { world.checkSessionLock(); nbttagcompound.setInteger("xPos", chunk.xPosition); nbttagcompound.setInteger("zPos", chunk.zPosition); nbttagcompound.setLong("LastUpdate", world.getWorldTime()); nbttagcompound.setByteArray("Blocks", chunk.blocks); nbttagcompound.setByteArray("Data", chunk.data.data); nbttagcompound.setByteArray("SkyLight", chunk.skylightMap.data); nbttagcompound.setByteArray("BlockLight", chunk.blocklightMap.data); nbttagcompound.setByteArray("HeightMap", chunk.heightMap); nbttagcompound.setBoolean("TerrainPopulated", chunk.isTerrainPopulated); chunk.hasEntities = false; var nbttaglist = new NBTTagList(); for (int i = 0; i < chunk.entities.Length; i++) { Iterator iterator = chunk.entities[i].iterator(); do { if (!iterator.hasNext()) { goto label0; } var entity = (Entity) iterator.next(); chunk.hasEntities = true; var nbttagcompound1 = new NBTTagCompound(); if (entity.addEntityID(nbttagcompound1)) { nbttaglist.setTag(nbttagcompound1); } } while (true); } label0: nbttagcompound.setTag("Entities", nbttaglist); var nbttaglist1 = new NBTTagList(); NBTTagCompound nbttagcompound2; for (Iterator iterator1 = chunk.chunkTileEntityMap.values().iterator(); iterator1.hasNext(); nbttaglist1.setTag(nbttagcompound2)) { var tileentity = (TileEntity) iterator1.next(); nbttagcompound2 = new NBTTagCompound(); tileentity.writeToNBT(nbttagcompound2); } nbttagcompound.setTag("TileEntities", nbttaglist1); }
public void saveChunk(World world, Chunk chunk) { world.checkSessionLock(); try { DataOutputStream dataoutputstream = RegionFileCache.func_22120_d(field_22110_a, chunk.xPosition, chunk.zPosition); var nbttagcompound = new NBTTagCompound(); var nbttagcompound1 = new NBTTagCompound(); nbttagcompound.setTag("Level", nbttagcompound1); ChunkLoader.storeChunkInCompound(chunk, world, nbttagcompound1); CompressedStreamTools.func_771_a(nbttagcompound, dataoutputstream); dataoutputstream.close(); WorldInfo worldinfo = world.getWorldInfo(); worldinfo.func_22177_b(worldinfo.func_22182_g() + RegionFileCache.func_22121_b(field_22110_a, chunk.xPosition, chunk.zPosition)); } catch (Exception exception) { exception.printStackTrace(); } }
public Chunk provideChunk(int i, int j) { rand.setSeed(i*0x4f9939f508L + j*0x1ef1565bd5L); var abyte0 = new byte[32768]; var chunk = new Chunk(worldObj, abyte0, i, j); biomesForGeneration = worldObj.getWorldChunkManager().loadBlockGeneratorData(biomesForGeneration, i*16, j*16, 16, 16); double[] ad = worldObj.getWorldChunkManager().temperature; generateTerrain(i, j, abyte0, biomesForGeneration, ad); replaceBlocksForBiome(i, j, abyte0, biomesForGeneration); field_695_u.func_667_a(this, worldObj, i, j, abyte0); chunk.func_353_b(); return chunk; }
public Chunk provideChunk(int i, int j) { if (i == lastQueriedChunkXPos && j == lastQueriedChunkZPos && lastQueriedChunk != null) { return lastQueriedChunk; } if (!worldObj.field_9209_x && !func_21111_c(i, j)) { return blankChunk; } int k = i & 0x1f; int l = j & 0x1f; int i1 = k + l*32; if (!chunkExists(i, j)) { if (chunks[i1] != null) { chunks[i1].onChunkUnload(); saveChunk(chunks[i1]); saveExtraChunkData(chunks[i1]); } Chunk chunk = func_4059_c(i, j); if (chunk == null) { if (chunkProvider == null) { chunk = blankChunk; } else { chunk = chunkProvider.provideChunk(i, j); } } chunks[i1] = chunk; chunk.func_4053_c(); if (chunks[i1] != null) { chunks[i1].onChunkLoad(); } if (!chunks[i1].isTerrainPopulated && chunkExists(i + 1, j + 1) && chunkExists(i, j + 1) && chunkExists(i + 1, j)) { populate(this, i, j); } if (chunkExists(i - 1, j) && !provideChunk(i - 1, j).isTerrainPopulated && chunkExists(i - 1, j + 1) && chunkExists(i, j + 1) && chunkExists(i - 1, j)) { populate(this, i - 1, j); } if (chunkExists(i, j - 1) && !provideChunk(i, j - 1).isTerrainPopulated && chunkExists(i + 1, j - 1) && chunkExists(i, j - 1) && chunkExists(i + 1, j)) { populate(this, i, j - 1); } if (chunkExists(i - 1, j - 1) && !provideChunk(i - 1, j - 1).isTerrainPopulated && chunkExists(i - 1, j - 1) && chunkExists(i, j - 1) && chunkExists(i - 1, j)) { populate(this, i - 1, j - 1); } } lastQueriedChunkXPos = i; lastQueriedChunkZPos = j; lastQueriedChunk = chunks[i1]; return chunks[i1]; }
private void saveExtraChunkData(Chunk chunk) { if (chunkLoader == null) { return; } try { chunkLoader.saveExtraChunkData(worldObj, chunk); } catch (Exception exception) { exception.printStackTrace(); } }
private void saveChunk(Chunk chunk) { if (chunkLoader == null) { return; } chunk.lastSaveTime = worldObj.getWorldTime(); chunkLoader.saveChunk(worldObj, chunk); }
public Chunk provideChunk(int i, int j) { hellRNG.setSeed(i*0x4f9939f508L + j*0x1ef1565bd5L); var abyte0 = new byte[32768]; func_4062_a(i, j, abyte0); func_4061_b(i, j, abyte0); field_4230_s.func_667_a(this, field_4235_n, i, j, abyte0); var chunk = new Chunk(field_4235_n, abyte0, i, j); return chunk; }
public void saveExtraChunkData(World world, Chunk chunk) { }
public void saveChunk(World world, Chunk chunk) { world.checkSessionLock(); File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition); if (file.exists()) { WorldInfo worldinfo = world.getWorldInfo(); worldinfo.func_22177_b(worldinfo.func_22182_g() - file.length()); } try { var file1 = new File(saveDir, "tmp_chunk.dat"); var fileoutputstream = new FileOutputStream(file1); var nbttagcompound = new NBTTagCompound(); var nbttagcompound1 = new NBTTagCompound(); nbttagcompound.setTag("Level", nbttagcompound1); storeChunkInCompound(chunk, world, nbttagcompound1); CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, fileoutputstream); fileoutputstream.close(); if (file.exists()) { file.delete(); } file1.renameTo(file); WorldInfo worldinfo1 = world.getWorldInfo(); worldinfo1.func_22177_b(worldinfo1.func_22182_g() + file.length()); } catch (Exception exception) { exception.printStackTrace(); } }
public Chunk provideChunk(int i, int j) { if (i == lastQueriedChunkXPos && j == lastQueriedChunkZPos && lastQueriedChunk != null) { return(lastQueriedChunk); } if (!worldObj.field_9209_x && !func_21111_c(i, j)) { return(blankChunk); } int k = i & 0x1f; int l = j & 0x1f; int i1 = k + l * 32; if (!chunkExists(i, j)) { if (chunks[i1] != null) { chunks[i1].onChunkUnload(); saveChunk(chunks[i1]); saveExtraChunkData(chunks[i1]); } Chunk chunk = func_4059_c(i, j); if (chunk == null) { if (chunkProvider == null) { chunk = blankChunk; } else { chunk = chunkProvider.provideChunk(i, j); } } chunks[i1] = chunk; chunk.func_4053_c(); if (chunks[i1] != null) { chunks[i1].onChunkLoad(); } if (!chunks[i1].isTerrainPopulated && chunkExists(i + 1, j + 1) && chunkExists(i, j + 1) && chunkExists(i + 1, j)) { populate(this, i, j); } if (chunkExists(i - 1, j) && !provideChunk(i - 1, j).isTerrainPopulated&& chunkExists(i - 1, j + 1) && chunkExists(i, j + 1) && chunkExists(i - 1, j)) { populate(this, i - 1, j); } if (chunkExists(i, j - 1) && !provideChunk(i, j - 1).isTerrainPopulated&& chunkExists(i + 1, j - 1) && chunkExists(i, j - 1) && chunkExists(i + 1, j)) { populate(this, i, j - 1); } if (chunkExists(i - 1, j - 1) && !provideChunk(i - 1, j - 1).isTerrainPopulated&& chunkExists(i - 1, j - 1) && chunkExists(i, j - 1) && chunkExists(i - 1, j)) { populate(this, i - 1, j - 1); } } lastQueriedChunkXPos = i; lastQueriedChunkZPos = j; lastQueriedChunk = chunks[i1]; return(chunks[i1]); }
private void func_375_a(Chunk chunk) { if (field_729_d == null) { return; } try { field_729_d.saveExtraChunkData(world, chunk); } catch (Exception exception) { exception.printStackTrace(); } }
private void func_373_b(Chunk chunk) { if (field_729_d == null) { return; } chunk.lastSaveTime = world.getWorldTime(); field_729_d.saveChunk(world, chunk); }