Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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!

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-

  • 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

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-

  • 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?

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-

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;

        }

    }

 

 

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-

  • 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!  ;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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.