Started by
Minecraftmaker12
on
Topic category: Help with Minecraft modding (Java Edition)
I wanted to make a mod that uses a gui to send an item to a player, with the recipient username specified in a text input. However, I don't know how to detect the username from the text input. Any help?
If your getting the entity/player that the item is being sent to. Then just get the display name of said entity/player and thats their name.
Idk what you mean by text input. If your talking about the return:text when adding special information. What you can do is make a custom string data tag (playername) and set it to the players name when the item is being sent. Then in the return:text procedure use the custom string data tag to get the players name.
i meant like a gui element that lets you type a text string into it. my goal is to locate a player with a username that matches the text put into the gui
Use the text input element, then use a button which gets the text input as a string and applies it to the item. The item being in an inventory slot in the gui.
Or you make it like an anvil where it constantly checks the text and applies it to a new copied item in an output slot. And then when the item is removed the item in the input slot is destroyed.
If you want to detect the username. You would need to compare your string with all players username:
Like this?
thank you!