Ejemplo n.º 1
0
        private void GameTick(object state)
        {
            if (World == null)
            {
                return;
            }

            if (_initiated)
            {
                _tickTime++;

                if (World.Player != null && Client.HasSpawned)
                {
                    //	player.IsSpawned = Spawned;

                    if (World.Player.IsFlying != _flying)
                    {
                        _flying = World.Player.IsFlying;

                        McpeAdventureSettings settings = McpeAdventureSettings.CreateObject();
                        settings.flags = GetAdventureFlags();
                        Client.SendPacket(settings);
                        //SendPlayerAbilities(player);
                    }

                    var pos = (PlayerLocation)World.Player.KnownPosition.Clone();

                    if (pos.DistanceTo(_lastSentLocation) > 0.0f ||
                        MathF.Abs(pos.HeadYaw - _lastSentLocation.HeadYaw) > 0.0f ||
                        MathF.Abs(pos.Pitch - _lastSentLocation.Pitch) > 0.0f)
                    {
                        SendLocation(pos);
                        _lastSentLocation = pos;
                    }

                    if ((pos.DistanceTo(_lastLocation) > 16f || MathF.Abs(pos.HeadYaw - _lastLocation.HeadYaw) >= 5.0f) &&
                        (_tickTime - _lastPrioritization >= 10))
                    {
                        World.ChunkManager.FlagPrioritization();

                        SendLocation(pos);

                        _lastLocation = pos;
                        UnloadChunks(new ChunkCoordinates(pos), Client.ChunkRadius + 3);

                        _lastPrioritization = _tickTime;
                    }
                }

                if (_tickTime % 20 == 0 && CustomConnectedPong.CanPing)
                {
                    Client.SendPing();
                }

                World.Player.OnTick();
                World.EntityManager.Tick();
                World.PhysicsEngine.Tick();
            }
        }
Ejemplo n.º 2
0
 public override void HandleMcpeAdventureSettings(McpeAdventureSettings message)
 {
     base.HandleMcpeAdventureSettings(message);
     if (BaseClient.WorldReceiver.GetPlayerEntity() is Player player)
     {
         player.CanFly   = ((message.flags & 0x40) == 0x40);
         player.IsFlying = ((message.flags & 0x200) == 0x200);
     }
 }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public override void HandleMcpeAdventureSettings(McpeAdventureSettings message)
        {
            if (message.entityUniqueId != EntityId)
            {
                //We are trying to change another players adventuresettings.
                return;
            }

            base.HandleMcpeAdventureSettings(message);
        }
Ejemplo n.º 4
0
        private void GameTick(object state)
        {
            if (World == null)
            {
                return;
            }

            if (_initiated)
            {
                var p = World.Player;
                if (p != null && p is Player player && Client.HasSpawned)
                {
                    //	player.IsSpawned = Spawned;

                    if (player.IsFlying != _flying)
                    {
                        _flying = player.IsFlying;

                        McpeAdventureSettings settings = McpeAdventureSettings.CreateObject();
                        settings.flags = GetAdventureFlags();
                        Client.SendPacket(settings);
                        //SendPlayerAbilities(player);
                    }

                    var pos = (PlayerLocation)player.KnownPosition.Clone();

                    if (pos.DistanceTo(_lastSentLocation) > 0.0f)
                    {
                        Client.SendMcpeMovePlayer(new MiNET.Utils.PlayerLocation(pos.X,
                                                                                 pos.Y + Player.EyeLevel, pos.Z, pos.HeadYaw,
                                                                                 pos.Yaw, -pos.Pitch), player.KnownPosition.OnGround);

                        _lastSentLocation = pos;
                    }

                    if (pos.DistanceTo(_lastLocation) > 16f && _stopwatch.ElapsedMilliseconds > 500)
                    {
                        World.ChunkManager.FlagPrioritization();

                        _stopwatch.Stop();
                        _stopwatch.Reset();
                        _lastLocation = pos;
                        UnloadChunks(new ChunkCoordinates(pos), Client.ChunkRadius + 3);
                        _stopwatch.Restart();
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void HandleMcpeAdventureSettings(McpeAdventureSettings message)
 {
 }
Ejemplo n.º 6
0
 public virtual void HandleMcpeAdventureSettings(McpeAdventureSettings message)
 {
     Client.UserPermission = (CommandPermission)message.commandPermission;
 }
Ejemplo n.º 7
0
 public override void HandleMcpeAdventureSettings(McpeAdventureSettings message)
 {
 }
 public void HandleMcpeAdventureSettings(McpeAdventureSettings message)
 {
     WritePackage(message);
 }
Ejemplo n.º 9
0
        private void GameTick(object state)
        {
            var isRealTick = _isRealTick;

            _isRealTick = !isRealTick;

            if (World == null)
            {
                return;
            }

            if (_initiated)
            {
                if (_isRealTick)
                {
                    _tickTime++;
                }

                var p = World.Player;
                if (p != null && p is Player player && Client.HasSpawned)
                {
                    //	player.IsSpawned = Spawned;

                    if (player.IsFlying != _flying && _isRealTick)
                    {
                        _flying = player.IsFlying;

                        McpeAdventureSettings settings = McpeAdventureSettings.CreateObject();
                        settings.flags = GetAdventureFlags();
                        Client.SendPacket(settings);
                        //SendPlayerAbilities(player);
                    }

                    var pos = (PlayerLocation)player.KnownPosition.Clone();

                    if (pos.DistanceTo(_lastSentLocation) > 0.0f)
                    {
                        Client.SendMcpeMovePlayer(new MiNET.Utils.PlayerLocation(pos.X,
                                                                                 pos.Y + Player.EyeLevel, pos.Z, pos.HeadYaw,
                                                                                 pos.Yaw, -pos.Pitch), player.KnownPosition.OnGround);

                        _lastSentLocation = pos;
                    }

                    if ((pos.DistanceTo(_lastLocation) > 16f || MathF.Abs(pos.HeadYaw - _lastLocation.HeadYaw) >= 10f) && (_tickTime - _lastPrioritization >= 10 && _isRealTick))
                    {
                        World.ChunkManager.FlagPrioritization();

                        _lastLocation = pos;
                        UnloadChunks(new ChunkCoordinates(pos), Client.ChunkRadius + 3);

                        _lastPrioritization = _tickTime;
                    }
                }

                if (_isRealTick && _tickTime % 20 == 0 && CustomConnectedPong.CanPing)
                {
                    Client.SendPing();
                }


                if (_isRealTick)
                {
                    World.Player.OnTick();
                    World.EntityManager.Tick();
                }
            }
        }