Jump to content

Recommended Posts

Posted

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!

Posted
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-

Posted

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

Posted

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-

Posted

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?

Posted

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-

Posted

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;

        }

    }

 

 

Posted

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-

Posted

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!  ;D

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.