Getting item meta from block transaction

Hi, how can I get the item name/meta from the ChangeBlockEvent?

Thanks

What do you mean by item? As in the blocks name and meta? The item that the player is holding when the block changes?

The BlockChangeEvent is a general event that occurs when a block changes state (from player, entity or just the world)

I’m looking to get the display name/lore of a tripwire hook when placed

Dont know if it will grab that data from the block but it works with items.

First of all you will need the BlockState of the tripwire hook.

Then do the following code

BlockState state;
Text name = state.get(Keys.DISPLAY_NAME).get();
List<Text> lore = state.get(Keys.ITEM_LORE).get();

Like i said. I know that works on items but no idea if it works on blocks as im not sure its the same data that is held to keep that data

I guess you can’t get those keys from a blockstate, but i instead got an itemstack from player.getiteminhand and got the meta that way.

I would try to use the key for display name from the item, but if the item itself doesn’t have a display name, then fall back to the item’s translation id.