Jump to content

World-gen help


tlr38usd

Recommended Posts

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-

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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-

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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;

        }

    }

 

 

Link to comment
Share on other sites

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.