コード例 #1
0
        public override void HandleMcpePlayerList(McpePlayerList message)
        {
            if (message.records is PlayerAddRecords addRecords)
            {
                foreach (var r in addRecords)
                {
                    var u = new API.Utils.UUID(r.ClientUuid.GetBytes());
                    if (_players.ContainsKey(u))
                    {
                        continue;
                    }

                    Texture2D skinTexture;
                    if (r.Skin.TryGetBitmap(out Bitmap skinBitmap))
                    {
                        skinTexture =
                            TextureUtils.BitmapToTexture2D(BaseClient.WorldProvider.Alex.GraphicsDevice, skinBitmap);
                    }
                    else
                    {
                        BaseClient.WorldProvider.Alex.Resources.ResourcePack.TryGetBitmap("entity/alex", out Bitmap rawTexture);
                        skinTexture = TextureUtils.BitmapToTexture2D(BaseClient.WorldProvider.Alex.GraphicsDevice, rawTexture);
                    }

                    BaseClient.WorldReceiver?.AddPlayerListItem(new PlayerListItem(u, r.DisplayName, Gamemode.Survival, 0));
                    PlayerMob m = new PlayerMob(r.DisplayName, BaseClient.WorldReceiver as World, BaseClient, skinTexture, true);

                    if (!_players.TryAdd(u, m))
                    {
                        Log.Warn($"Duplicate player record! {r.ClientUuid}");
                    }
                }
            }
            else if (message.records is PlayerRemoveRecords removeRecords)
            {
                foreach (var r in removeRecords)
                {
                    var u = new UUID(r.ClientUuid.GetBytes());
                    if (_players.TryRemove(u, out var player))
                    {
                        BaseClient.WorldReceiver?.RemovePlayerListItem(u);
                        if (BaseClient.WorldReceiver is World w)
                        {
                            w.DespawnEntity(player.EntityId);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public override void HandleMcpeAddPlayer(McpeAddPlayer message)
        {
            UUID u = new UUID(message.uuid.GetBytes());

            if (_players.TryGetValue(u, out PlayerMob mob))
            {
                mob.EntityId      = message.runtimeEntityId;
                mob.KnownPosition = new PlayerLocation(message.x, message.y, message.z, message.headYaw, message.yaw, message.pitch);

                if (BaseClient.WorldReceiver is World w)
                {
                    mob.IsSpawned = true;
                    w.SpawnEntity(mob.EntityId, mob);
                }
                else
                {
                    mob.IsSpawned = false;
                }
            }
        }
コード例 #3
0
ファイル: Entity.cs プロジェクト: TheBlackPlague/Alex
        public Entity(int entityTypeId, World level, NetworkProvider network)
        {
            Network = network;

            EntityId      = -1;
            Level         = level;
            EntityTypeId  = entityTypeId;
            KnownPosition = new PlayerLocation();
            Inventory     = new Inventory(46);
            //	HealthManager = new HealthManager(this);

            Inventory.SlotChanged += OnInventorySlotChanged;
            Inventory.SelectedHotbarSlotChanged += InventoryOnSelectedHotbarSlotChanged;

            HideNameTag         = true;
            ServerEntity        = true;
            IsAffectedByGravity = true;

            HealthManager = new HealthManager(this);
            UUID          = new UUID(Guid.NewGuid().ToByteArray());
        }
コード例 #4
0
ファイル: World.cs プロジェクト: K4mey/Alex
 public void RemovePlayerListItem(UUID item)
 {
     PlayerList.Entries.Remove(item);
 }