Custom GeneratorType for Custom World Types
See original GitHub issueIssue for pre 1.16: #297
Introduction
It’s not uncommon for mods to provide their own world type, e.g. for skyblock. Unfortunately, this isn’t trivial for a mod to add and I’d propose to make a module for this in the API. Some of the things that need to be done:
- Allow creation of a GeneratorType object.
- Simplify the process of providing ChunkGenerators for each dimension
- Fix the parsing of server.properties for the GeneratorOptions
So far I have a rough idea what this would look like, but this definitely requires some thought and some input from experienced contributors.
GeneratorType
GeneratorType is a client-only abstract class with private constructor.
It is required in order to provide the MinecraftClient with a selection on the world creation screen.
While there is no proper registry, there exists a protected (mutable) List<GeneratorType> VALUES
that allows aading new ones.
On the client, this class also provides the GeneratorOptions.
In order to make this class accessible to mods, I would suggest using an accesswidener to make the class extensible,
Then, Fabric could provide a FabricGeneratorType extends GeneratorType
which should be either extensible or use a builder pattern.
This then allows mods to provide their own ChunkGenerators/DimensionOptions for each dimension.
GeneratorOptions
GeneratorOptions is the class that actually holds all information needed to generate the world.
On the client, it’s created using GeneratorType.method_29079(...)
,
on the server it is parsed from the properties file using GeneratorOptions.fromProperties(...)
This class is fairly accessible and doesn’t need to be extended, however the parsing on the server side is not only hardcoded,
but also happens before ModInitializers are called.
Therefore a custom GeneratorType wouldn’t have been registered yet and couldn’t possibly be parsed.
This could be fixed by accessing the serverPropertiesLoader
local in the server main after the ModInitializers have been called
and then simply reparsing the world type.
Additional Nice-To-Haves
As already mentioned in #297, there are some nice-to-have features that may be out of scope.
- Cycling through different world types is a pain. Would be nice to have an easier method to select the desired type than just clicking a button repeatedly
- Changing the default world type. It’s a simple mixin into the MoreOptionsDialogand possibly more relevant to packs than mods and therefore possibly better suited to a separate mod.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
I think the correct solution is to just reparse the GeneratorOptions after ModInitializers have been called.
Vanilla 1.19 provides this feature.