public override void GenerateStructures(Chunk chunk) { int minX = chunk.pos.x - structure.negX; int maxX = chunk.pos.x + Env.ChunkSize + structure.posX; int minZ = chunk.pos.z - structure.negZ; int maxZ = chunk.pos.z + Env.ChunkSize + structure.posZ; for (int x = minX; x < maxX; x++) { for (int z = minZ; z < maxZ; z++) { Vector3Int pos = new Vector3Int(x, 0, z); float chanceAtPos = Randomization.Random(pos.GetHashCode(), 44, true); if (chance > chanceAtPos) { if (Randomization.Random(pos.Add(1, 0, 0).GetHashCode(), 44, true) > chanceAtPos && Randomization.Random(pos.Add(-1, 0, 0).GetHashCode(), 44, true) > chanceAtPos && Randomization.Random(pos.Add(0, 0, 1).GetHashCode(), 44, true) > chanceAtPos && Randomization.Random(pos.Add(0, 0, -1).GetHashCode(), 44, true) > chanceAtPos) { int height = terrainGen.GenerateTerrainForBlockColumn(chunk, x, z, true); structure.Build(world, chunk, new Vector3Int(x, height, z), this); } } } } }
public virtual void GenerateStructures(BlockPos chunkPos, TerrainGen terrainGen) { if (layerType != LayerType.Structure) { return; } if (customTerrainLayer) { customLayer.GenerateStructures(chunkPos, terrainGen); return; } int minX, maxX, minZ, maxZ; minX = chunkPos.x - structure.negX; maxX = chunkPos.x + Config.Env.ChunkSize + structure.posX; minZ = chunkPos.z - structure.negZ; maxZ = chunkPos.z + Config.Env.ChunkSize + structure.posZ; for (int x = minX; x < maxX; x++) { for (int z = minZ; z < maxZ; z++) { int percentChance = GetNoise(x, 0, z, 10, 100, 1); if (percentChance < chanceToSpawnBlock) { if (percentChance < GetNoise(x + 1, 0, z, 10, 100, 1) && percentChance < GetNoise(x - 1, 0, z, 10, 100, 1) && percentChance < GetNoise(x, 0, z + 1, 10, 100, 1) && percentChance < GetNoise(x, 0, z - 1, 10, 100, 1)) { int height = terrainGen.GenerateTerrainForBlockColumn(x, z, true); structure.Build(world, chunkPos, new BlockPos(x, height, z), this); } } } } }
public override void GenerateStructures(Chunk chunk, int layerIndex) { //if (chunk.pos.x!=-30 || chunk.pos.y!=30 || chunk.pos.z!=0) return; int minX = chunk.Pos.x; int maxX = chunk.Pos.x + Env.ChunkSize1; int minZ = chunk.Pos.z; int maxZ = chunk.Pos.z + Env.ChunkSize1; int structureID = 0; for (int x = minX; x <= maxX; x++) { for (int z = minZ; z <= maxZ; z++) { Vector3Int pos = new Vector3Int(x, 0, z); float chanceAtPos = Randomization.RandomPrecise(pos.GetHashCode(), 44); if (chance > chanceAtPos) { if (Randomization.RandomPrecise(pos.Add(1, 0, 0).GetHashCode(), 44) > chanceAtPos && Randomization.RandomPrecise(pos.Add(-1, 0, 0).GetHashCode(), 44) > chanceAtPos && Randomization.RandomPrecise(pos.Add(0, 0, 1).GetHashCode(), 44) > chanceAtPos && Randomization.RandomPrecise(pos.Add(0, 0, -1).GetHashCode(), 44) > chanceAtPos) { int xx = Helpers.Mod(x, Env.ChunkSize); int zz = Helpers.Mod(z, Env.ChunkSize); int height = Helpers.FastFloor(terrainGen.GetTerrainHeightForChunk(chunk, xx, zz)); if (chunk.Pos.y <= height && chunk.Pos.y + Env.ChunkSize1 >= height) { Vector3Int worldPos = new Vector3Int(x, height, z); structure.Build(chunk, structureID++, ref worldPos, this); } } } } } }