Convenience methods for ItemType/BlockType/TypedKey/TagKey
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Is your feature request related to a problem?
Not really a problem per se, just some of the methods for using TypedKey/TagKey seem awfully verbose.
Comparing a Block to a TypedKey
(I dont think anyone would do this, just wanted to show it off)
(block referencing a Bukkit Block)
TypedKey<BlockType> blockTypedKey = TypedKey.create(RegistryKey.BLOCK, block.getType().key());
if (blockTypedKey.equals(BlockTypeKeys.STONE)) {
}
Checking if a Block matches a TagKey
(as far as I know this is the shortest way?!?!?)
(block referencing a Bukkit Block and myTagKey referencing a custom TagKey)
TypedKey<BlockType> blockTypedKey = TypedKey.create(RegistryKey.BLOCK, block.getType().key());
Tag<BlockType> tag = RegistryAccess.registryAccess().getRegistry(RegistryKey.BLOCK).getTag(myTagKey);
if (tag.contains(blockTypedKey)) {
}
Describe the solution you'd like.
I would like to see some additions similar to NMS Methods.
Ex: NMS ItemStack:
(I believe BlockStateBehaviour has these as well)
This would be a nice addition to Bukkit ItemStack/Block (maybe even ItemType/BlockType)
Could include for example:
ItemStack#is(TypedKey/TagKey/ItemType)
Block#is(TypedKey/TagKey/BlockType)
Possibly even:
ItemType#is(TagKey)
BlockType#is(TagKey)
"is" may not be the best option, Im just going off what NMS has done, for the base idea.
Possibly out of the scope of this issue, but another nice addition would be:
ItemType#getTypedKey()
BlockType#getTypedKey()
Possibly also:
ItemStack#getTypedKey()
Block#getTypedKey()
Describe alternatives you've considered.
Other than what I mentioned in the "problem" area, nothing I can think of at the moment.
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the requested convenience methods and linked pull request #14152 first. Determine which ItemStack, Block, ItemType, and BlockType operations are in scope, then verify that the agreed API surface covers the intended TypedKey and TagKey checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100