I need some help with testing for a player's name and using it in a if/else argument. For example, if someone were to load up my mod with the name "Notch", then they would be given strength, but if someone with any other name were to use the mod, they would not have the effect. Any help would be appreciated, and thanks in advance!
Thanks a ton! This helps a lot! I just have one question. If I use this on multiplayer, would it still work? Say the example above, would it work? Also, could you give me some example code? I just tried making some armor which only gives strength to Ender_Pug_Sam, but it didn't really work out.
The Meaning of Life, the Universe, and Everything.
Alright try this out
public void PlayerTick(PlayerTickEvent event)
//this makes it so I don't have to type event.player everytime I want to use the player//
EntityPlayer player = event.player;
//Since playertick every tick for each player, this will be different for every player.//
String PlayerName = player.getGameProfile().getName();
//Checks if the playername is Ender_Pug_Sam//
if(PlayerName == "Ender_Pug_Sam")
player.addPotionEffect(Whatever Is used in 1.7.10 to get potions, I forgot.);
Rollback Post to RevisionRollBack
Want a mod with the best magnets available? The download Better Magnets!
And if you like Avaritia then you will love More Avaritia! Adds recipes for creative items from a huge list of mods, and even adds more custom items that fit the Avaritia theme!