2121import java .util .logging .Level ;
2222
2323import org .bukkit .Bukkit ;
24- import org .bukkit .Chunk ;
24+ import org .bukkit .Location ;
2525import org .bukkit .command .CommandSender ;
2626import org .bukkit .entity .Player ;
2727
@@ -100,6 +100,18 @@ private void sendUpdateSelf(WrappedGameProfile gameProfile) throws FieldAccessEx
100100 respawn .getGameModes ().write (0 , gamemode );
101101 respawn .getWorldTypeModifier ().write (0 , receiver .getWorld ().getWorldType ());
102102
103+ Location location = receiver .getLocation ().clone ();
104+
105+ PacketContainer teleport = protocolManager .createPacket (PacketType .Play .Server .POSITION );
106+ teleport .getModifier ().writeDefaults ();
107+ teleport .getDoubles ().write (0 , location .getX ());
108+ teleport .getDoubles ().write (1 , location .getY ());
109+ teleport .getDoubles ().write (2 , location .getZ ());
110+ teleport .getFloat ().write (0 , location .getYaw ());
111+ teleport .getFloat ().write (1 , location .getPitch ());
112+ //send an invalid teleport id in order to let bukkit ignore the incoming confirm packet
113+ teleport .getIntegers ().writeSafely (0 , -1 );
114+
103115 try {
104116 //remove the old skin - client updates it only on a complete remove and add
105117 protocolManager .sendServerPacket (receiver , removeInfo );
@@ -108,12 +120,8 @@ private void sendUpdateSelf(WrappedGameProfile gameProfile) throws FieldAccessEx
108120 //notify the client that it should update the own skin
109121 protocolManager .sendServerPacket (receiver , respawn );
110122
111- //refresh the chunk
112- Chunk chunk = receiver .getWorld ().getChunkAt (receiver .getLocation ());
113- receiver .getWorld ().refreshChunk (chunk .getX (), chunk .getZ ());
114-
115123 //prevent the moved too quickly message
116- receiver . teleport (receiver . getLocation (). clone () );
124+ protocolManager . sendServerPacket (receiver , teleport );
117125
118126 //send the current inventory - otherwise player would have an empty inventory
119127 receiver .updateInventory ();
0 commit comments