@@ -653,8 +653,6 @@ public virtual void HandleMcpeAnimate(McpeAnimate message)
653653 Level . RelayBroadcast ( this , msg ) ;
654654 }
655655
656- Action _dimensionFunc ;
657-
658656 /// <summary>
659657 /// Handles the player action.
660658 /// </summary>
@@ -771,12 +769,7 @@ public virtual void HandleMcpePlayerAction(McpePlayerAction message)
771769 }
772770 case PlayerAction . DimensionChangeAck :
773771 {
774- if ( _dimensionFunc != null )
775- {
776- _dimensionFunc ( ) ;
777- _dimensionFunc = null ;
778- }
779-
772+ SendPlayerStatus ( 3 ) ;
780773 break ;
781774 }
782775 case PlayerAction . WorldImmutable :
@@ -1452,40 +1445,20 @@ public void SetPosition(PlayerLocation position, bool teleport = true)
14521445
14531446 public virtual void Teleport ( PlayerLocation newPosition )
14541447 {
1455- if ( ! Monitor . TryEnter ( _teleportSync ) ) return ;
1456-
1457- try
1458- {
1459- bool oldNoAi = NoAi ;
1460- SetNoAi ( true ) ;
1461-
1462- if ( ! IsChunkInCache ( newPosition ) )
1463- {
1464- // send teleport straight up, no chunk loading
1465- SetPosition ( new PlayerLocation
1466- {
1467- X = KnownPosition . X ,
1468- Y = 4000 ,
1469- Z = KnownPosition . Z ,
1470- Yaw = 91 ,
1471- Pitch = 28 ,
1472- HeadYaw = 91 ,
1473- } ) ;
1474-
1475- ForcedSendChunk ( newPosition ) ;
1476- }
1477-
1478- // send teleport to spawn
1479- SetPosition ( newPosition ) ;
1448+ KnownPosition = newPosition ;
1449+ LastUpdatedTime = DateTime . UtcNow ;
14801450
1481- SetNoAi ( oldNoAi ) ;
1482- }
1483- finally
1484- {
1485- Monitor . Exit ( _teleportSync ) ;
1486- }
1451+ var packet = McpeMovePlayer . CreateObject ( ) ;
1452+ packet . runtimeEntityId = EntityManager . EntityIdSelf ;
1453+ packet . x = newPosition . X ;
1454+ packet . y = newPosition . Y + 1.62f ;
1455+ packet . z = newPosition . Z ;
1456+ packet . yaw = newPosition . Yaw ;
1457+ packet . headYaw = newPosition . HeadYaw ;
1458+ packet . pitch = newPosition . Pitch ;
1459+ packet . mode = 1 ;
14871460
1488- MiNetServer . FastThreadPool . QueueUserWorkItem ( SendChunksForKnownPosition ) ;
1461+ SendPacket ( packet ) ;
14891462 }
14901463
14911464 private bool IsChunkInCache ( PlayerLocation position )
@@ -1907,10 +1880,7 @@ public virtual void SpawnLevel(Level toLevel, PlayerLocation spawnPoint, bool us
19071880 bool oldNoAi = NoAi ;
19081881 SetNoAi ( true ) ;
19091882
1910- if ( useLoadingScreen )
1911- {
1912- SendChangeDimension ( Dimension . Nether ) ;
1913- }
1883+ SendChangeDimension ( Dimension . Nether ) ;
19141884
19151885 if ( toLevel == null && levelFunc != null )
19161886 {
@@ -1929,10 +1899,7 @@ public virtual void SpawnLevel(Level toLevel, PlayerLocation spawnPoint, bool us
19291899
19301900 Action transferFunc = delegate
19311901 {
1932- if ( useLoadingScreen )
1933- {
1934- SendChangeDimension ( Dimension . Overworld ) ;
1935- }
1902+ SendChangeDimension ( Dimension . Overworld ) ;
19361903
19371904 Level . RemovePlayer ( this , true ) ;
19381905
@@ -1977,16 +1944,7 @@ public virtual void SpawnLevel(Level toLevel, PlayerLocation spawnPoint, bool us
19771944 } ) ;
19781945 } ;
19791946
1980-
1981- if ( useLoadingScreen )
1982- {
1983- _dimensionFunc = transferFunc ;
1984- ForcedSendEmptyChunks ( ) ;
1985- }
1986- else
1987- {
1988- transferFunc ( ) ;
1989- }
1947+ transferFunc ( ) ;
19901948 }
19911949
19921950 protected virtual void SendChangeDimension ( Dimension dimension , bool respawn = false , Vector3 position = new Vector3 ( ) )
0 commit comments