Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TestChunkGenerator : ChunkGenerator() {
- val chunkSize = 16
- val sectorSize = 3
- private fun skyCast(chunkData: ChunkData, x: Int, z: Int): Int {
- var max = 128
- while (chunkData.getType(x, max, z) == Material.AIR) {
- max--
- if (max < 0) return 0
- }
- return max + 1
- }
- override fun generateChunkData(world: World, random: Random, x: Int, z: Int, biome: BiomeGrid) = createChunkData(world).apply {
- val noiseGen = SimplexOctaveGenerator(random, 5)
- for (practicalX in x..x + 15) {
- for (practicalZ in z..z + 15) {
- val noise = ((noiseGen.noise(practicalX.toDouble(), practicalZ.toDouble(), 0.5, 0.5, true) + 1) * 5.0 + 50.0)
- .toInt()
- setBlock(practicalX, 0, practicalZ, Material.BEDROCK)
- for (practicalY in 1 until noise) {
- setBlock(practicalX, practicalY, practicalZ, Material.DIRT)
- }
- setBlock(practicalX, noise, practicalZ, Material.GRASS_BLOCK)
- }
- }
- if (x % sectorSize == 0) {
- // why does the x need to be a multiple of 5?
- for (practicalX in 0 until chunkSize) {
- setRegion(0, 0, practicalX, 1, skyCast(this, practicalX, 0), x + 1, Material.WHITE_CONCRETE)
- }
- }
- if (z % sectorSize == 0) {
- for (practicalZ in 0 until chunkSize) {
- setRegion(z, 0, 0, z + 1, skyCast(this, 0, z), 1, Material.WHITE_CONCRETE)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment