private void HandleDC(byte[] message) { Logger.Log(username + " Disconnected."); GlobalMessage(username + " Left."); /*if (OnDisconnect != null) * OnDisconnect(this); * if (PlayerDisconnect != null) * PlayerDisconnect(this);*/ PlayerDisconnectEvent.Call(this); socket.Close(); Disconnect(); foreach (int i in VisibleEntities.ToArray()) { try { Entity e = Entity.Entities[i]; e.p.SendDespawn(id); } catch { /* Ignore Me */ } } }
private void HandleWindowClick(byte[] message) { short slot = util.EndianBitConverter.Big.ToInt16(message, 1); ClickType click = (ClickType)message[3]; short ActionID = util.EndianBitConverter.Big.ToInt16(message, 4); bool Shift = (message[6] == 1); //Console.WriteLine(String.Format("{0} {1} {2}", click, slot, Shift)); if (HasWindowOpen) { window.HandleClick(this, slot, click, ActionID, Shift); } else { inventory.HandleClick(slot, click, ActionID, Shift); } if (!HasWindowOpen) { if (slot == 5) { foreach (int i in VisibleEntities.ToArray()) { Entity e = Entity.Entities[i]; if (!e.isPlayer) { continue; } e.p.SendEntityEquipment(id, 4, inventory.items[5].id, 0); } } else if (slot == 6) { foreach (int i in VisibleEntities.ToArray()) { Entity e = Entity.Entities[i]; if (!e.isPlayer) { continue; } e.p.SendEntityEquipment(id, 3, inventory.items[6].id, 0); } } else if (slot == 7) { foreach (int i in VisibleEntities.ToArray()) { Entity e = Entity.Entities[i]; if (!e.isPlayer) { continue; } e.p.SendEntityEquipment(id, 2, inventory.items[7].id, 0); } } else if (slot == 8) { foreach (int i in VisibleEntities.ToArray()) { Entity e = Entity.Entities[i]; if (!e.isPlayer) { continue; } e.p.SendEntityEquipment(id, 1, inventory.items[8].id, 0); } } else if (slot == inventory.current_index) { foreach (int i in VisibleEntities.ToArray()) { Entity e = Entity.Entities[i]; if (!e.isPlayer) { continue; } e.p.SendEntityEquipment(id, 0, inventory.current_item.id, 0); } } } else { byte currentc = (byte)((current_slot_holding - 9) + window.InventorySize); //TODO TEST if (slot == currentc) { foreach (int i in VisibleEntities.ToArray()) { Entity e = Entity.Entities[i]; if (!e.isPlayer) { continue; } e.p.SendEntityEquipment(id, 0, inventory.current_item.id, 0); } } } if (HasWindowOpen) { if (slot < 5) { // GlobalMessage(GetName() + " " + window.items[1].item); } } else { if (slot < 10) { // GlobalMessage(GetName() + inventory.items[1].item); } } }