Package org.bukkit.util.noise

Examples of org.bukkit.util.noise.OctaveGenerator


    }

    @Override
    public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
        Map<String, OctaveGenerator> octaves = getWorldOctaves(world);
        OctaveGenerator noiseHeight = octaves.get("height");
        OctaveGenerator noiseJitter = octaves.get("jitter");
        OctaveGenerator noiseType = octaves.get("type");

        chunkX <<= 4;
        chunkZ <<= 4;

        boolean nether = world.getEnvironment() == Environment.NETHER;
        Material matMain = nether ? Material.NETHERRACK : Material.DIRT;
        Material matShore = nether ? Material.SOUL_SAND : Material.SAND;
        Material matShore2 = Material.GRAVEL;
        Material matTop = nether ? Material.NETHERRACK : Material.GRASS;
        Material matUnder = nether ? Material.NETHERRACK : Material.STONE;
        Material matLiquid = nether ? Material.STATIONARY_LAVA : Material.STATIONARY_WATER;

        byte[] buf = start(Material.AIR);

        int baseHeight = WORLD_DEPTH / 2;
        double terrainHeight = 50;
        boolean noDirt = true;
        int waterLevel = WORLD_DEPTH / 2;

        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                int deep = 0;
                for (int y = (int) Math.min(baseHeight
                        + noiseHeight.noise(x + chunkX, z + chunkZ, 0.7, 0.6, true)
                        * terrainHeight
                        + noiseJitter.noise(x + chunkX, z + chunkZ, 0.5, 0.5)
                        * 1.5, WORLD_DEPTH - 1); y > 0; y--) {
                    double terrainType = noiseType.noise(x + chunkX, y, z + chunkZ, 0.5, 0.5);
                    Material ground = matTop;
                    if (Math.abs(terrainType) < random.nextDouble() / 3 && !noDirt) {
                        ground = matMain;
                    } else if (deep != 0 || y < waterLevel) {
                        ground = matMain;
View Full Code Here


        /* With default settings, this is 5 octaves. With tscale=256,terrainheight=50,
         * this comes out to 14 octaves, which makes more complex terrain at the cost
         * of more complex generation. Without this, the terrain looks bad, especially
         * on higher tscale/terrainheight pairs. */
        double value = Math.round(Math.sqrt(50 * 256.0 / (128 - 50)) * 1.1 - 0.2);
        OctaveGenerator gen = new SimplexOctaveGenerator(seed, Math.max((int) value, 5));
        gen.setScale(1 / 256.0);
        octaves.put("height", gen);

        gen = new SimplexOctaveGenerator(seed, gen.getOctaves().length / 2);
        gen.setScale(Math.min(256.0 / 1024, 1 / 32.0));
        octaves.put("jitter", gen);

        gen = new SimplexOctaveGenerator(seed, 2);
        gen.setScale(1 / WORLD_DEPTH);
        octaves.put("type", gen);
    }
View Full Code Here

    }

    @Override
    public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
        Map<String, OctaveGenerator> octaves = getWorldOctaves(world);
        OctaveGenerator noiseFloor = octaves.get("floor");
        OctaveGenerator noiseCeiling = octaves.get("ceiling");
        OctaveGenerator noiseJitter1 = octaves.get("jitter1");
        OctaveGenerator noiseJitter2 = octaves.get("jitter2");
        OctaveGenerator noiseStalactite = octaves.get("stalactite");
        OctaveGenerator noiseStalagmite = octaves.get("stalagmite");
        OctaveGenerator noisePlatform1 = octaves.get("platform1");
        OctaveGenerator noisePlatform2 = octaves.get("platform2");

        chunkX <<= 4;
        chunkZ <<= 4;

        Material stone = world.getEnvironment() == Environment.NETHER ? Material.NETHERRACK : Material.STONE;
        int height = WORLD_DEPTH;

        byte[] buf = start(stone);

        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                int min = (int) (Math.abs(noiseFloor.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 3)
                        + 5 + noiseJitter1.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 2
                        + convertPointyThings(noiseStalagmite, x + chunkX, z + chunkZ, height));
                int max = (int) (height - Math.abs(noiseCeiling.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 3)
                        - 5 + noiseJitter2.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 2 - random.nextInt(5)
                        - convertPointyThings(noiseStalactite, x + chunkX, z + chunkZ, height));

                if (min > 20) {
                    min -= random.nextInt(5);
                }

                if (min >= max) {
                    set(buf, x, 0, z, Material.BEDROCK);
                    set(buf, x, height - 1, z, Material.BEDROCK);
                    continue;
                }

                for (int y = min; y <= max; y++) {
                    set(buf, x, y, z, Material.AIR);
                }

                int platform = (int) (noisePlatform1.noise(x + chunkX, z + chunkZ, 0.5, 0.5, true) * 20 - 4);
                if (platform > 5) {
                    platform -= random.nextInt(3);
                }
                while (platform-- > 0) {
                    set(buf, x, height / 2 - platform - 1, z, stone);
                }

                platform = (int) (noisePlatform2.noise(x + chunkX, z + chunkZ, 0.5, 0.5, true) * 30 - 6);
                if (platform > 5) {
                    platform -= random.nextInt(3);
                }
                while (platform-- > 0) {
                    set(buf, x, height / 4 - platform - 1, z, stone);
View Full Code Here

    @Override
    protected void createWorldOctaves(World world, Map<String, OctaveGenerator> octaves) {
        Random seed = new Random(world.getSeed());

        OctaveGenerator gen = new SimplexOctaveGenerator(seed, 10);
        gen.setScale(1 / 64.0);
        octaves.put("floor", gen);

        gen = new SimplexOctaveGenerator(seed, 10);
        gen.setScale(1 / 64.0);
        octaves.put("ceiling", gen);

        gen = new SimplexOctaveGenerator(seed, 5);
        gen.setScale(1 / 32.0);
        octaves.put("jitter1", gen);

        gen = new SimplexOctaveGenerator(seed, 5);
        gen.setScale(1 / 32.0);
        octaves.put("jitter2", gen);

        gen = new SimplexOctaveGenerator(seed, 10);
        gen.setScale(1 / 32.0);
        octaves.put("stalactite", gen);

        gen = new SimplexOctaveGenerator(seed, 10);
        gen.setScale(1 / 48.0);
        octaves.put("stalagmite", gen);

        gen = new SimplexOctaveGenerator(seed, 7);
        gen.setScale(1 / 32.0);
        octaves.put("platform1", gen);

        gen = new SimplexOctaveGenerator(seed, 8);
        gen.setScale(1 / 96.0);
        octaves.put("platform2", gen);
    }
View Full Code Here

TOP

Related Classes of org.bukkit.util.noise.OctaveGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.