Fabric API

Fabric API

106M Downloads

LevelGeneratorTypes are a pain to create...

valoeghese opened this issue · 20 comments

commented

Looking through BetaPlus's code while making a LevelGeneratorType myself, I notice two things that make worldtypes in fabric a pain to create:

  1. 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
  2. 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
commented

Vanilla now provides this functionality I believe

commented

Mixin 0.8 might mean we can use mixin to invoke the constructor

commented

I'll work on making a fabric level generator type api probably unless someone else does it first

commented

bump

commented
  1. Support loading level type from server config file
commented

Maybe there should be a fabric api module for this? What do you all think?

commented

Surely you mean LevelGeneratorTypes?

commented

That may have been some :voldethonk: ,
though I think the game calls them world types as well?

commented

Yes

commented

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.

commented

Yeah, a fabric module would be great. Something that does the brunt work of:

  1. 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?)
  2. Add a registry so level types can be indexed by Identifier. (injected into the game at strategic points so they can be used)
  3. Other stuff...?
commented

bump

commented

bump

commented

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

commented

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

  1. A proper registry rather than a fixed length array with hardcoded IDs.
  2. 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.
  3. I didn't even realize that it doesn't work with the properties file, but that definitely needs to be fixed
  4. 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

commented

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)

commented

So ids 0-6 and 8 are taken by minecraft

commented

Altering other vanilla dimensions can be done like the overworld.

commented

And did I mention that the constructor is private? yeehaw emoji

commented

I guess #483 works on it?