Posted June 28, 201312 yr I'm making world gen for my mod and I'm wondering how you get the y coordinate that is not underground. I have looked in the minecraft source and found this int y = world.getHeightValue(x, z); But that always returns 0, help!
June 28, 201312 yr I'm wondering how you get the y coordinate that is not underground heu ... y coordinate of what ? because technicly yes 0 is a y coordinate. are you asking how to get the y coordinate of the first block starting from the sky ? aka the non-air block that has the highest Y for a given x, z ? how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
June 28, 201312 yr Author I'm wondering how you get the y coordinate that is not underground heu ... y coordinate of what ? because technicly yes 0 is a y coordinate. are you asking how to get the y coordinate of the first block starting from the sky ? aka the non-air block that has the highest Y for a given x, z ? Yes, like how villages spawn on the top of the world
June 28, 201312 yr you could always just make a loop public int getHighestBlock(world, x, z){ for(int i = 128; i > 0; i--){ if(world.getBlockId(x, i, z) != 0){ return i; } return 0; } } if it return 0 all the time it means your code is running BEFORE the land is generated how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
June 28, 201312 yr Author you could always just make a loop public int getHighestBlock(world, x, z){ for(int i = 128; i > 0; i--){ if(world.getBlockId(x, i, z) != 0){ return i; } return 0; } } if it return 0 all the time it means your code is running BEFORE the land is generated So how do I generate after the land?
June 28, 201312 yr does that return 0 all the time ? if you want to generate after the land, use decorators instead. how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
June 28, 201312 yr i mean the class and event of decoration, just look at the javadoc it's pretty straightfoward http://jd.minecraftforge.net/ how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
June 28, 201312 yr Author i mean the class and event of decoration, just look at the javadoc it's pretty straightfoward http://jd.minecraftforge.net/ Is there a better way to do it? I know villages spawn on top of the world and they're not decorations.
June 28, 201312 yr villages use this code. protected int getAverageGroundLevel(World par1World, StructureBoundingBox par2StructureBoundingBox) { int i = 0; int j = 0; for (int k = this.boundingBox.minZ; k <= this.boundingBox.maxZ; ++k) { for (int l = this.boundingBox.minX; l <= this.boundingBox.maxX; ++l) { if (par2StructureBoundingBox.isVecInside(l, 64, k)) { i += Math.max(par1World.getTopSolidOrLiquidBlock(l, k), par1World.provider.getAverageGroundLevel()); ++j; } } } if (j == 0) { return -1; } else { return i / j; } }
June 28, 201312 yr well technicly they are, or at least they are produced the same way, what exactly are you trying to achieve ? also, did you even try my piece of code ? how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
June 28, 201312 yr Author well technicly they are, or at least they are produced the same way, what exactly are you trying to achieve ? also, did you even try my piece of code ? I did I just copied it wrong. Works great now. Thanks!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.