Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public CustomTerrainGenerator(ICubicWorld world, final long seed) {
- final int selectorOctaves = 8;
- Random rnd = new Random(seed);
- IBuilder selector = NoiseSource.perlin().
- seed(rnd.nextLong()).
- frequency(8.55515/Math.pow(2, selectorOctaves)/(MAX_ELEV/64.0)).
- octaves(selectorOctaves).
- create();
- IBuilder low = NoiseSource.perlin().
- seed(rnd.nextLong()).
- frequency(684.412D/Math.pow(2, OCTAVES)/(MAX_ELEV/64.0)).
- octaves(OCTAVES).
- create();
- IBuilder high = NoiseSource.perlin().
- seed(rnd.nextLong()).
- frequency(684.412D/Math.pow(2, OCTAVES)/(MAX_ELEV/64.0)).
- octaves(OCTAVES).
- create();
- int heightmapOctaves = 10;
- double heightmapFreq = 200.0/Math.pow(2, heightmapOctaves)/(MAX_ELEV/64);
- IBuilder randomHeight2d = NoiseSource.perlin().
- seed(rnd.nextLong()).
- frequency(heightmapFreq, 0, heightmapFreq).
- octaves(heightmapOctaves).
- create().
- mulIf(NEGATIVE, -0.3).
- mul(3).sub(2).
- clamp(-2, 1).
- divIf(NEGATIVE, 2*2*1.4).
- divIf(NOT_NEGATIVE, 8).
- mul(0.2*17/64.0);
- BiomeHeightVolatilitySource biomeSource = new BiomeHeightVolatilitySource(
- world.getBiomeProvider(), 2*(int) (MAX_ELEV/64), X_SECTION_SIZE, Z_SECTION_SIZE);
- IBuilder height = biomeSource::getHeight;
- IBuilder volatility = biomeSource::getVolatility;
- this.terrainBuilder = selector.
- lerp(low, high).
- mul(volatility.div((x, y, z) -> (y*8/MAX_ELEV < height.get(x, y, z)) ? 4 : 1)).
- add(height).add(randomHeight2d).
- mul(MAX_ELEV).add(64).sub((x, y, z) -> y*8*MAX_ELEV);
- }
- public void generate(final ICubePrimer cubePrimer, int cubeX, int cubeY, int cubeZ) {
- CubePos cubePos = new CubePos(cubeX, cubeY, cubeZ);
- BlockPos start = cubePos.getMinBlockPos();
- BlockPos end = cubePos.getMaxBlockPos();
- terrainBuilder.scaledStream(start, end, new Vec3i(4, 8, 4)).
- forEach(e -> cubePrimer.setBlockState(e.getX(), e.getY(), e.getZ(), this.getState(e)));
- }
- private IBlockState getState(IBuilder.IEntry e) {
- return e.getValue() > 0 ? Blocks.AIR.getDefaultState() : Blocks.STONE.getDefaultState();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement