Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hardcoding height and bottom values for dungeons #217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

InfoTeddy
Copy link

Worlds whose generation doesn't have a height of 256 and a bottom of 0 will not work with dungeon seed cracking. This is because the dungeon seed cracking in this mod always assumes that the generation has a height of 256 and a bottom of 0.

To fix this, just use getHeight() instead of 256, and subtract getBottomY() from the Y-position of the dungeon. We need to do this, because to generate the Y-position of the dungeon, Minecraft will do Random.nextInt(getHeight()) and then add getBottomY() to the result. (You cannot specify the minimum bound with Random.nextInt(), and the minimum bound will always default to 0; so this is the next best thing to do.) And the reverse of adding is subtracting.

Also, to be able to use getHeight() and getBottomY(), we'll need to pass the World around a bit, but this is no big deal.

This makes the seed cracker mod work with the Caves & Cliffs 1.18 world generation preview data pack (which generates worlds with a height of 384 and a bottom of -64), completely flawlessly. I tested it.

Worlds whose generation doesn't have a height of 256 and a bottom of 0
will not work with dungeon seed cracking. This is because the dungeon
seed cracking in this mod always assumes that the generation has a
height of 256 and a bottom of 0.

To fix this, just use getHeight() instead of 256, and subtract
getBottomY() from the Y-position of the dungeon. We need to do this,
because to generate the Y-position of the dungeon, Minecraft will do
Random.nextInt(getHeight()) and then add getBottomY() to the result.
(You cannot specify the minimum bound with Random.nextInt(), and the
minimum bound will always default to 0; so this is the next best thing
to do.) And the reverse of adding is subtracting.

Also, to be able to use getHeight() and getBottomY(), we'll need to pass
the World around a bit, but this is no big deal.

This makes the seed cracker mod work with the Caves & Cliffs 1.18 world
generation preview data pack (which generates worlds with a height of
384 and a bottom of -64), completely flawlessly. I tested it.
@CB30
Copy link

CB30 commented Jul 2, 2021

do you mind if I edit my fork to include your edits?

@InfoTeddy
Copy link
Author

I don't mind at all! It's not like you could do something different than what I do and still have the code be correct, and it's a pretty insignificant change.

@CB30
Copy link

CB30 commented Jul 3, 2021

I don't mind at all! It's not like you could do something different than what I do and still have the code be correct, and it's a pretty insignificant change.

Appreciated. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants