Allowing chars

For all mod-related questions and custom code.
Post Reply
BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Allowing chars

Post by BobKare »

Hey.

I just got a couple of questions.
Is it safe to allow characters like æøå and & in the chat?
If so, where in the code is this written?

Thanks,

~BobKare

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Allowing chars

Post by fragmer »

You will not be able to allow such characters, because Minecraft client does not support extended ASCII or Unicode.

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Allowing chars

Post by Hellenion »

I believe those are not accepted by the client software, fCraft would be able to handle them, but I'm not sure if the Notchian clients will. Most of the time, unknown characters will choke the client causing a horrible, slow death, I wouldn't experiment with strange characters on public servers if I were you.

if you really want to push this through, look for the function "ContainsValidCharacters" or "IsValidName" or something similar, it'll eventually lead you to where the characters are evaluated.
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

User avatar
boblol0909
SupOP
Offline
Posts: 314
Joined: June 24th, 2011, 10:27 pm

Re: Allowing chars

Post by boblol0909 »

If a message ends with & and no number after it I believe it will crash every client that receives it.

BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Re: Allowing chars

Post by BobKare »

Thanks.

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Allowing chars

Post by fragmer »

You dont need to worry about message contents if you use Player.Message(). fCraft will take care of line-wrapping and potential crashing for you. Output sanitizing and wrapping is done in fCraft.LineWrapper class (fCraft/Networking/LineWrapper.cs)

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Allowing chars

Post by Jonty800 »

How do we get all these to work Frag?

Image

My past attempts always return with a '?'
You cannot use certain BBCodes: [img].

User avatar
Intertoothh
Trustee
Offline
Posts: 1149
Joined: May 24th, 2011, 5:51 am

Re: Allowing chars

Post by Intertoothh »

fragmer wrote:You will not be able to allow such characters, because Minecraft client does not support extended ASCII or Unicode.
McLaughlinKid wrote:You put roar on everything don't you?

User avatar
PyroPyro
Offline
Posts: 381
Joined: May 25th, 2011, 4:00 pm
Location: #fCraft
Contact:

Re: Allowing chars

Post by PyroPyro »

Jonty800 wrote:How do we get all these to work Frag?

Image

My past attempts always return with a '?'
I saw that on some servers, that can be done... Don't know how.

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Allowing chars

Post by Jonty800 »

Yeah, mcforge has this, and it is possible.

Fragmer told me a way about half a year ago, but I've totally forgotten.
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Allowing chars

Post by fragmer »

Minecraft client is capable of showing most code page 437 characters, but the client is not capable of typing any of them in. Minecraft is still unable to show any Unicode. There used to be some random client crash issues if, for example, a line of text contains no printable characters. I never bothered figuring out exact conditions that cause such client crashes.

If you'd like to modify the set of characters that fCraft allows in the output, you'll have to dive into LineWrapper.cs

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Allowing chars

Post by Jonty800 »

Thanks for the help Fragmer. :)

I made some changes to the LineWrapper, and I used a simple rawMessage = rawMessage.Replace("(smile)", encoding.GetString(chars)); to replace text with the byte. But I can't seem to get the emotes to come up on the chat feed, they're blank. The bytes definitely get sent because they can be copied from console and appear as an emote when pasted into the WoM chat bar (but obviously don't send when pressing enter because minecraft doesnt support them).

Is there some sort of hidden check that replaces invalid bytes with ' ' ?
Do you have any suggestions on how I can fix this problem?
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Allowing chars

Post by fragmer »

Like I said, the client is very buggy when it comes to showing those non-standard characters. You may have to experiment a bit to get them to work. Maybe they have to be preceded by some code? I seem to vaguely recall those nonprintable characters requiring the null ('\0' or (char)0) somewhere in the string.

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Allowing chars

Post by Jonty800 »

Ahh memories.

I figured this out, if anyone would like a tutorial, feel free to PM me.
You cannot use certain BBCodes: [img].

User avatar
Hellenion
Offline
Posts: 220
Joined: October 20th, 2011, 9:20 am
Location: Subnet
Contact:

Re: Allowing chars

Post by Hellenion »

fragmer, suggestion: Use those fancy box drawing chars to create awesome/retro menus.
A = {x ∈ P(U) | x ∉ x}
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block

Post Reply