public async Task GenerateSingle(IWorld world, ChunkWorldPos chunkWorldPos, BlockWorldPos pos, BlockState state, int size) { int seed = await world.GetSeed(); int oreSeed = pos.X ^ pos.Z ^ seed ^ state.GetHashCode(); Random random = new Random(oreSeed); await GenerateImpl(world, chunkWorldPos, pos, state, size, random); }
public async Task Generate(IWorld world, ChunkWorldPos chunkWorldPos, BlockState blockState, int count, int size, int minHeight, int maxHeight) { int seed = await world.GetSeed(); BlockWorldPos curChunkCorner = chunkWorldPos.ToBlockWorldPos(); int chunkSeed = chunkWorldPos.X ^ chunkWorldPos.Z ^ seed ^ blockState.GetHashCode(); Random random = new Random(chunkSeed); if (minHeight > maxHeight) { int tmp = minHeight; minHeight = maxHeight; maxHeight = tmp; } else if (maxHeight == minHeight) { if (minHeight < 255) { ++maxHeight; } else { --minHeight; } } for (int j = 0; j < count; ++j) { BlockWorldPos blockpos = BlockWorldPos.Add( curChunkCorner, random.Next(16), random.Next(maxHeight - minHeight) + minHeight, random.Next(16)); await GenerateSingle(world, chunkWorldPos, blockpos, blockState, size); } }