Jump to content

Questions about WorldGeneration


Robertusxd

Recommended Posts

Hello guys, I hope the answers to my questions arent obvious.

I like to think that im decently experienced in Java but im completly new to Minecraft modding. From what ive seen 1.12 changed a lot of things(?) so maybe thats why its so hard to get any information thats actually up to date.

 

So what im trying to do is having the WorldGenerator build a house at the spawnlocation.

1.What would be the best way to modify the WorldGenerator in a way that makes sure the spawnlocation is rather flat so that a building doesnt look completly out of place?

2.What would be the best way to then actually place a building there?

 

I have tried implementing the IWorldGenerator interface but im not quite sure if thats the best way to ensure that the area is rather flat. It worked for building a house by changing the blockstates of the blocks relative to the spawn BlockPos but im not sure if that is the best way to go about this.

 

Thanks for any help in advance.

Link to comment
Share on other sites

There's a (World?) method that will give you the top-most solid Y for any X,Z. With that you can check an area.

 

There are several strategies for flattening. One is to choose flat biomes, build up from the highest Y, fill down where the area is lower, and hope it comes out looking good. Another is to scrape a foundation (with room to walk around the outside) down to some median level (but keep it above sea-level).

 

What you choose will depend on what look you want, whether you need to "force" the building at each proposed site etc.

  • Like 1

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Im not very experienced with world generation but if you have the x and z coordinates of the spawn loop from 255 to 0 and find the first non log/leaf block and that is the y you want to work with.  Then just clear all unwanted blocks from the area and flatten as normal

Edited by drok0920
Expanded on question
Link to comment
Share on other sites

Like jeffreyfisher mentioned, it would probably be more efficient for you to use World#getTopSolidOrLiquidBlock, and if the results of that happen to be a leaf or log, iterate downward until you find a non-leaf/log. Vanilla crops use a similar algorithm.

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.



×
×
  • Create New...

Important Information

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