[Solved] Item In Hand Properties

Hello beautiful people of Sponge,

So I’m trying to figure out how to obtain a block’s properties or it’s full ID. I think this is also referred to as Keys, of even META data? I know to obtain a plain ID from a block one would use

player.getItemInHand().get().getItem().getId(),

but I only receive an output of “minecraft:stone”. What I’m looking for is a way to get an output of “1:2”, "1:6: ect. Any help would be greatly appreciated! :smiley:

You’ll never get a “1:2” or “1:6” output. Mojang itself has gotten rid of them, and sponge was built to never use those magic numbers in the first place because of the removal from Mojang

things will be a block like “minecraft:stone” and have a variant property of “andesite” or “smooth_granite” for example…

1 Like

Thanks for the info. How can I get the variant properties of the item on hand?

You can use Keys.ITEM_BLOCKSTATE to get the BlockState of what the item is using currently, as well as changing it further (though changing the ItemType is not possible anymore.

1 Like