fCraft Forums

Quick question
Page 1 of 1

Author:  Jonty800 [ January 18th, 2012, 11:39 am ]
Post subject:  Quick question

I was looking at the SetSpawn handler and saw:

                player.Send(PacketWriter.MakeAddEntity(255, player.ListName, player.Position));

Why do you send an entity to the player? What does it do compared to just sending the Teleport packet? And why is the ID 255?


Author:  fragmer [ January 18th, 2012, 12:48 pm ]
Post subject:  Re: Quick question

Minecraft treats IDs as signed bytes. From Minecraft's perspective, bytes have range (-128...127). Minecraft treats IDs that are less than 1 as referring to "self." In C#, bytes are unsigned and have range (0...255). Anyways, "-255" in C# means "-1" in Java.

When you send a an AddEntity packet with a "self" ID, it sets player's spawn and teleports them to the given position. I'm not sure why it sends a teleport packet as well (which only teleports the player, without setting spawn). I'll look back through the old commits to see if there's a real reason for it. Could be one of those Minecraft client bug workarounds, I don't even remember...

Author:  Jonty800 [ January 19th, 2012, 2:55 am ]
Post subject:  Re: Quick question

So what would happen if I changed player.ListName to "fragmer"... would I become you?

Author:  Hellenion [ January 19th, 2012, 9:04 am ]
Post subject:  Re: Quick question

You would become fragmer indeed. At least others will see fragmer's skin and his name floating above your head.

Author:  Jonty800 [ January 19th, 2012, 10:50 am ]
Post subject:  Re: Quick question

I tested this, it didn't work haha!
Even after a /wflush to update the visible entities.

Out of curiosity, what is the safest way to change a player's skin?


Is the best way to update the player's new skin to use player.ResetVisibleEntities for everyone in the world?

foreach(Player p in player.World.Players){

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group