Jump to content


Need Help With Different Colored Nametags (Minecraft)

Java Minecraft

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1 xXDR0IDXx

xXDR0IDXx

    Servant of Chuck Knoblock the one armed one man army


  • 3 posts
  • Joined December 20, 2011
2

Posted 26 April 2012 - 08:40 PM

Hi, I'm new to coding, so Idk if I'm going to sound stupid by asking this. I'm trying to figure out how to give certain people different colored nametags in Minecraft. (i.e My friends nametag being blue, rival being red, etc.) If anyone could give me a push in the right direction, or atleast a bit of code I could use as a reference, that'd be great. I can't find anything on the internet explaining to me how to do this, so posting on a forum'd be the best thing to do, I guess. Thanks.
Did I ever tell you the definition of insanity?

#2 Fluttershy

Fluttershy

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 23 posts
  • Joined April 21, 2012
3

Posted 26 April 2012 - 09:48 PM

\247a-f will color your text differently.
Minecraft's font renderer supports custom colors through this.

#3 WhoopiGoldberg

WhoopiGoldberg

    Limbs removed by the Grinch


  • 1492 posts
  • Joined October 10, 2011
1181

Posted 27 April 2012 - 01:19 AM

Find the nameplate rendering code, then change the colours of the two drawString() functions.

View PostFluttershy, on 26 April 2012 - 09:48 PM, said:

\247a-f will color your text differently.
Minecraft's font renderer supports custom colors through this.
This works for mid-way through text. For changing a whole line (eg: a name on the nameplate) you'd just change the colour that you give to drawString() or drawStringWithShadow()

Edited by WhoopiGoldberg, 27 April 2012 - 01:22 AM.

Yeah, that.

LadyRavenOwl said:

Hearing Whoopi's voice is like getting head.

#4 DeCoolJB

DeCoolJB

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 976 posts
  • Joined October 8, 2011
334

Posted 27 April 2012 - 09:02 PM

View PostWhoopiGoldberg, on 27 April 2012 - 01:19 AM, said:

Find the nameplate rendering code, then change the colours of the two drawString() functions.

Speaking of changing method arguments, doing Whoopi's suggested method would result in a much, much more flexible way of coloring your names afterwards. Sure, Minecraft's default color codes have useful colors, but actually editing the color results in a more satisfying result.

Plus, you can (and I highly advise this) change the color argument to take the value of a preset hexadecimal integer in a custom class. Therefore, by just change the value in your class, all the names will automatically change to that color. No need to do \234-a2348sdafa-sdf or w/e

Making it so different people have different colors is pretty easy too, just create a new integer in the name rendering code, then do if elseif else statements on the player's name, which will set that new integer to a preset color.

Edited by DeCoolJB, 27 April 2012 - 09:03 PM.

Te vagy egy ostoba

#5 cortz

cortz

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 33 posts
  • Joined February 22, 2012
6

Posted 28 April 2012 - 04:33 AM

Instead of making it drawstring for every single variable. You can just make a hashmap hooked up into 2 arraylists, (1 for color, 2nd for names) then do the fancy for loop and matching them. Then replace the color if name = name in arraylist and done.
Saves a lot of lines of code if you know what your doing.

I never tried the above method for nameplates but I did do something similar before in my "arraylist" gui. Saves so much time and lines in the long run.

#6 rakiru

rakiru

    Judgmental Giraffe


  • 3032 posts
  • Joined October 25, 2011
2619

Posted 30 April 2012 - 11:25 AM

View Postcortz, on 28 April 2012 - 04:33 AM, said:

a hashmap hooked up into 2 arraylists
wut
Error is my onii-chan
Posted Image

#7 Matdo

Matdo

    Limbs safe from the Grinch


  • 805 posts
  • Joined October 26, 2011
148

Posted 30 April 2012 - 11:39 AM

To do this is really easy. All you would need to do is make an if statement checking if their username is equal to whatever and then either use the \247 colours (http://www.teamavoli...__fromsearch__1) Or use the way Whoopi showed.

Posted Image

I died a little when finding out my school's default font is Comic Sans MS.


#8 ZeKurt

ZeKurt

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 61 posts
  • Joined April 14, 2012
-19

Posted 30 April 2012 - 02:04 PM

Use fontrenderers, look threw the "render" classes.

#9 XCMajor

XCMajor

    Limbs removed by the Grinch


  • 92 posts
  • Joined October 22, 2011
8

Posted 30 April 2012 - 02:12 PM

View PostZeKurt, on 30 April 2012 - 02:04 PM, said:

Use fontrenderers, look threw the "render" classes.

through*
sorry had to
"Defeating a sandwich only makes it tastier" - Virginia

#10 iamDeath123

iamDeath123

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 15 posts
  • Joined February 21, 2012
-4

Posted 30 April 2012 - 02:29 PM

What is a nameplate called in the coding?

#11 Matdo

Matdo

    Limbs safe from the Grinch


  • 805 posts
  • Joined October 26, 2011
148

Posted 30 April 2012 - 03:17 PM

The class you are wanting is  RenderPlayer.java. I will not go any further then this. Just try searching for relevant things such as name. You will find it.

Posted Image

I died a little when finding out my school's default font is Comic Sans MS.


#12 ZeKurt

ZeKurt

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 61 posts
  • Joined April 14, 2012
-19

Posted 30 April 2012 - 04:37 PM

Dude thats exactly what I said, matdo. But ok!

#13 Lucky7

Lucky7

    I'M NOT FLYING ANYMORE THEY PATCHED IT


  • 45 posts
  • Joined March 23, 2012
33

Posted 30 April 2012 - 10:55 PM

At renderliving label you chose what color it renders as. You can just change it there or like others have stated you can just put the '\274(0-9/a-f).

Yeah my avatar is a fat flying cat. Big whoop wanna fight about it?


#14 Matdo

Matdo

    Limbs safe from the Grinch


  • 805 posts
  • Joined October 26, 2011
148

Posted 01 May 2012 - 02:04 PM

View PostZeKurt, on 30 April 2012 - 04:37 PM, said:

Dude thats exactly what I said, matdo. But ok!
You just said the render class. I further explained which class he wanted to change. In fact, http://www.teamavoli...kbehind-blocks/ explains it well.

Posted Image

I died a little when finding out my school's default font is Comic Sans MS.


#15 ZeKurt

ZeKurt

    Servant of Chuck Knoblock the one armed long arm of the Law


  • 61 posts
  • Joined April 14, 2012
-19

Posted 02 May 2012 - 12:31 PM

Ya, but is telling him exactly what class really necessary?  For such a simple conecpt?


Welcome to our forum! We would like to encourage you to contribute to our community by posting and talking in the shoutbox.

Please consider joining us by logging in or registering.