Solved Can't understand why this BlockPopulator Fails

Discussion in 'Plugin Development' started by SlimeyDerp, Mar 28, 2020.

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

    SlimeyDerp

    Code:java
    1.  
    2. public class OrePopulator extends BlockPopulator {
    3.  
    4. @Override
    5. public void populate(World world, Random random, Chunk chunk) {
    6. int X, Y, Z;
    7. boolean isStone;
    8. for (int i = 1; i < 15; i++) { // Number of tries
    9. if (random.nextInt(100) < 20) { // The chance of spawning
    10. X = random.nextInt(15);
    11. Z = random.nextInt(15);
    12. Y = random.nextInt(40) + 20; // Get randomized coordinates
    13. if (chunk.getBlock(X, Y, Z).getType() == Material.END_STONE) {
    14. isStone = true;
    15. while (isStone) {
    16. chunk.getBlock(X, Y, Z).setType(Material.DIAMOND_ORE);
    17. if (random.nextInt(100) < 40) { // The chance of continuing the vein
    18. switch (random.nextInt(5)) { // The direction chooser
    19. case 0:
    20. X++;
    21. break;
    22. case 1:
    23. Y++;
    24. break;
    25. case 2:
    26. Z++;
    27. break;
    28. case 3:
    29. X--;
    30. break;
    31. case 4:
    32. Y--;
    33. break;
    34. case 5:
    35. Z--;
    36. break;
    37. }
    38. isStone = (chunk.getBlock(X, Y, Z).getType() == Material.END_STONE) && (chunk.getBlock(X, Y, Z).getType() != Material.DIAMOND_ORE);
    39. } else isStone = false;
    40. }
    41. }
    42. }
    43. }
    44. }
    45. }
    46.  


    The block population throws this error:

    [17:17:03] [Server thread/ERROR]: Error occurred while enabling BeyondHorizons v1.0.1 (Is it up to date?)
    net.minecraft.server.v1_15_R1.ReportedException: Exception initializing level
    at net.minecraft.server.v1_15_R1.MinecraftServer.initWorld(MinecraftServer.java:516) ~[patched_1.15.2.jar:git-Paper-143]
    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.createWorld(CraftServer.java:1037) ~[patched_1.15.2.jar:git-Paper-143]
    at org.bukkit.Bukkit.createWorld(Bukkit.java:536) ~[patched_1.15.2.jar:git-Paper-143]
    at org.bukkit.WorldCreator.createWorld(WorldCreator.java:320) ~[patched_1.15.2.jar:git-Paper-143]
    at me.slimeyderp.beyondhorizons.BeyondHorizons.makingAetherWorld(BeyondHorizons.java:80) ~[?:?]
    at me.slimeyderp.beyondhorizons.BeyondHorizons.onEnable(BeyondHorizons.java:20) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.15.2.jar:git-Paper-143]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) ~[patched_1.15.2.jar:git-Paper-143]
    etc...
    Caused by: java.lang.IllegalArgumentException: x out of range (expected 0-15, got 16)
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:168) ~[patched_1.15.2.jar:git-Paper-143]
    at org.bukkit.craftbukkit.v1_15_R1.CraftChunk.validateChunkCoordinates(CraftChunk.java:330) ~[patched_1.15.2.jar:git-Paper-143]
    at org.bukkit.craftbukkit.v1_15_R1.CraftChunk.getBlock(CraftChunk.java:95) ~[patched_1.15.2.jar:git-Paper-143]
    at me.slimeyderp.beyondhorizons.OrePopulator.populate(OrePopulator.java:46) ~[?:?]
    at net.minecraft.server.v1_15_R1.Chunk.loadCallback(Chunk.java:680) ~[patched_1.15.2.jar:git-Paper-143]
    at net.minecraft.server.v1_15_R1.PlayerChunk.lambda$null$11(PlayerChunk.java:530) ~[patched_1.15.2.jar:git-Paper-143]
    etc...

    ( I put etc when it started to go inside the way Bukkit manages the code )

    Why is it not working? Also, the world has 2 layers of purpur bricks on top and from the 3rd block down to the last one, it's all end stone, excluding the last layer, which is bedrock. I don't get where I'm screwing up.
     
  2. Online

    timtower Administrator Administrator Moderator

    @SlimeyDerp It is the X++ and Y++, and when they start at 0 also the -- versions.
    Your values go outside the chunk.
     
  3. Offline

    SlimeyDerp

    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page