コード例 #1
0
        static void SpawnRaw(Player dst, byte id, Entity entity, Position pos, Orientation rot,
                             string skin, string name, string model)
        {
            // NOTE: Fix for standard clients
            if (id == Entities.SelfID)
            {
                pos.Y -= 22;
            }
            name = Colors.Cleanup(name, dst.hasTextColors);

            if (dst.Supports(CpeExt.ExtPlayerList, 2))
            {
                dst.Send(Packet.ExtAddEntity2(id, skin, name, pos, rot, dst.hasCP437, dst.hasExtPositions));
            }
            else if (dst.hasExtList)
            {
                dst.Send(Packet.ExtAddEntity(id, skin, name, dst.hasCP437));
                dst.Send(Packet.Teleport(id, pos, rot, dst.hasExtPositions));
            }
            else
            {
                dst.Send(Packet.AddEntity(id, name, pos, rot, dst.hasCP437, dst.hasExtPositions));
            }

            if (dst.hasChangeModel && !model.CaselessEq("humanoid"))
            {
                SendModel(dst, id, model);
            }
            if (dst.Supports(CpeExt.EntityProperty))
            {
                dst.Send(Packet.EntityProperty(id, EntityProp.RotX, Orientation.PackedToDegrees(rot.RotX)));
                dst.Send(Packet.EntityProperty(id, EntityProp.RotZ, Orientation.PackedToDegrees(rot.RotZ)));
                SendModelScales(dst, id, entity);
            }
        }
コード例 #2
0
        static void SendModelScale(Player pl, byte id, EntityProp axis, float value)
        {
            if (value == 0)
            {
                return;
            }
            int packed = (int)(value * 1000);

            if (packed == 0)
            {
                return;
            }
            pl.Send(Packet.EntityProperty(id, axis, packed));
        }
コード例 #3
0
        static void SendModelScale(Player dst, byte id, EntityProp axis, float value, float max)
        {
            if (value == 0)
            {
                return;
            }
            value = Math.Min(value, max);

            int packed = (int)(value * 1000);

            if (packed == 0)
            {
                return;
            }
            dst.Send(Packet.EntityProperty(id, axis, packed));
        }
コード例 #4
0
        public static void UpdateEntityProp(Entity entity, EntityProp prop, int value)
        {
            Player[] players = PlayerInfo.Online.Items;
            Level    lvl     = entity.Level;

            Orientation rot   = entity.Rot;
            byte        angle = Orientation.DegreesToPacked(value);

            if (prop == EntityProp.RotX)
            {
                rot.RotX = angle;
            }
            if (prop == EntityProp.RotY)
            {
                rot.RotY = angle;
            }
            if (prop == EntityProp.RotZ)
            {
                rot.RotZ = angle;
            }

            entity.Rot = rot;
            if (prop == EntityProp.RotY)
            {
                entity.SetYawPitch(rot.RotY, rot.HeadX);
            }

            foreach (Player pl in players)
            {
                if (pl.level != lvl || !pl.Supports(CpeExt.EntityProperty))
                {
                    continue;
                }
                if (!pl.CanSeeEntity(entity))
                {
                    continue;
                }

                byte id = (pl == entity) ? Entities.SelfID : entity.EntityID;
                pl.Send(Packet.EntityProperty(id, prop,
                                              Orientation.PackedToDegrees(angle)));
            }
        }
コード例 #5
0
        static void SpawnRaw(Player dst, byte id, Entity e, Position pos, Orientation rot,
                             string skin, string name, string model)
        {
            dst.Session.SendSpawnEntity(id, name, skin, pos, rot);

            if (dst.hasChangeModel)
            {
                OnSendingModelEvent.Call(e, ref model, dst);
                if (!model.CaselessEq("humanoid"))
                {
                    dst.Session.SendChangeModel(id, model);
                }
            }

            if (dst.Supports(CpeExt.EntityProperty))
            {
                dst.Send(Packet.EntityProperty(id, EntityProp.RotX, Orientation.PackedToDegrees(rot.RotX)));
                dst.Send(Packet.EntityProperty(id, EntityProp.RotZ, Orientation.PackedToDegrees(rot.RotZ)));
                SendModelScales(dst, id, e);
            }
        }