0

What I want to do is when a player picks up an item I can check the username against mine and if it matches they can keep the item and if it doesn't it gets deleted out of there inventory so only I can use the item.

I'm currently trying to do this onItemUseFist to be honest I have no idea where to start with doing this. I already have the item I want to do this to. I just don't know how to do that. I think xComp does something like this with his glasses in Mystcraft.

Thanks in advance,

Josh

  • @Judge2020 Thanks for the reply but I have already tried that and it doesn't seem to work. – joshbas0300 Feb 7 '16 at 9:07
1

According to http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/mods-discussion/1399911-how-do-i-get-a-players-username-with-forge,

Minecraft.getMinecraft().thePlayer.username.equals("username")

works. You can put that as the arguments of an if. then statement then an else statement to do what you want to happen if it doesn't match your username. You could also invert the if statement with a ! before the first M then have the code run in the then statement.

-1

In the code of Forge for 1.12 I found:

Minecraft.getMinecraft().player.getName()
  • Can you expand on this to cover how OP might use it to get player names? – Malco Nov 23 '18 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.