@Override public Chunk provideChunk(int chunkX, int chunkZ) { rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L); biomesForGeneration = worldObj .getBiomeProvider() .loadBlockGeneratorData(biomesForGeneration, chunkX * 16, chunkZ * 16, 16, 16); ChunkPrimer primer = new ChunkPrimer(); setBlocksInChunk(primer); caveGenerator.generate(worldObj, chunkX, chunkZ, primer); if (CavelandConfig.generateRiver) { ravineGenerator.generate(worldObj, chunkX, chunkZ, primer); } replaceBiomeBlocks(chunkX, chunkZ, primer); Chunk chunk = new Chunk(worldObj, primer, chunkX, chunkZ); byte[] biomeArray = chunk.getBiomeArray(); for (int i = 0; i < biomeArray.length; ++i) { biomeArray[i] = (byte) Biome.getIdForBiome(biomesForGeneration[i]); } chunk.resetRelightChecks(); return chunk; }
@Override public Chunk provideChunk(int par1, int par2) { this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L); final Block[] ids = new Block[32768 * 2]; final byte[] meta = new byte[32768 * 2]; this.generateTerrain(par1, par2, ids, meta); this.createCraters(par1, par2, ids, meta); this.biomesForGeneration = this.worldObj .getWorldChunkManager() .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); this.replaceBlocksForBiome(par1, par2, ids, meta, this.biomesForGeneration); if (this.worldGenerators == null) { this.worldGenerators = this.getWorldGenerators(); } for (MapGenBaseMeta generator : this.worldGenerators) { generator.generate(this, this.worldObj, par1, par2, ids, meta); } this.onChunkProvide(par1, par2, ids, meta); final Chunk var4 = new Chunk(this.worldObj, ids, meta, par1, par2); final byte[] var5 = var4.getBiomeArray(); for (int var6 = 0; var6 < var5.length; ++var6) { var5[var6] = (byte) this.biomesForGeneration[var6].biomeID; } var4.generateSkylightMap(); return var4; }
public Chunk provideChunk(int i, int j) { field_913_j.setSeed((long) i * 0x4f9939f508L + (long) j * 0x1ef1565bd5L); byte abyte0[] = new byte[32768]; field_4179_v = worldObj_16 .getWorldChunkManager() .loadBlockGeneratorData(field_4179_v, i * 16, j * 16, 16, 16); double ad[] = BWG4WorldChunkManager.temperature; generateTerrain(i, j, abyte0, field_4179_v, ad); replaceBlocksForBiome(i, j, abyte0, field_4179_v); field_902_u.generate(this, worldObj_16, i, j, abyte0); if (mapFeaturesEnabled) { strongholdGenerator.generate(this, worldObj_16, i, j, abyte0); } Chunk chunk = new Chunk(worldObj_16, abyte0, i, j); byte abyte1[] = chunk.getBiomeArray(); for (int k = 0; k < abyte1.length; k++) { abyte1[k] = (byte) field_4179_v[k].biomeID; } chunk.generateSkylightMap(); return chunk; }
public Chunk provideChunk(int par1, int par2) { this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L); byte[] var3 = new byte[32768]; generateTerrain(par1, par2, var3); this.biomesForGeneration = this.worldObj .getWorldChunkManager() .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); replaceBlocksForBiome(par1, par2, var3, this.biomesForGeneration); this.caveGenerator.generate(this, this.worldObj, par1, par2, var3); this.ravineGenerator.generate(this, this.worldObj, par1, par2, var3); if (this.mapFeaturesEnabled) { this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, var3); this.villageGenerator.generate(this, this.worldObj, par1, par2, var3); this.strongholdGenerator.generate(this, this.worldObj, par1, par2, var3); this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, var3); } Chunk var4 = new Chunk(this.worldObj, var3, par1, par2); byte[] var5 = var4.getBiomeArray(); for (int var6 = 0; var6 < var5.length; var6++) { var5[var6] = ((byte) this.biomesForGeneration[var6].biomeID); } var4.generateSkylightMap(); return var4; }
public static S21PacketChunkData.Extracted func_179756_a( Chunk p_179756_0_, boolean p_179756_1_, boolean p_179756_2_, int p_179756_3_) { ExtendedBlockStorage[] aextendedblockstorage = p_179756_0_.getBlockStorageArray(); S21PacketChunkData.Extracted s21packetchunkdata$extracted = new S21PacketChunkData.Extracted(); List<ExtendedBlockStorage> list = Lists.<ExtendedBlockStorage>newArrayList(); for (int i = 0; i < aextendedblockstorage.length; ++i) { ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[i]; if (extendedblockstorage != null && (!p_179756_1_ || !extendedblockstorage.isEmpty()) && (p_179756_3_ & 1 << i) != 0) { s21packetchunkdata$extracted.dataSize |= 1 << i; list.add(extendedblockstorage); } } s21packetchunkdata$extracted.data = new byte [func_180737_a( Integer.bitCount(s21packetchunkdata$extracted.dataSize), p_179756_2_, p_179756_1_)]; int j = 0; for (ExtendedBlockStorage extendedblockstorage1 : list) { char[] achar = extendedblockstorage1.getData(); for (char c0 : achar) { s21packetchunkdata$extracted.data[j++] = (byte) (c0 & 255); s21packetchunkdata$extracted.data[j++] = (byte) (c0 >> 8 & 255); } } for (ExtendedBlockStorage extendedblockstorage2 : list) { j = func_179757_a( extendedblockstorage2.getBlocklightArray().getData(), s21packetchunkdata$extracted.data, j); } if (p_179756_2_) { for (ExtendedBlockStorage extendedblockstorage3 : list) { j = func_179757_a( extendedblockstorage3.getSkylightArray().getData(), s21packetchunkdata$extracted.data, j); } } if (p_179756_1_) { func_179757_a(p_179756_0_.getBiomeArray(), s21packetchunkdata$extracted.data, j); } return s21packetchunkdata$extracted; }
@Override public void write(ByteBuf out) { out.writeInt(worldId); out.writeInt(chunk.xPosition); out.writeInt(chunk.zPosition); out.writeInt(pos.x); out.writeShort(pos.y); out.writeInt(pos.z); out.writeBytes(chunk.getBiomeArray()); }
/** * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the * blocks for the specified chunk from the map seed and chunk seed */ @Override public Chunk provideChunk(int par1, int par2) { long time = System.currentTimeMillis(); this.rand.setSeed((long) par1 * 341873128712L + (long) par2 * 132897987541L); short[] abyte = new short[32768]; this.generateTerrain(par1, par2, abyte); this.biomesForGeneration = this.worldObj .getWorldChunkManager() .loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); // this.biomesForGeneration = new BiomeGenBase[] {BiomeGenBase.desert}; this.replaceBlocksForBiome(par1, par2, abyte, this.biomesForGeneration); // this.caveGenerator.generate((IChunkProvider)this, this.worldObj, par1, par2, abyte); // this.ravineGenerator.generate(this, this.worldObj, par1, par2, abyte); if (this.mapFeaturesEnabled) { // this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, abyte); // this.villageGenerator.generate(this, this.worldObj, par1, par2, abyte); // this.strongholdGenerator.generate(this, this.worldObj, par1, par2, abyte); // this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, abyte); } /*short[] ashort = new short[32768]; int yMax = 32768/256; for(int x = 0; x < 16; x++) { for(int z = 0; z < 16; z++) { for(int y = 0; y < yMax; y++) { int idx = y << 8 | z << 4 | x; int ido = x << 11 | z << 7 | y; ashort[idx] = abyte[ido]; } } }*/ Chunk chunk = new Chunk(this.worldObj, abyte, new byte[32768], par1, par2); byte[] abyte1 = chunk.getBiomeArray(); for (int k = 0; k < abyte1.length; ++k) { abyte1[k] = (byte) this.biomesForGeneration[k].biomeID; } chunk.generateSkylightMap(); // System.out.println("Providing Chunk: " + (System.currentTimeMillis() - time) + "ms"); return chunk; }
@Override public Chunk provideChunk(int i, int j) { this.rand.setSeed(i * 341873128712L + j * 132897987541L); byte[] var3 = new byte[32768]; this.biomesForGeneration = this.worldObj .getWorldChunkManager() .loadBlockGeneratorData(this.biomesForGeneration, i * 16, j * 16, 16, 16); this.generateTerrain(i, j, var3, this.biomesForGeneration, this.generatedTemperatures); this.replaceBlocksForBiome(i, j, var3, this.biomesForGeneration); this.caveGenerator.generate(this, this.worldObj, i, j, var3); Chunk var4 = new Chunk(this.worldObj, var3, i, j); byte[] var5 = var4.getBiomeArray(); for (int var6 = 0; var6 < var5.length; ++var6) { var5[var6] = (byte) this.biomesForGeneration[var6].biomeID; } var4.generateSkylightMap(); return var4; }
@Override public Chunk provideChunk(int x, int z) { rand.setSeed((long) x * 0x4f9939f508L + (long) z * 0x1ef1565bd5L); Block blocks[] = new Block[16 * dimension.heightLimit * 16]; Arrays.fill(blocks, Blocks.air); byte meta[] = new byte[16 * dimension.heightLimit * 16]; biomesForGeneration = worldObj .getWorldChunkManager() .getBiomesForGeneration(biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); for (TerrainLayer layer : dimension.terrainLayers) { generateTerrain(x, z, blocks, layer); } biomesForGeneration = worldObj .getWorldChunkManager() .loadBlockGeneratorData(biomesForGeneration, x * 16, z * 16, 16, 16); for (TerrainLayer layer : dimension.terrainLayers) { replaceBlocksForBiome(x, z, blocks, meta, biomesForGeneration, layer); } // caveGenerator.generate(this, worldObj, x, z, ids); // ravineGenerator.generate(this, worldObj, x, z, ids); Chunk chunk = new Chunk(worldObj, blocks, meta, x, z); byte[] biomes = chunk.getBiomeArray(); for (int k = 0; k < biomes.length; ++k) { biomes[k] = (byte) this.biomesForGeneration[k].biomeID; } chunk.generateSkylightMap(); if (dimension == Dimension.nether) { chunk.resetRelightChecks(); } return chunk; }
/** * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the * blocks for the specified chunk from the map seed and chunk seed */ public Chunk provideChunk(int p_73154_1_, int p_73154_2_) { this.hellRNG.setSeed((long) p_73154_1_ * 341873128712L + (long) p_73154_2_ * 132897987541L); Block[] var3 = new Block[32768]; this.func_147419_a(p_73154_1_, p_73154_2_, var3); this.func_147418_b(p_73154_1_, p_73154_2_, var3); this.netherCaveGenerator.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, var3); this.genNetherBridge.func_151539_a(this, this.worldObj, p_73154_1_, p_73154_2_, var3); Chunk var4 = new Chunk(this.worldObj, var3, p_73154_1_, p_73154_2_); BiomeGenBase[] var5 = this.worldObj .getWorldChunkManager() .loadBlockGeneratorData( (BiomeGenBase[]) null, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); byte[] var6 = var4.getBiomeArray(); for (int var7 = 0; var7 < var6.length; ++var7) { var6[var7] = (byte) var5[var7].biomeID; } var4.resetRelightChecks(); return var4; }
public static S21PacketChunkData.Extracted func_149269_a( Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_) { int j = 0; ExtendedBlockStorage[] aextendedblockstorage = p_149269_0_.getBlockStorageArray(); int k = 0; S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted(); byte[] abyte = field_149286_i; if (p_149269_1_) { p_149269_0_.sendUpdates = true; } int l; for (l = 0; l < aextendedblockstorage.length; ++l) { if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) { extracted.field_150280_b |= 1 << l; if (aextendedblockstorage[l].getBlockMSBArray() != null) { extracted.field_150281_c |= 1 << l; ++k; } } } for (l = 0; l < aextendedblockstorage.length; ++l) { if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) { byte[] abyte1 = aextendedblockstorage[l].getBlockLSBArray(); System.arraycopy(abyte1, 0, abyte, j, abyte1.length); j += abyte1.length; } } NibbleArray nibblearray; for (l = 0; l < aextendedblockstorage.length; ++l) { if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) { nibblearray = aextendedblockstorage[l].getMetadataArray(); System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); j += nibblearray.data.length; } } for (l = 0; l < aextendedblockstorage.length; ++l) { if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) { nibblearray = aextendedblockstorage[l].getBlocklightArray(); System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); j += nibblearray.data.length; } } if (!p_149269_0_.worldObj.provider.hasNoSky) { for (l = 0; l < aextendedblockstorage.length; ++l) { if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) { nibblearray = aextendedblockstorage[l].getSkylightArray(); System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); j += nibblearray.data.length; } } } if (k > 0) { for (l = 0; l < aextendedblockstorage.length; ++l) { if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && aextendedblockstorage[l].getBlockMSBArray() != null && (p_149269_2_ & 1 << l) != 0) { nibblearray = aextendedblockstorage[l].getBlockMSBArray(); System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); j += nibblearray.data.length; } } } if (p_149269_1_) { byte[] abyte2 = p_149269_0_.getBiomeArray(); System.arraycopy(abyte2, 0, abyte, j, abyte2.length); j += abyte2.length; } extracted.field_150282_a = new byte[j]; System.arraycopy(abyte, 0, extracted.field_150282_a, 0, j); return extracted; }
public Chunk getOrCreateChunk(int x, int z) { random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); Chunk chunk; // Get default biome data for chunk CustomBiomeGrid biomegrid = new CustomBiomeGrid(); biomegrid.biome = new BiomeGenBase[256]; world.getWorldChunkManager().getBiomeGenAt(biomegrid.biome, x << 4, z << 4, 16, 16, false); // Try extended block method (1.2+) short[][] xbtypes = generator.generateExtBlockSections( CraftServer.instance().getWorld(world.provider.dimensionId), this.random, x, z, biomegrid); if (xbtypes != null) { chunk = new Chunk(this.world, x, z); ExtendedBlockStorage[] csect = chunk.getBlockStorageArray(); int scnt = Math.min(csect.length, xbtypes.length); // Loop through returned sections for (int sec = 0; sec < scnt; sec++) { if (xbtypes[sec] == null) { continue; } byte[] secBlkID = new byte[4096]; // Allocate blk ID bytes byte[] secExtBlkID = (byte[]) null; // Delay getting extended ID nibbles short[] bdata = xbtypes[sec]; // Loop through data, 2 blocks at a time for (int i = 0, j = 0; i < bdata.length; i += 2, j++) { short b1 = bdata[i]; short b2 = bdata[i + 1]; byte extb = (byte) ((b1 >> 8) | ((b2 >> 4) & 0xF0)); secBlkID[i] = (byte) b1; secBlkID[(i + 1)] = (byte) b2; if (extb != 0) { // If extended block ID data if (secExtBlkID == null) { // Allocate if needed secExtBlkID = new byte[2048]; } secExtBlkID[j] = extb; } } // Build chunk section csect[sec] = new ExtendedBlockStorage(sec << 4, false); // , secBlkID, secExtBlkID); } } else { // Else check for byte-per-block section data byte[][] btypes = generator.generateBlockSections(getWorld(world), this.random, x, z, biomegrid); if (btypes != null) { chunk = new Chunk(this.world, x, z); ExtendedBlockStorage[] csect = chunk.getBlockStorageArray(); int scnt = Math.min(csect.length, btypes.length); for (int sec = 0; sec < scnt; sec++) { if (btypes[sec] == null) { continue; } csect[sec] = new ExtendedBlockStorage(sec << 4, false); // , btypes[sec], null); } } else { // Else, fall back to pre 1.2 method @SuppressWarnings("deprecation") byte[] types = generator.generate(getWorld(world), this.random, x, z); int ydim = types.length / 256; int scnt = ydim / 16; chunk = new Chunk(this.world, x, z); // Create empty chunk ExtendedBlockStorage[] csect = chunk.getBlockStorageArray(); scnt = Math.min(scnt, csect.length); // Loop through sections for (int sec = 0; sec < scnt; sec++) { ExtendedBlockStorage cs = null; // Add sections when needed byte[] csbytes = (byte[]) null; for (int cy = 0; cy < 16; cy++) { int cyoff = cy | (sec << 4); for (int cx = 0; cx < 16; cx++) { int cxyoff = (cx * ydim * 16) + cyoff; for (int cz = 0; cz < 16; cz++) { byte blk = types[cxyoff + (cz * ydim)]; if (blk != 0) { // If non-empty if (cs == null) { // If no section yet, get one cs = csect[sec] = new ExtendedBlockStorage(sec << 4, true); csbytes = cs.getBlockLSBArray(); } csbytes[(cy << 8) | (cz << 4) | cx] = blk; } } } } // If section built, finish prepping its state if (cs != null) { cs.getYLocation(); } } } } // Set biome grid byte[] biomeIndex = chunk.getBiomeArray(); for (int i = 0; i < biomeIndex.length; i++) { biomeIndex[i] = (byte) (biomegrid.biome[i].biomeID & 0xFF); } // Initialize lighting chunk.generateSkylightMap(); return chunk; }