[WGEN] Create a Riverland

Discussion in 'Resources' started by Empty2k12, Nov 19, 2012.

Thread Status:
Not open for further replies.
  1. Hey Guys,
    in my Worldgeneration-tests I created this small fail:
    View attachment 11748
    I hope anyone can do someting with the code:
    Code:
    public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
        byte[] b = new byte[16*16*128];
        Random seed = new Random(world.getSeed());
        SimplexOctaveGenerator gen = new SimplexOctaveGenerator(seed, 8);
        SimplexOctaveGenerator gen2 = new SimplexOctaveGenerator(seed, 8);
        PerlinOctaveGenerator pln = new PerlinOctaveGenerator(seed, 8);
        gen.setScale(1/64.0);
        gen2.setScale(1/128.0);
        pln.setScale(0.00215D);
        for (int x=0; x<16; x++){
                    for (int z=0; z<16; z++){
                        double noise2 = Math.max(gen.noise(x+chunkX*16, z+chunkZ*16, 0.5, 0.5)*16, gen2.noise(x+chunkX*16, z+chunkZ*16, 0.7, 0.5));
                        double noise1 = noise2 + Math.E;
                        double noise = Math.sin(noise1) * 3;
                        for(int y=21; y<48.0D+noise; y++) {
                            b[xyzToByte(x, y, z)] = (byte)(Material.GRASS).getId();
                        }
                        for(int y=1; y<32+noise; y++){
                            if(b[xyzToByte(x,y,z)] ==0)
                            b[xyzToByte(x,y,z)] = (byte)(Material.STONE).getId();
                        }   
                        for(int y=0; y<1; y++) {
                            b[xyzToByte(x, y, z)] = (byte)(Material.BEDROCK).getId();
                        }
                    }
                   
                }
        return b;
        }
    PS: Can someone explain me what the thing with the D is. I saw is at other codes, but dont know what this mean!?

    Empty2k12
     
    jtjj222 likes this.
  2. Offline

    jtjj222

    The D makes sure java interprets it as a double, that way if you do any division in your code, it doesn't get rounded.
     
    Empty2k12 likes this.
Thread Status:
Not open for further replies.

Share This Page