Is it possible to detect a player's name from gui text inputs?

Started by Minecraftmaker12 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is it possible to detect a player's name from gui text inputs?

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?

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If your getting the entity…
Sat, 10/12/2024 - 02:37

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.

Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i meant like a gui element…
Sat, 10/12/2024 - 17:55

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

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use the text input element,…
Sat, 10/12/2024 - 22:46

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?