Fix hardcoding height and bottom values for dungeons #217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 subtractgetBottomY()
from the Y-position of the dungeon. We need to do this, because to generate the Y-position of the dungeon, Minecraft will doRandom.nextInt(getHeight())
and then addgetBottomY()
to the result. (You cannot specify the minimum bound withRandom.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()
andgetBottomY()
, we'll need to pass theWorld
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.