LevelGeneratorTypes are a pain to create...
valoeghese opened this issue · 20 comments
Looking through BetaPlus's code while making a LevelGeneratorType myself, I notice two things that make worldtypes in fabric a pain to create:
- Manual numerical ID (and more!)
LevelGeneratorTypes don't use a registry. (Seriously it's all hardcoded)
just look here to see what I mean: https://github.com/mrburger/Beta-Plus/blob/1.14-fabric/src/main/java/com/mrburgerus/betaplus/world/beta_plus/BetaLevelType.java - You need a mixin to OverworldDimension to make it work
https://github.com/mrburger/Beta-Plus/blob/1.14-fabric/src/main/java/com/mrburgerus/betaplus/mixin/MixinOverworldDimension.java
I'll work on making a fabric level generator type api probably unless someone else does it first
That may have been some :voldethonk: ,
though I think the game calls them world types as well?
I am fairly certain that its actually way worse than you think it is. You need separate mixins (or a LOT of reflection) for the dedicated server and the client to allow players to select your custom world type.
iirc you will even need to create your own custom buttons on the client side since the vanilla buttons are hardcoded...
Would appreciate a fabric module for this.
Yeah, a fabric module would be great. Something that does the brunt work of:
- Changing the button to work properly with all existing level types (with an option for mods to provide a lambda to construct their own settings screen to configure it?)
- Add a registry so level types can be indexed by Identifier. (injected into the game at strategic points so they can be used)
- Other stuff...?
From what I can see, the modded LevelGeneratorTypes also need to be initialized before the server processes the properties file, or the server will use default world type instead of the said modded one.
My current solution is to mixin to LevelGeneratorType.getTypeFromName but it would probably be better to just make the LevelGeneratorTypes initialize at the right time
The whole map type (yes they're called that in game) selection process is very hardcoded indeed. I'm also in the situation where I need a custom one.
What I think is needed is
- A proper registry rather than a fixed length array with hardcoded IDs.
- The buton for selecting the type automatically recognizes added LevelGeneratorTypes. Additionally it would be nice though if the type could be extended with a customization screen and then showing the customization button based on that.
- I didn't even realize that it doesn't work with the properties file, but that definitely needs to be fixed
- The Mixin in OverworldDimension, maybe extend LevelGeneratorType to also include a ChunkGeneratorType?
Of course there is more that could be done, but with this the basic funcionality should be complete?
Other than 3. it doesn't seem that hard. Maybe a bit ugly and invasive but not hard.
Nice to haves:
5. Maybe out of scope, but even with the few (5?) default world types, selecting them is already a pain
6. Allow altering other dimensions through the world type in a nice way
There are 8 vanilla world types, but id 7 isn’t used and two of them are hidden (customised and debug_all_block_states). One of them isn’t set to be hidden but you can’t select it via “more world options” from what I can tell (default_1_1)
I guess #483 works on it?