# World-gen help

## Recommended Posts

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!

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

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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

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

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

##### Share on other sites

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-

##### Share on other sites

How do I decorate?

##### Share on other sites

i mean the class and event of decoration, just look at the javadoc it's pretty straightfoward

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

##### Share on other sites

i mean the class and event of decoration, just look at the javadoc it's pretty straightfoward

Is there a better way to do it? I know villages spawn on top of the world and they're not decorations.

##### 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;

}

}

##### Share on other sites

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-

##### Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

• ### Posts

• Sorry im late, i had to do some homework. this is the latest section in logs. https://paste.ee/p/OQgMF What else do you need me to do?
• public class ModRecipes { public static final DeferredRegister<RecipeSerializer<?>> SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MagicOverhaul.MOD_ID); public static final RegistryObject<RecipeSerializer<RuneInscribingRecipe>> RUNE_INSCRIBING_SERIALIZER = SERIALIZERS.register("rune_inscribing", () -> new RuneInscribingRecipe.Serializer()); public static void register(IEventBus eventBus){ SERIALIZERS.register(eventBus); } }
• It still doesn't work, however replacing rubidium with embeddium does work, however the resource packs don't work.

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...