It is currently November 13th, 2018, 8:31 pm


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Quick question
PostPosted: January 18th, 2012, 11:39 am 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
I was looking at the SetSpawn handler and saw:

Code:
player.TeleportTo(player.World.Map.Spawn);
                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?

Thanks!

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Quick question
PostPosted: January 18th, 2012, 12:48 pm 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
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...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Quick question
PostPosted: January 19th, 2012, 2:55 am 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
So what would happen if I changed player.ListName to "fragmer"... would I become you?

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Quick question
PostPosted: January 19th, 2012, 9:04 am 
User avatar

Joined: October 20th, 2011, 9:20 am
Posts: 220
Location: Subnet
You would become fragmer indeed. At least others will see fragmer's skin and his name floating above your head.

_________________
A = {x ∈ P(U) | x ∉ x}

Show
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


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Quick question
PostPosted: January 19th, 2012, 10:50 am 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
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?


Nvm.

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

eg;
Code:
foreach(Player p in player.World.Players){
p.ResetVisibleEntities();
}

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net