Skip to content

Convenience methods for ItemType/BlockType/TypedKey/TagKey #12168

Description

@ShaneBeee

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)
Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions