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

Move more data into sections, world height implementation #20

Merged
merged 25 commits into from
Mar 23, 2022

Conversation

paulevsGitch
Copy link
Contributor

This small PR will make possible to change level height. It includes:

  • Storing metadata and both light arrays inside chunk sections
  • Storing heightmaps in short format instead of byte format
  • Loading data from old worlds into new worlds
  • Storing world height in level.dat and providing it in the interface

Bonus: short world (height set to 80 blocks with NBT Explorer):

2022-03-04_19 35 58

@GameHerobrine
Copy link

c-custom world height =o?

@paulevsGitch
Copy link
Contributor Author

c-custom world height =o?

Some sort of. It will require some more work - splitting chunk section rendering and some changes in light code

@paulevsGitch
Copy link
Contributor Author

I added test terrain generator. It will be used in dev environment and when world height is larger than 128. It should be removed before next release (I marked is for removal, not whole mixin, only some functions)

2022-03-05_21 22 49

@calmilamsy
Copy link
Member

You should probably move your test stuff to the testmod workspace instead.

@paulevsGitch
Copy link
Contributor Author

paulevsGitch commented Mar 5, 2022

True, I will fix this in next commit

@GameHerobrine
Copy link

hm does the last commit means i can try it =o?

@paulevsGitch
Copy link
Contributor Author

Yes, you can try it if you want

@paulevsGitch
Copy link
Contributor Author

Should world height be per-dimensional or per-world? Current implementation is per-world

@theishiopian
Copy link

Per dimension would be cool

@calmilamsy
Copy link
Member

Dimensional would be preferred, or even better, both, though I'm not sure of a use-case for the latter.

@theishiopian
Copy link

Maybe the world one is the default, which dimensions can override?

@calmilamsy
Copy link
Member

Yea, likely something like that.

@GameHerobrine
Copy link

hm custom dimension height

@paulevsGitch
Copy link
Contributor Author

Maybe the world one is the default, which dimensions can override?

This actually makes it per-dimensional. There is no reason to store both values for world and dimension, so there can be only dimensional height with default value of 128. If this will be done as interface - any mod can implement it and change height into desirable one. It will be also possible for mods to change vanilla height with mixins as mixins can override interface functions of another mixins.

It will be not to hard to implement as each chunk already ask a world for section count, so now it will ask dimension about that

@paulevsGitch
Copy link
Contributor Author

paulevsGitch commented Mar 14, 2022

Mobs are now spawning on any world height, items works correctly, the last visible issue that is not fixed yet is light. I'm not sure why it is not completely correct (looks like there are more hardcoded constants somewhere in the code), so any help is welcome

2022-03-14_21 36 52

P.S.: I optimised some parts of light calculations. They are not source if the issue, but light should work faster than in vanilla for any sections count

Edit: I forgot about move height from level to dimension, but this is not harderst part

@paulevsGitch
Copy link
Contributor Author

Looks like I fixed light. Next step will be to move world height into dimension settings

2022-03-15_01 51 24

@paulevsGitch
Copy link
Contributor Author

StAPI now can support per-dimensional height, and any dimension can define custom height limit.

Example for custom dimension:

public class CoolDimension extends Dimension implements StationDimension {
    @Override
    short getDefaultLevelHeight() {
        return 256;
    }
    // Other code
}

Example for vanilla dimension (with Mixin):

@Mixin(Overworld.class)
public class OverworldMixin implements StationDimension {
    @Override
    short getDefaultLevelHeight() {
        return 256;
    }
}

I found a strange bug when Nether with vanilla generator will cause infinity world loading, when generator is custom this will not happen. I'm not sure why this happens, looks like it is not dependent from world height as it will stuck on vanilla height range too

@GameHerobrine
Copy link

wonder how will it work with aether

@paulevsGitch
Copy link
Contributor Author

I found a strange bug when Nether with vanilla generator will cause infinity world loading, when generator is custom this will not happen. I'm not sure why this happens, looks like it is not dependent from world height as it will stuck on vanilla height range too

I fixed that. The reason was that Nether generator is different from Overworld and tried to directly put blocks byte data into chunks. As chunks have only states that failed and resulted as empty chunks. Now this is fixed

@paulevsGitch
Copy link
Contributor Author

I think that this PR is ready for review

Copy link
Member

@mineLdiver mineLdiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong import rules?

@mineLdiver
Copy link
Member

I think I've submitted this review wrong.

@mineLdiver mineLdiver dismissed their stale review March 23, 2022 20:01

Let's just use vanilla import rules then

Copy link
Member

@mineLdiver mineLdiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointed out some minor issues, but otherwise the PR is ready to be merged.

paulevsGitch and others added 2 commits March 24, 2022 00:02
…ationapi/mixin/flattening/MixinLevelProperties.java

Co-authored-by: mineLdiver <[email protected]>
@mineLdiver
Copy link
Member

Seems good, merging.

@mineLdiver mineLdiver merged commit b43597c into ModificationStation:master Mar 23, 2022
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.

5 participants