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

[1.15.x] Rewrite docs for Registries #312

Closed
wants to merge 10 commits into from

Conversation

sciwhiz12
Copy link
Contributor

Rewrote the documentation for [Concepts > Registries]:

  • Removed outdated references to GameRegistry.register
  • Reordered register methods so DeferredRegister is first and foremost
  • Simplified section on creating registries (if someone makes a custom registry, they'll be researching on their own)
  • Clarified ObjectHolder rules from block of text to rules list
  • Removed mentions of any registry load order (to future-proof when registry events are parallel-dispatched)

This is an update of my earlier PR for 1.14.x. See that PR for earlier reviews.
Closes #275 and #85.

Copy link
Collaborator

@tterrag1098 tterrag1098 left a comment

Choose a reason for hiding this comment

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

This is good stuff, much needed improvements. Just a couple small things that need addressing and then it's good to go.

docs/concepts/registries.md Show resolved Hide resolved
docs/concepts/registries.md Show resolved Hide resolved
docs/concepts/registries.md Show resolved Hide resolved
-------------------------------------

It is possible to have Forge inject values from registries into `public static final` fields of classes. This is done by annotating classes and fields with `@ObjectHolder`. If a class has this annotation, all the `public static final` fields within are taken to be object holders too, and the value of the annotation is the namespace of the holder (i.e. every field uses it as the default namespace for the registry name of the object to inject). If a field has this annotation, and the value does not contain a namespace, the namespace is chosen from the surrounding class's `@ObjectHolder` annotation. If the class is not annotated in this situation, the field is ignored with a warning. If it does contain a namespace, then the object to inject into the field is the object with that name. If the class has the annotation and one of the `public static final` fields does not, then the resource path of the object's name is taken to be the field's name. The type of the registry is taken from the type of the field.
It is possible to have Forge inject registered object from registries into the `public static` fields of classes. This is done by annotating classes or fields with `@ObjectHolder` and supplying enough information to construct a `ResourceLocation` that identifies a specific object in a specific registry.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This section should take a back seat to a section about RegistryObject which should also be documented. If you are injecting third-party entries this is the far superior way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I only recently learned that RegistryObjects can be instantiated; I thought that it was a DeferredRegister class.
I'm going to make a new section on this.

@tterrag1098
Copy link
Collaborator

Also, everything in here is relevant for 1.14.x too, so it should target that branch.

@tterrag1098 tterrag1098 added Out of Date Information A page contains information which is outdated or incorrect Page Improvement Improves an existing page Waiting for Changes PR is waiting on requested changes from author labels Jul 19, 2020
@sciwhiz12
Copy link
Contributor Author

Since 1.14.x is essentially the same as 1.15.x in terms of registries, I'll integrate these reviews into the 1.14.x branch and close this PR. Thank you.

@sciwhiz12 sciwhiz12 closed this Jul 19, 2020
@sciwhiz12 sciwhiz12 deleted the registries_1.15.x branch March 8, 2021 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Out of Date Information A page contains information which is outdated or incorrect Page Improvement Improves an existing page Waiting for Changes PR is waiting on requested changes from author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants