Jump to content

Probably a stupid question, but function for getting a player's username.


Cyan

Recommended Posts

I feel pretty stupid for even asking this, but I have skimmed the entityplayer files without finding what I am looking for. It is probably right in front of me, but I'll ask here anyway :|

 

I was looking to add a player's username to a render. I unfortunately just can't quite seem to find the function that returns it.

Again, most likely because I am looking right over it. Poooint me in the right direction Forge forum!!(please)

 

 

Thanks in advance.

Link to comment
Share on other sites

EntityPlayer.username

 

Use your javadocs.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

The good news is: I had already tried that.

 

The bad news is: I can't quite return that from my function.

 

 

Function as of now just in case it will help:

 

 public EntityPlayer getName()
    {
        

        return EntityPlayer.username;
    }

Link to comment
Share on other sites

The good news is: I had already tried that.

 

The bad news is: I can't quite return that from my function.

 

 

Function as of now just in case it will help:

 

 public EntityPlayer getName()
    {
        

        return EntityPlayer.username;
    }

 

*Facepalm*

 

First off, the return type of that function is wrong.

 

Second you need a player reference, the username property is not static.

 

 public String getName(EntityPlayer player)
    {
        

        return player.username;
    }

 

Basic programming stuff, this.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

First, I asked for a return statement, so the facepalm is rather rude considering the ---->

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Third, thank you. I've been fumbling around with this too long to not realize I didn't make it a string function. Stupid me is stupid.

 

Going to give you a thanks, but perhaps you should consider not being rude the next time someone makes an easily looked over error.

Link to comment
Share on other sites

First, I asked for a return statement, so the facepalm is rather rude considering the ---->

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Third, thank you. I've been fumbling around with this too long to not realize I didn't make it a string function. Stupid me is stupid.

 

Going to give you a thanks, but perhaps you should consider not being rude the next time someone makes an easily looked over error.

 

Just think about this for one minute... wait, make that a string of minutes.

 

That is not the kind of error that is "easily overlooked". It is basic programming to know that you are wanting a String to return, not an EntityPlayer. If you want a string, the method is a String method!

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Also, once again, basic programming. The reason someone face-palms (albeit sometimes in a rude way, [sorry Draco, it is rude, even if I would do it too :P]) is because someone does something either A) Stupid (like the case sort of is here), or B) Missed something so obvious it should have killed them...

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

First, I asked for a return statement, so the facepalm is rather rude considering the ---->

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Third, thank you. I've been fumbling around with this too long to not realize I didn't make it a string function. Stupid me is stupid.

 

Going to give you a thanks, but perhaps you should consider not being rude the next time someone makes an easily looked over error.

 

Just think about this for one minute... wait, make that a string of minutes.

 

That is not the kind of error that is "easily overlooked". It is basic programming to know that you are wanting a String to return, not an EntityPlayer. If you want a string, the method is a String method!

 

Second, vague response was vague. I realize where the username is, I was just puzzled about how to apply it.

 

Also, once again, basic programming. The reason someone face-palms (albeit sometimes in a rude way, [sorry Draco, it is rude, even if I would do it too :P]) is because someone does something either A) Stupid (like the case sort of is here), or B) Missed something so obvious it should have killed them...

Eh, I wouldn't say "stupid". I know that it seems sometimes like everybody and his dog wants to make a Minecraft mod, and that some people have less knowledge of Java than the aforementioned dogs, but that's not a license to call them "stupid". Tell them to learn Java, certainly. But don't call them stupid.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

That is not the kind of error that is "easily overlooked". It is basic programming to know that you are wanting a String to return, not an EntityPlayer. If you want a string, the method is a String method!

 

Not to mention that his code should have been throwing errors...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Going to put one more quick post into this since apparently it got more backlash than needed.

 

It is an easily overlooked error. Believe me. So much that I didn't realize that (half) of my problem was that I hadn't noticed it the function being changed at that point and time. I just copied and pasted here with the first "suggestion" Draco18s made.

(while in reality, the nifty Eclipse hover and fix changed the code to Enitplayer getName(), whereas I thought it was still String getName(), but that's what I get for trying to rush around and copy things to the forum for a quick reply)

 

That being said, I made a mistake in copying. My bad. I also stated at least three times that this was probably a stupid question in the original post. I'm not the best programmer in the world, nor did I have any actual teaching. Sometimes I make mistakes. That being said, no need to be a douche when I explicitly state I'm asking a stupid question.

 

Chances are I am asking a stupid question because I know I have made a stupid mistake, and just don't exactly know why.

 

There is no point in making this any more of an ordeal. Feel free to criticize me whenever I do something stupid and I am not ALREADY aware of it.

Link to comment
Share on other sites

It is an easily overlooked error. Believe me. So much that I didn't realize that (half) of my problem was that I hadn't noticed it the function being changed at that point and time. I just copied and pasted here with the first "suggestion" Draco18s made.

 

I don't post code that works because 99% of the time I'm not opening Eclipse and nabbing exact function names.

I do, however, post code that tells people where to look.

 

(while in reality, the nifty Eclipse hover and fix changed the code to Enitplayer getName(), whereas I thought it was still String getName(), but that's what I get for trying to rush around and copy things to the forum for a quick reply)

 

Forums are an asynchronous method of communication.  Therefor you can afford the time to spellcheck and make sure you've got things write.*  About a third of my own questions are solved before I even make my opening post because in the process of copy-pasting and explaining what's going on I realize my error.

 

That being said, I made a mistake in copying. My bad.

 

Which is impossible to know from this end, therefor it is acceptable to point out these errors.

 

There is no point in making this any more of an ordeal. Feel free to criticize me whenever I do something stupid and I am not ALREADY aware of it.

 

This post is not a criticism, it is for future reference.

 

*Even go back and make edits.  This word should be "right" but I have a bad habit of typing the wrong thing and will frequently alter my posts when I notice errors just after clicking submit.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • A friend found this code, but I don't know where. It seems to be very outdated, maybe from 1.12? and so uses TextureManager$loadTexture and TextureManager$deleteTexture which both don't seem to exist anymore. It also uses Minecraft.getMinecraft().mcDataDir.getCanonicalPath() which I replaced with the resource location of my texture .getPath()? Not sure if thats entirely correct. String textureName = "entitytest.png"; File textureFile = null; try { textureFile = new File(Minecraft.getMinecraft().mcDataDir.getCanonicalPath(), textureName); } catch (Exception ex) { } if (textureFile != null && textureFile.exists()) { ResourceLocation MODEL_TEXTURE = Resources.OTHER_TESTMODEL_CUSTOM; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.deleteTexture(MODEL_TEXTURE); Object object = new ThreadDownloadImageData(textureFile, null, MODEL_TEXTURE, new ImageBufferDownload()); texturemanager.loadTexture(MODEL_TEXTURE, (ITextureObject)object); return true; } else { return false; }   Then I've been trying to go through the source code of the reload resource packs from minecraft, to see if I can "cache" some data and simply reload some textures and swap them out, but I can't seem to figure out where exactly its "loading" the texture files and such. Minecraft$reloadResourcePacks(bool) seems to be mainly controlling the loading screen, and using this.resourcePackRepository.reload(); which is PackRepository$reload(), but that function seems to be using this absolute confusion of a line List<String> list = this.selected.stream().map(Pack::getId).collect(ImmutableList.toImmutableList()); and then this.discoverAvailable() and this.rebuildSelected. The rebuild selected seemed promising, but it seems to just be going through each pack and doing this to them? pack.getDefaultPosition().insert(list, pack, Functions.identity(), false); e.g. putting them into a list of packs and returning that into this.selected? Where do the textures actually get baked/loaded/whatever? Any info on how Minecraft reloads resource packs or how the texture manager works would be appreciated!
    • This might be a long shot , but do you remember how you fixed that?
    • Yeah, I'll start with the ones I added last night.  Wasn't crashing until today and wasn't crashing at all yesterday (+past few days since removing Cupboard), so deductive reasoning says it's likeliest to be one of the new ones.  A few horse armor mods and a corn-based add-on to Farmer's Delight, the latter which I hope to keep - I could do without the horse armor mods if necessary.  Let me try a few things and we'll see. 
    • Add crash-reports with sites like https://mclo.gs/ Add this mod: https://www.curseforge.com/minecraft/mc-mods/packet-fixer/files/5416165
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.