public MCClient(string server, int port, string username, string password, string serverpassword, bool useauth) { m_Client = new MCRawClient(server, port); m_Username = username; m_Password = password; m_ServerPassword = serverpassword; m_UseAuth = useauth; if (m_UseAuth) { m_AccountInfo = MCLogin.GetInfo(m_Username, m_Password); if (m_AccountInfo == null) throw new Exception("Invalid credentials or bot is outdated."); } m_SelectedItem = MCBlockType.Air; m_Position = new Point3D(); m_ItemInv = null; m_CraftInv = null; m_EquipInv = null; m_Players = new List<MCPlayer>(); Time = 0; SpawnPoint = new Point3D(); m_Yaw = 0f; m_Pitch = 0f; m_Client.OnDisconnect += new DisconnectEventHandler(m_Client_OnDisconnect); m_Client.OnHandshake += new HandshakeEventHandler(m_Client_OnHandshake); m_Client.OnLogin += new LoginEventHandler(m_Client_OnLogin); m_Client.OnUpdateTime += new UpdateTimeEventHandler(m_Client_OnUpdateTime); m_Client.OnPlayerMoveLook += new PlayerMoveLookEventHandler(m_Client_OnPlayerMoveLook); m_Client.OnAddInventory += new AddInventoryEventHandler(m_Client_OnAddInventory); m_Client.OnPlayerInventory += new PlayerInventoryEventHandler(m_Client_OnPlayerInventory); m_Client.OnSpawnPosition += new SpawnPositionEventHandler(m_Client_OnSpawnPosition); m_Client.OnNamedEntitySpawn += new NamedEntitySpawnEventHandler(m_Client_OnNamedEntitySpawn); m_Client.OnChat += new ChatEventHandler(m_Client_OnChat); m_Client.OnAddVehicle += new AddVehicleEventHandler(m_Client_OnAddVehicle); }
public void PlaceBlock(MCBlockType block, Point3D position, MCBlockFace direction) { SendPacket(MCPackets.CreatePlayerBlockPlacePacket((short)block, (int)position.X, (byte)position.Y, (int)position.Z, (byte)direction)); }
public void ChangeHolding(MCBlockType item) { SendPacket(MCPackets.CreatePlayerHoldingPacket(0, (short)item)); }