NucleoidMC / fantasy

Library to support creating dimensions at runtime
GNU Lesser General Public License v3.0
95 stars 26 forks source link

Question about DimensionOptions #27

Closed tksonix closed 1 year ago

tksonix commented 1 year ago

Hi,

So first I apologize for me leaving this non-issue in issues page. I myself is a beginner mod developer, and is learning modding through reading others code. May I ask some questions regarding DimensionOptions, as I find no information after some decent search online?

What's the purpose of DimensionOptions, and so is the Registry? Why is it needed to unfreeze the Registry before adding things to it?

Thanks in advance ;)

Kind regards.

haykam821 commented 1 year ago

The DimensionOptions class represents a dimension type and chunk generator. Each dimension has a corresponding DimensionOptions instance, and world presets are composed of a map of world IDs to DimensionOptions instances. Essentially, DimensionOptions is the template for a World.

Minecraft generally does not expect registries to be modified at runtime, so Fantasy must make some invasive changes to the registry system to ensure that all necessary components of a dimension at runtime, such as the DimensionOptions and World, exist.

tksonix commented 1 year ago

Hi,

Thanks for the reply. I have figured that out in the meantime myself by digging into minecraft's code. Thanks anyway.

But there is still one problem. In my code, I create a new world, insert into MinecraftServer's field with mixin accessor, which is the same method your RuntimeWorldManager take, but without registering the DimensionOptions into the registry. This works completly fine and I haven't encountered any related issue. In fact, in 1.18, DimensionOptions isn't needed, only DimensionType and ChunkGenerator is needed to create a new instance of World (while in 1.19 the World constructor changes, which takes a DimensionOptions).

May I ask the reason behind registering with Registry<DimensionOptions>, and the problem might cause without doing so?

Kind regards.

haykam821 commented 1 year ago

I'm not too knowledgable about the internals of Fantasy or Minecraft's world system, but I believe the registration at this point is just for consistency with the contents added in vanilla. Another mod could access the registry, for example. There might have been other reasons when Fantasy was implemented in Minecraft 1.17, but I can't speak on that.