ArrayOutOfBounds in Biomegrid

Discussion in 'Plugin Development' started by whereisthemonkey, Apr 13, 2016.

Thread Status:
Not open for further replies.
  1. Hey together, I am currently trying to generate chunk data with the following code:

    2. @Override
    3. public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
    4. //ChunkData data = createChunkData(world);
    5. System.out.println(chunkX);
    6. System.out.println(chunkZ);
    7. switch (random.nextInt(11)) {
    8. case 0:
    9. biome.setBiome(chunkX, chunkZ, Biome.BIRCH_FOREST);
    10. break;
    11. case 1:
    12. biome.setBiome(chunkX, chunkZ, Biome.COLD_TAIGA);
    13. break;
    14. case 2:
    15. biome.setBiome(chunkX, chunkZ, Biome.DESERT);
    16. break;
    17. case 3:
    18. biome.setBiome(chunkX, chunkZ, Biome.EXTREME_HILLS);
    19. break;
    20. case 4:
    21. biome.setBiome(chunkX, chunkZ, Biome.FLOWER_FOREST);
    22. break;
    23. case 5:
    24. biome.setBiome(chunkX, chunkZ, Biome.FOREST);
    25. break;
    26. case 6:
    27. biome.setBiome(chunkX, chunkZ, Biome.JUNGLE);
    28. break;
    29. case 7:
    30. biome.setBiome(chunkX, chunkZ, Biome.PLAINS);
    31. break;
    32. case 8:
    33. biome.setBiome(chunkX, chunkZ, Biome.SAVANNA);
    34. break;
    35. case 9:
    36. biome.setBiome(chunkX, chunkZ, Biome.SUNFLOWER_PLAINS);
    37. break;
    38. case 10:
    39. biome.setBiome(chunkX, chunkZ, Biome.TAIGA);
    40. break;
    41. default:
    42. biome.setBiome(chunkX, chunkZ, Biome.PLAINS);
    43. break;
    44. }
    45. return (ChunkData) world.getChunkAt(chunkX, chunkZ).getChunkSnapshot();
    46. }

    I looked at the Biomegrid class and saw that it is an array of 256 length. My question now is, how can I fix this error:

    2. Error occurred while enabling ProsperityRush v1.0 (Is it up to date?)
    3. net.minecraft.server.v1_8_R3.ReportedException: Exception generating new chunk
    4. at net.minecraft.server.v1_8_R3.ChunkProviderServer.originalGetChunkAt( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    5. at net.minecraft.server.v1_8_R3.ChunkProviderServer.getChunkAt( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    6. at net.minecraft.server.v1_8_R3.ChunkProviderServer.getChunkAt( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    7. at org.bukkit.craftbukkit.v1_8_R3.CraftServer.createWorld( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    8. at org.bukkit.Bukkit.createWorld( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    9. at org.bukkit.WorldCreator.createWorld( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    10. at me.whereisthemonkey.ProsperityRush.Parcel.ParcelWorld.<init>( ~[?:?]
    11. at me.whereisthemonkey.ProsperityRush.ProsperityRush.onEnable( ~[?:?]
    12. at ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    13. at [spigot.jar:git-Spigot-db6de12-18fbb24]
    14. at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot.jar:git-Spigot-db6de12-18fbb24]
    15. at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin( [spigot.jar:git-Spigot-db6de12-18fbb24]
    16. at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins( [spigot.jar:git-Spigot-db6de12-18fbb24]
    17. at net.minecraft.server.v1_8_R3.MinecraftServer.s( [spigot.jar:git-Spigot-db6de12-18fbb24]
    18. at net.minecraft.server.v1_8_R3.MinecraftServer.k( [spigot.jar:git-Spigot-db6de12-18fbb24]
    19. at net.minecraft.server.v1_8_R3.MinecraftServer.a( [spigot.jar:git-Spigot-db6de12-18fbb24]
    20. at net.minecraft.server.v1_8_R3.DedicatedServer.init( [spigot.jar:git-Spigot-db6de12-18fbb24]
    21. at [spigot.jar:git-Spigot-db6de12-18fbb24]
    22. at Source) [?:1.8.0_65]
    23. Caused by: java.lang.ArrayIndexOutOfBoundsException: -13
    24. at org.bukkit.craftbukkit.v1_8_R3.generator.CustomChunkGenerator$CustomBiomeGrid.setBiome( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    25. at me.whereisthemonkey.ProsperityRush.Parcel.Generators.HillParcelGenerator.generateChunkData( ~[?:?]
    26. at org.bukkit.craftbukkit.v1_8_R3.generator.CustomChunkGenerator.getOrCreateChunk( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    27. at net.minecraft.server.v1_8_R3.ChunkProviderServer.originalGetChunkAt( ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    28. ... 18 more

    Which x and y should I use and could anyone please help me out?

    Thank you very much,
  2. Offline


    What is line 73 from call HillParcelGenerator? It seems you are trying to get a negitive index at that line.
  3. I know what I am doing, line 73 is setBiome which calls an Array. The Out of Bounds is called because an Array can't as we both know be called ad a negative value like Array[-13]. My question was what could i possibly do wrong and how can I do it right?
  4. Offline


    Print out what the random is equal to, and what each Biome value is equal to.
  5. @Zombie_Striker Hey, the random works fine I already did all you do ;)
    What I guess is that I am using the generateChunkData function wrong, but there is no tutorial so I was hoping somebody could help me out
  6. Offline


  7. Last edited by a moderator: Apr 15, 2016
  8. Offline


    @whereisthemonkey Did you really read it?

    Have a look at the parameters of ChunkGenerator#generateChunkData and the ones from BiomeGrid.
  9. Offline


    ArrayOutOfBound means the element you are asking for does not exist.

    Can you show me the class and this line:

  10. @Jero
    2. biome.setBiome(chunkX, chunkZ, Biome.JUNGLE);

    I know that the problem is cause by calling the element -13 from the ArrayList biomes[256]

    Thanks for your quick reply!

    @mcdorli If you did it so many times I would highly appreciate it if you share your knowledge with me! Thank you!
  11. Offline


    Yeah, BiomeGrid#setBiome takes in arguments relative to the chunk, and not the chunk's coordinates. You need to give it a value between 0 and 15.

    And oohhh...look at it what i says on the 2nd method declaration
    MisterErwin likes this.
Thread Status:
Not open for further replies.

Share This Page