Beispiel #1
0
        public PacketHandler(string host, int port, HandlerMode mode)
        {
            Mode = mode;

            _tcp = new TcpClient(host, port);

            _stream = new NetworkStreamMC(_tcp.GetStream());

            _packetHandler = new Thread(Worker)
                                 {
                                     Name = "SC#PacketHandler",
                                     IsBackground = true
                                 };

            _packetHandler.Start();
        }
Beispiel #2
0
        public override void Read(NetworkStreamMC stream)
        {
            X = stream.Int32();
            Y = stream.Int16();
            Z = stream.Int32();

            SizeX = stream.Byte();
            SizeY = stream.Byte();
            SizeZ = stream.Byte();

            Data = stream.Bytes(stream.Int32());
        }
Beispiel #3
0
        public override void Read(NetworkStreamMC stream)
        {
            InvId = stream.Byte();
            SlotId = stream.Int16();
            ItemId = stream.Int16();

            if (ItemId == -1) return;
            ItemCount = stream.Byte();
            ItemHealth = stream.Byte();
        }
Beispiel #4
0
        public override void Read(NetworkStreamMC stream)
        {
            Type = stream.Byte();
            Count = stream.Int16();

            Items = new Item[Count];

            for (int i = 0; i < Count; ++i)
            {
                var id = (Enums.Item)stream.Int16();
                if (id == Enums.Item.Invalid)
                    Items[i] = new Item { Id = id, Count = 0, Health = 0 };
                else
                    Items[i] = new Item { Id = id, Count = stream.Byte(), Health = stream.Int16() };
            }
        }
Beispiel #5
0
        public override void Read(NetworkStreamMC stream)
        {
            X = stream.Double();
            Y = stream.Double();
            Z = stream.Double();

            RadiusMaybe = stream.Single();

            Count = stream.Int32();

            Records = new byte[Count][];

            for (int i = 0; i < Count; ++i)
            {
                Records[i] = stream.Bytes(3);
            }
        }
Beispiel #6
0
        public override void Read(NetworkStreamMC stream)
        {
            X = stream.Int32();
            Y = stream.Byte();
            Z = stream.Int32();

            Direction = stream.Byte();

            ItemId = stream.Int16();

            if (ItemId == -1) return;
            ItemAmount = stream.Byte();
            ItemHealth = stream.Byte();
        }
Beispiel #7
0
        public override void Read(NetworkStreamMC stream)
        {
            X = stream.Int32();
            Z = stream.Int32();

            Size = stream.Int16();

            Coordinates = new short[Size];

            for (short i = 0; i < Size; ++i)
            {
                Coordinates[i] = stream.Int16();
            }

            Types = stream.Bytes(Size);
            Metadata = stream.Bytes(Size);
        }
Beispiel #8
0
 public void Send(NetworkStreamMC stream)
 {
     var writer = new PacketWriter {(byte) Id};
     Write(writer);
     stream.Write(writer.ToArray(), 0, writer.Count());
 }
Beispiel #9
0
 public virtual void Read(NetworkStreamMC stream)
 {
     foreach (var p in GetType().GetProperties().OrderBy(p => p.MetadataToken).Where(p => typeof(PacketBase).GetProperty(p.Name) == null))
     {
         p.SetValue(this, stream.GetType().InvokeMember(p.PropertyType.Name, BindingFlags.InvokeMethod, null, stream, null), null);
     }
 }