PaperMC / PaperMC/codebook

Registry-related get methods

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
22
Forks
1
Avg merge
2m
Merged PRs (30d)
1

Description

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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Registry, HolderGetter, HolderLookup, RegistryAccess, and BootstapContext methods listed in the issue, then compare the approach used for #10. Trace call sites where ResourceKey or TagKey arguments come from static fields and identify the affected local variables. Done means the applicable variables consistently use names derived from those fields across the listed methods.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.