public DummyChunk(int chunksize) { Blocks = new DummyChunkData(chunksize); }
private bool SetBlocks(IServerChunk[] chunks, float horRadius, float vertRadius, double centerX, double centerY, double centerZ, ushort[] terrainheightmap, ushort[] rainheightmap, int chunkX, int chunkZ) { IMapChunk mapchunk = chunks[0].MapChunk; int chunkSize = worldgenBlockAccessor.ChunkSize; // One extra size for checking if we run into water horRadius++; vertRadius++; int mindx = (int)GameMath.Clamp(centerX - horRadius, 0, chunksize - 1); int maxdx = (int)GameMath.Clamp(centerX + horRadius + 1, 0, chunksize - 1); int mindy = (int)GameMath.Clamp(centerY - vertRadius * 0.7f, 1, worldheight - 1); int maxdy = (int)GameMath.Clamp(centerY + vertRadius + 1, 1, worldheight - 1); int mindz = (int)GameMath.Clamp(centerZ - horRadius, 0, chunksize - 1); int maxdz = (int)GameMath.Clamp(centerZ + horRadius + 1, 0, chunksize - 1); double xdistRel, ydistRel, zdistRel; double hRadiusSq = horRadius * horRadius; double vRadiusSq = vertRadius * vertRadius; double distortStrength = GameMath.Clamp(vertRadius / 4.0, 0, 0.1); bool foundWater = false; for (int lx = mindx; lx <= maxdx && !foundWater; lx++) { xdistRel = (lx - centerX) * (lx - centerX) / hRadiusSq; for (int lz = mindz; lz <= maxdz && !foundWater; lz++) { zdistRel = (lz - centerZ) * (lz - centerZ) / hRadiusSq; double heightrnd = (mapchunk.CaveHeightDistort[lz * chunksize + lx] - 127) * distortStrength; for (int y = mindy; y <= maxdy + 10 && !foundWater; y++) { double yDist = y - centerY; double heightOffFac = yDist > 0 ? heightrnd * heightrnd : 0; ydistRel = yDist * yDist / (vRadiusSq + heightOffFac); if (y > worldheight - 1 || xdistRel + ydistRel + zdistRel > 1.0) { continue; } int ly = y % chunksize; // dominionsmod foundWater = (chunks[y / chunksize].Blocks[(ly * chunksize + lz) * chunksize + lx] == saltWater || chunks[y / chunksize].Blocks[(ly * chunksize + lz) * chunksize + lx] == GlobalConfig.waterBlockId); } } } if (foundWater) { return(false); } horRadius--; vertRadius--; mindx = (int)GameMath.Clamp(centerX - horRadius, 0, chunksize - 1); maxdx = (int)GameMath.Clamp(centerX + horRadius + 1, 0, chunksize - 1); mindz = (int)GameMath.Clamp(centerZ - horRadius, 0, chunksize - 1); maxdz = (int)GameMath.Clamp(centerZ + horRadius + 1, 0, chunksize - 1); mindy = (int)GameMath.Clamp(centerY - vertRadius * 0.7f, 1, worldheight - 1); maxdy = (int)GameMath.Clamp(centerY + vertRadius + 1, 1, worldheight - 1); hRadiusSq = horRadius * horRadius; vRadiusSq = vertRadius * vertRadius; for (int lx = mindx; lx <= maxdx; lx++) { xdistRel = (lx - centerX) * (lx - centerX) / hRadiusSq; for (int lz = mindz; lz <= maxdz; lz++) { zdistRel = (lz - centerZ) * (lz - centerZ) / hRadiusSq; double heightrnd = (mapchunk.CaveHeightDistort[lz * chunksize + lx] - 127) * distortStrength; int surfaceY = terrainheightmap[lz * chunksize + lx]; for (int y = maxdy + 10; y >= mindy; y--) { double yDist = y - centerY; double heightOffFac = yDist > 0 ? heightrnd * heightrnd * Math.Min(1, Math.Abs(y - surfaceY) / 10.0) : 0; ydistRel = yDist * yDist / (vRadiusSq + heightOffFac); if (y > worldheight - 1 || xdistRel + ydistRel + zdistRel > 1.0) { continue; } IChunkBlocks chunkBlockData = chunks[y / chunksize].Blocks; int ly = y % chunksize; chunkBlockData[(ly * chunksize + lz) * chunksize + lx] = y < 12 ? GlobalConfig.lavaBlockId : blockId; if (terrainheightmap[lz * chunksize + lx] == y) { terrainheightmap[lz * chunksize + lx]--; rainheightmap[lz * chunksize + lx]--; } if (y == 11) { if (basaltNoise.Noise(chunkX * chunkSize + lx, chunkZ * chunkSize + lz) > 0.65) { chunkBlockData[(ly * chunksize + lz) * chunksize + lx] = GlobalConfig.basaltBlockId; terrainheightmap[lz * chunksize + lx] = Math.Max(terrainheightmap[lz * chunksize + lx], (ushort)11); rainheightmap[lz * chunksize + lx] = Math.Max(rainheightmap[lz * chunksize + lx], (ushort)11); } else { worldgenBlockAccessor.ScheduleBlockLightUpdate(new BlockPos(chunkX * chunkSize + lx, y, chunkZ * chunkSize + lz), airBlockId, GlobalConfig.lavaBlockId); } } } } } return(true); }