HELP!! Chunk Generation .getId() deprecated!

Discussion in 'Plugin Development' started by ice374, Dec 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ice374

    Sooo... i went and distributed a plugin, but it turns out that my method of chunk generation no longer works (as of 1.7.9_R.4?) .getId() is deprecated, and has been for atleast the past year, but now no terrain generates at all, heres a sample of the code, whats an alternate way of generating it?

    Code:java
    1. public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
    2. byte[] b = new byte[16*16*128];
    3. Random seed = new Random(world.getSeed());
    4. SimplexOctaveGenerator gen = new SimplexOctaveGenerator(seed, 8);
    5. gen.setScale(1/40.0);
    6.  
    7. for (int x=0; x<16; x++){
    8. for (int z=0; z<16; z++){
    9. int multiplier = 5;
    10. double noise = gen.noise(x+chunkX*16, z+chunkZ*16, 0.5, 0.5)*multiplier;
    11. for(int y=0; y<32+noise; y++){
    12. if(b[xyzToByte(x,y,z)] ==0)
    13. if(y == 0)
    14. b[xyzToByte(x,y,z)] = (byte) (Material.BEDROCK).getId();
    15. else
    16. b[xyzToByte(x,y,z)] = (byte) (Material.SNOW_BLOCK).getId();
    17. }
    18. for(int y=0; y<20; y++)
    19. {
    20. if(b[xyzToByte(x,y,z)] == 0)
    21. b[xyzToByte(x,y,z)] = (byte) (Material.STATIONARY_WATER).getId();
    22.  
    23. }
    24.  
    25. b[xyzToByte(x,0,z)] = (byte) (Material.BEDROCK.getId());
    26. }
    27. }
    28.  
    29. return b;
    30. }
    31.  
    32. //This converts relative chunk locations to bytes that can be written to the chunk
    33. public int xyzToByte(int x, int y, int z) {
    34. return (x * 16 + z) * 128 + y;
    35. }
    36.  


    it doesnt throw ANY errors.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2016
  2. Offline

    xize

    ice374
    Would World.regenerateChunk(x,z); not be more suitable?, Im not sure if it still takes the populators though.

    -edit renamed typo in the method-
     
  3. Offline

    ice374

    no such thing apparently, i suspect your getting world.regenerateChunk() or world.generateTree() mixed up?
     
  4. Offline

    xize

    ice374
    Edited it, I had indeed the wrong name in mind:p
     
  5. Offline

    ice374

    example of how regenerateChunk() works for my situation, I thought it was for, literally regenerating existing chunks?

    Ive created a new dimension, and this is meant to be the terrain, but the .getId() method is no longer working
     
  6. Offline

    xize

    ice374
    ah, so you mean that you want to force generating chunks on chunks who are not generated before?

    as far as I know to force a chunk to be generated you could do world.refreshChunk(x,z) I also thought getting the chunk with getChunkAt could already starts generating it but Im not to sure.

    howevever for just normal regenerating on existed chunks I would geuss regenerateChunk(x,z) works fine however Im not sure how it would effect when you use for example a custom generator, as for populators Im not sure these got generated to.

    but the regenerated chunk still seems to match with the seed as it seems.
     
Thread Status:
Not open for further replies.

Share This Page