void NetherGen::generateChunk(int x, int z, int map) { NBT_Value* main = new NBT_Value(NBT_Value::TAG_COMPOUND); NBT_Value* val = new NBT_Value(NBT_Value::TAG_COMPOUND); val->Insert("Sections", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("HeightMap", new NBT_Value(heightmap)); val->Insert("Entities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("TileEntities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("LastUpdate", new NBT_Value((int64_t)time(NULL))); val->Insert("xPos", new NBT_Value(x)); val->Insert("zPos", new NBT_Value(z)); val->Insert("TerrainPopulated", new NBT_Value((char)1)); main->Insert("Level", val); /* uint32_t chunkid; ServerInstance->map()->posToId(x, z, &chunkid); ServerInstance->map()->maps[chunkid].x = x; ServerInstance->map()->maps[chunkid].z = z; */ sChunk* chunk = new sChunk(); //chunk->blocks = &((*t_blocks)[0]); //chunk->data = &((*t_data)[0]); //chunk->blocklight = &((*t_blocklight)[0]); //chunk->skylight = &((*t_skylight)[0]); chunk->heightmap = &(heightmap[0]); chunk->nbt = main; chunk->x = x; chunk->z = z; ServerInstance->map(map)->chunks.insert(ChunkMap::value_type(ChunkMap::key_type(x, z), chunk)); memset(chunk->blocks, 0, 16*16*256); memset(chunk->addblocks, 0, 16*16*256/2); memset(chunk->data, 0, 16*16*256/2); memset(chunk->blocklight, 0, 16*16*256/2); memset(chunk->skylight, 0, 16*16*256/2); chunk->chunks_present = 0xffff; generateWithNoise(x, z, map); // Update last used time //ServerInstance->map()->mapLastused[chunkid] = (int)time(0); // Not changed //ServerInstance->map()->mapChanged[chunkid] = ServerInstance->config()->bData("save_unchanged_chunks"); //ServerInstance->map()->maps[chunkid].nbt = main; if (addOre) { AddOre(x, z, map, BLOCK_GLOWSTONE); AddOre(x, z, map, BLOCK_STATIONARY_LAVA); } // Add trees if (addTrees) { AddTrees(x, z, map, fastrand() % 2 + 3); } if (expandBeaches) { ExpandBeaches(x, z, map); } }
void HeavenGen::generateChunk(int x, int z, int map) { NBT_Value* main = new NBT_Value(NBT_Value::TAG_COMPOUND); NBT_Value* val = new NBT_Value(NBT_Value::TAG_COMPOUND); generateWithNoise(x, z, map); val->Insert("Blocks", new NBT_Value(heavenblocks)); val->Insert("Data", new NBT_Value(blockdata)); val->Insert("SkyLight", new NBT_Value(skylight)); val->Insert("BlockLight", new NBT_Value(blocklight)); val->Insert("HeightMap", new NBT_Value(heightmap)); val->Insert("Entities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("TileEntities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("LastUpdate", new NBT_Value((int64_t)time(NULL))); val->Insert("xPos", new NBT_Value(x)); val->Insert("zPos", new NBT_Value(z)); val->Insert("TerrainPopulated", new NBT_Value((char)1)); main->Insert("Level", val); /* uint32_t chunkid; Mineserver::get()->map()->posToId(x, z, &chunkid); Mineserver::get()->map()->maps[chunkid].x = x; Mineserver::get()->map()->maps[chunkid].z = z; */ std::vector<uint8_t> *t_blocks = (*val)["Blocks"]->GetByteArray(); std::vector<uint8_t> *t_data = (*val)["Data"]->GetByteArray(); std::vector<uint8_t> *t_blocklight = (*val)["BlockLight"]->GetByteArray(); std::vector<uint8_t> *t_skylight = (*val)["SkyLight"]->GetByteArray(); std::vector<uint8_t> *heightmap = (*val)["HeightMap"]->GetByteArray(); sChunk* chunk = new sChunk(); chunk->blocks = &((*t_blocks)[0]); chunk->data = &((*t_data)[0]); chunk->blocklight = &((*t_blocklight)[0]); chunk->skylight = &((*t_skylight)[0]); chunk->heightmap = &((*heightmap)[0]); chunk->nbt = main; chunk->x = x; chunk->z = z; Mineserver::get()->map(map)->chunks.linkChunk(chunk, x, z); // Update last used time //Mineserver::get()->map()->mapLastused[chunkid] = (int)time(0); // Not changed //Mineserver::get()->map()->mapChanged[chunkid] = Mineserver::get()->config()->bData("save_unchanged_chunks"); //Mineserver::get()->map()->maps[chunkid].nbt = main; if (addOre) { AddOre(x, z, map, BLOCK_STATIONARY_WATER); } // Add trees if (addTrees) { AddTrees(x, z, map, fastrand() % 2 + 3); } if (expandBeaches) { ExpandBeaches(x, z, map); } }
void MapGen::generateChunk(int x, int z, int map) { NBT_Value *main = new NBT_Value(NBT_Value::TAG_COMPOUND); NBT_Value *val = new NBT_Value(NBT_Value::TAG_COMPOUND); val->Insert("Blocks", new NBT_Value(blocks)); val->Insert("Data", new NBT_Value(blockdata)); val->Insert("SkyLight", new NBT_Value(skylight)); val->Insert("BlockLight", new NBT_Value(blocklight)); val->Insert("HeightMap", new NBT_Value(heightmap)); val->Insert("Entities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("TileEntities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("LastUpdate", new NBT_Value((int64_t)time(NULL))); val->Insert("xPos", new NBT_Value(x)); val->Insert("zPos", new NBT_Value(z)); val->Insert("TerrainPopulated", new NBT_Value((int8_t)1)); main->Insert("Level", val); /* uint32_t chunkid; Mineserver::get()->map()->posToId(x, z, &chunkid); Mineserver::get()->map()->maps[chunkid].x = x; Mineserver::get()->map()->maps[chunkid].z = z; */ std::vector<uint8_t> *t_blocks = (*val)["Blocks"]->GetByteArray(); std::vector<uint8_t> *t_data = (*val)["Data"]->GetByteArray(); std::vector<uint8_t> *t_blocklight = (*val)["BlockLight"]->GetByteArray(); std::vector<uint8_t> *t_skylight = (*val)["SkyLight"]->GetByteArray(); std::vector<uint8_t> *heightmap = (*val)["HeightMap"]->GetByteArray(); sChunk *chunk = new sChunk(); chunk->blocks = &((*t_blocks)[0]); chunk->data = &((*t_data)[0]); chunk->blocklight = &((*t_blocklight)[0]); chunk->skylight = &((*t_skylight)[0]); chunk->heightmap = &((*heightmap)[0]); chunk->nbt = main; chunk->x = x; chunk->z = z; Mineserver::get()->map(map)->chunks.linkChunk(chunk, x, z); if(Mineserver::get()->config()->bData("mapgen.flatgrass")) generateFlatgrass(x, z, map); else generateWithNoise(x, z, map); // Update last used time //Mineserver::get()->map()->mapLastused[chunkid] = (int)time(0); // Not changed chunk->changed = Mineserver::get()->config()->bData("map.save_unchanged_chunks"); //Mineserver::get()->map()->maps[chunkid].nbt = main; if(addOre) { AddOre(x, z, map, BLOCK_COAL_ORE); AddOre(x, z, map, BLOCK_IRON_ORE); AddOre(x, z, map, BLOCK_GOLD_ORE); AddOre(x, z, map, BLOCK_DIAMOND_ORE); AddOre(x, z, map, BLOCK_REDSTONE_ORE); AddOre(x, z, map, BLOCK_LAPIS_ORE); } AddOre(x, z, map, BLOCK_GRAVEL); // Add trees if(addTrees) AddTrees(x, z, map); // add trees will make a *kind-of* forest of 16*16 chunks if(expandBeaches) ExpandBeaches(x, z, map); }
void BiomeGen::generateChunk(int x, int z, int map) { NBT_Value* main = new NBT_Value(NBT_Value::TAG_COMPOUND); NBT_Value* val = new NBT_Value(NBT_Value::TAG_COMPOUND); val->Insert("Sections", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("HeightMap", new NBT_Value(heightmap)); val->Insert("Entities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("TileEntities", new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND)); val->Insert("LastUpdate", new NBT_Value((int64_t)time(NULL))); val->Insert("xPos", new NBT_Value(x)); val->Insert("zPos", new NBT_Value(z)); val->Insert("TerrainPopulated", new NBT_Value((int8_t)1)); main->Insert("Level", val); sChunk* chunk = new sChunk(); //chunk->blocks = new uint8_t[16 * 16 * 256]; //chunk->addblocks = new uint8_t[16 * 16 * 256 / 2]; //chunk->data = new uint8_t[16 * 16 * 256 / 2]; //chunk->blocklight = new uint8_t[16 * 16 * 256 / 2]; //chunk->skylight = new uint8_t[16 * 16 * 256 / 2]; chunk->heightmap = &((*(*val)["HeightMap"]->GetIntArray())[0]); heightmap_pointer = chunk->heightmap; chunk->nbt = main; chunk->x = x; chunk->z = z; memset(chunk->blocks, 0, 16*16*256); memset(chunk->addblocks, 0, 16*16*256/2); memset(chunk->data, 0, 16*16*256/2); memset(chunk->blocklight, 0, 16*16*256/2); memset(chunk->skylight, 0, 16*16*256/2); chunk->chunks_present = 0xffff; ServerInstance->map(map)->chunks.insert(ChunkMap::value_type(ChunkMap::key_type(x, z), chunk)); if (ServerInstance->config()->bData("mapgen.flatgrass")) { generateFlatgrass(x, z, map); } else { generateWithNoise(x, z, map); } // Update last used time //ServerInstance->map()->mapLastused[chunkid] = (int)time(0); // Not changed chunk->changed = ServerInstance->config()->bData("map.save_unchanged_chunks"); //ServerInstance->map()->maps[chunkid].nbt = main; if (addOre) { AddOre(x, z, map, BLOCK_COAL_ORE); AddOre(x, z, map, BLOCK_IRON_ORE); AddOre(x, z, map, BLOCK_GOLD_ORE); AddOre(x, z, map, BLOCK_DIAMOND_ORE); AddOre(x, z, map, BLOCK_REDSTONE_ORE); AddOre(x, z, map, BLOCK_LAPIS_ORE); } AddOre(x, z, map, BLOCK_GRAVEL); // Add trees if (addTrees) { AddTrees(x, z, map); // add trees will make a *kind-of* forest of 16*16 chunks } }