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

Registry-related get methods #13

Open
Machine-Maker opened this issue Jul 27, 2023 · 0 comments
Open

Registry-related get methods #13

Machine-Maker opened this issue Jul 27, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Machine-Maker
Copy link
Member

Machine-Maker commented Jul 27, 2023

A lot of the methods on Registry, HolderGetter, HolderLookup, RegistryAccess take ResourceKey as the sole parameter returning something. A lot of the time, those ResourceKey arguments are obtained from static final fields somewhere which makes choosing the name for the local var very easy.

Something like

Holder<Structure> structure1 = registry.getHolder(BuiltinStructures.NETHER_FOSSIL);

can be changed to

Holder<Structure> netherForsilStructure = registry.getHolder(BuiltinStructures.NETHER_FOSSIL);

This is similar to #10 and how the various is and has methods are handled, by looking at the field used in the parameter.

A non-exhaustive list of methods that this could apply to are:

TagKey

  • TagKey#create(ResourceKey, ResourceLocation)

ResourceKey

  • ResourceKey#create(ResourceKey, ResourceLocation)

Registry

  • Registry#get(ResourceKey)
  • Registry#getHolder(ResourceKey)
  • Registry#getOptional(ResourceKey)
  • Registry#getOrThrow(ResourceKey)
  • Registry#containsKey(ResourceKey)
  • Registry#getHolder(ResourceKey)
  • Registry#getTag(TagKey)
  • Registry#getTagOrEmpty(TagKey)
  • Registry#getOrCreateTag(TagKey)

RegistryAccess, RegistryAccess$Frozen, HolderLookup$Provider

  • RegistryAccess#lookup(ResourceKey)
  • RegistryAccess#lookupOrThrow(ResourceKey)
  • RegistryAccess#registry(ResourceKey)
  • RegistryAccess#registryOrThrow(ResourceKey)

HolderGetter, HolderLookup

  • HolderGetter#get(ResourceKey)
  • HolderGetter#getOrThrow(ResourceKey)
  • HolderGetter#get(TagKey)
  • HolderGetter#getOrThrow(TagKey)

BootstapContext

(yes there is a typo in Bootstap in the vanilla source)

  • Bootstap#register(ResourceKey, Object, Lifecycle)
  • Bootstap#register(ResourceKey, Object)
  • Bootstap#lookup(ResourceKey)
@Machine-Maker Machine-Maker added the enhancement New feature or request label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant