Esempio n. 1
0
        public PlayerHandler(Server server, PacketPipe pipe, Player player)
        {
            this.server = server;
            this.pipe = pipe;
            this.player = player;

            pipe.SetHandler(this);
            //server.World.ChunkPool.AddPlayer(player);
            //pipe.SendPacket(new PositionPacket(0, 4, 0));
            SetPosition(player.X, player.Y, player.Z, 0, 0);

            var mainInv = new InventoryItem[36];
            mainInv[0] = new InventoryItem((int)BlockType.Stone, -1);
            mainInv[1] = new InventoryItem((int)BlockType.Dirt, -1);
            mainInv[2] = new InventoryItem((int)BlockType.Cobblestone, -1);
            mainInv[3] = new InventoryItem((int)BlockType.Wood, -1);
            mainInv[4] = new InventoryItem((int)BlockType.Sand, -1);
            mainInv[5] = new InventoryItem((int)BlockType.StillLava, -1);
            mainInv[6] = new InventoryItem((int)BlockType.StillWater, -1);
            mainInv[7] = new InventoryItem((int)BlockType.Sponge, -1);
            mainInv[8] = new InventoryItem(277, 1);
            pipe.SendPacket(new SendInventoryPacket(InventoryType.Main, mainInv));
            pipe.SendPacket(new SendInventoryPacket(InventoryType.Crafting, new InventoryItem[4]));
            pipe.SendPacket(new SendInventoryPacket(InventoryType.Armor, new InventoryItem[4]));
            pipe.SendPacket(new UpdateTimePacket((int)server.World.Time));
            Broadcast(new ChatPacket("Player connected: " + player.Name));
        }
Esempio n. 2
0
 public override void Read(NetworkReader reader)
 {
     Type = (InventoryType)reader.ReadInt32();
     int count = reader.ReadInt16();
     Items = new InventoryItem[count];
     for (int i = 0; i < count; i++) {
         int id = reader.ReadInt16();
         if (id == -1) {
             Items[i] = null;
         } else {
             int itemCount = reader.ReadByte();
             int damage = reader.ReadInt16();
             Items[i] = new InventoryItem(id, itemCount, damage);
         }
     }
 }
Esempio n. 3
0
 public SendInventoryPacket(InventoryType type, InventoryItem[] items)
 {
     Type = type;
     Items = items;
 }