How to get ItemStack or ItemType by ItemTranslation

Is there a way to get an ItemStack or an ItemType by the ItemTranslation?
I know there’s a function called getItemTranslationById() but is there a possible way to swap it? A function like getItemIdByTranslation() ?

Thanks for help

How do you mean ItemTranslation? I can not find any class named it? Do you mean InventoryTranslation?

You can get the Translation from an ItemStack.
You can do for example: player.getItemInHand(HandTypes.MAIN_HAND).get().getTranslation();
and then you have as output the name of the ItemStack. So for example the ID from stone is: minecraft:stone and the translation is: Stone

Ah you mean SpongeAPI/Translation.java at stable-7 · SpongePowered/SpongeAPI · GitHub
if so ill need to do some testing to see, however I believe that this is just the display name of the item, meaning that unless your willing to go through every inventory and Item entity checking for the ItemStack of the same name it wont work.

I am curious about the getId() function, as in does it return a generic id for translation or does it display an item specific id.

Just out of curiosity, how come your in a need to convert the translation to an item type/stack?

I want to give a player red wool instead of white wool for example. Because atm you can just give a player: ItemTypes.WOOL and i need a solution to get black wool instead of white

Then why dont you just change the colour of the wool

ItemStack stack;
stack = stack.with(Keys.DYE_COLOR, DyeColours.BLACK).get();

Or from itemType

ItemTypeSnapshot snapshot = ItemTypes.WOOL.getDefaultSolution().with(Keys.DYE_TYPE, DyeTypes.RED).get();
ItemStack stack = snapshot.createStack();

I can not remember the exact context (just woken up)

Okay thanks it worked! But how can i translate it for example for wood? So that i get spruce wood instead of oak wood.

Same again. Only instead of DyeType it would be TreeType (the key would be TREE_TYPE)

Okay it worked too! Thanks mate. But one last question do I have. How does it works with Mod-ItemTypes? For example ironchest-mod. To get the ItemType, you have to do: Sponge.getGame().getRegistry().getType(ItemType.class, “ironchest:iron_chest”).get()
And how do I get any different chesttype from there? Because there also different chests like ironchests or diamondchests with the same id (ironchest:iron_chest)

That is something you will need to discuss with the mod developer as its to do with how that mod interacts with sponge. If it doesnt and spongeforge does all the work then you will need to use NMS

Edit:
You can see all the supported Keys by the following code

ItemStack stack; 
Sponge.getRegistry().getAllOf(Key.class).stream().filter(k -> stack.supports(k)).forEach(k -> System.out.println(k.getId()));

Okay thank you so much mate. I found a way to fix that. You were a really big assistance for me!!