Skip to content

Registry-related get methods #13

Description

@Machine-Maker

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions