mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
migrate ALMOST everything from source tree into client
This commit is contained in:
45
source/client/network/Packets/AddPlayerPacket.cpp
Normal file
45
source/client/network/Packets/AddPlayerPacket.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
AddPlayerPacket::AddPlayerPacket(const RakNet::RakNetGUID& guid, RakNet::RakString name, int id, float x, float y, float z)
|
||||
{
|
||||
m_guid = guid;
|
||||
m_name = name;
|
||||
m_id = id;
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_z = z;
|
||||
}
|
||||
|
||||
void AddPlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void AddPlayerPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_ADD_PLAYER);
|
||||
bs->Write(m_guid);
|
||||
bs->Write(m_name);
|
||||
bs->Write(m_id);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_y);
|
||||
bs->Write(m_z);
|
||||
}
|
||||
|
||||
void AddPlayerPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_guid);
|
||||
bs->Read(m_name);
|
||||
bs->Read(m_id);
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_y);
|
||||
bs->Read(m_z);
|
||||
}
|
||||
55
source/client/network/Packets/ChunkDataPacket.cpp
Normal file
55
source/client/network/Packets/ChunkDataPacket.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
#include "LevelChunk.hpp"
|
||||
|
||||
void ChunkDataPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void ChunkDataPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_CHUNK_DATA);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_z);
|
||||
|
||||
// Well, we first have to prepare the data.
|
||||
m_data.Reset();
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
m_data.Write(m_pChunk->m_updateMap[i]);
|
||||
|
||||
// if nothing was updated:
|
||||
if (!m_pChunk->m_updateMap[i])
|
||||
continue;
|
||||
|
||||
for (int y = 0; y < 8; y++)
|
||||
{
|
||||
if ((m_pChunk->m_updateMap[i] >> y) & 1)
|
||||
{
|
||||
int idx = ((i & 0xF) << 11) | ((i >> 4) << 7) + (y * 16);
|
||||
//write the tile data
|
||||
|
||||
m_data.Write((const char*) &m_pChunk->m_pBlockData[idx], 16 * sizeof(TileID));
|
||||
m_data.Write((const char*) &m_pChunk->m_tileData [idx >> 1], 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bs->Write(m_data);
|
||||
}
|
||||
|
||||
void ChunkDataPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_z);
|
||||
bs->Read(m_data);
|
||||
}
|
||||
25
source/client/network/Packets/LoginPacket.cpp
Normal file
25
source/client/network/Packets/LoginPacket.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void LoginPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void LoginPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_LOGIN);
|
||||
bs->Write(m_str);
|
||||
}
|
||||
|
||||
void LoginPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_str);
|
||||
}
|
||||
25
source/client/network/Packets/MessagePacket.cpp
Normal file
25
source/client/network/Packets/MessagePacket.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void MessagePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void MessagePacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_MESSAGE);
|
||||
bs->Write(m_str);
|
||||
}
|
||||
|
||||
void MessagePacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_str);
|
||||
}
|
||||
35
source/client/network/Packets/MovePlayerPacket.cpp
Normal file
35
source/client/network/Packets/MovePlayerPacket.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void MovePlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void MovePlayerPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_MOVE_PLAYER);
|
||||
bs->Write(m_id);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_y);
|
||||
bs->Write(m_z);
|
||||
bs->Write(m_pitch);
|
||||
bs->Write(m_yaw);
|
||||
}
|
||||
|
||||
void MovePlayerPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_id);
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_y);
|
||||
bs->Read(m_z);
|
||||
bs->Read(m_pitch);
|
||||
bs->Read(m_yaw);
|
||||
}
|
||||
35
source/client/network/Packets/PlaceBlockPacket.cpp
Normal file
35
source/client/network/Packets/PlaceBlockPacket.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void PlaceBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void PlaceBlockPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_PLACE_BLOCK);
|
||||
bs->Write(m_playerID);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_z);
|
||||
bs->Write(m_y);
|
||||
bs->Write(m_tile);
|
||||
bs->Write(m_face);
|
||||
}
|
||||
|
||||
void PlaceBlockPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_playerID);
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_z);
|
||||
bs->Read(m_y);
|
||||
bs->Read(m_tile);
|
||||
bs->Read(m_face);
|
||||
}
|
||||
27
source/client/network/Packets/PlayerEquipmentPacket.cpp
Normal file
27
source/client/network/Packets/PlayerEquipmentPacket.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void PlayerEquipmentPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void PlayerEquipmentPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_PLAYER_EQUIPMENT);
|
||||
bs->Write(m_playerID);
|
||||
bs->Write(m_itemID);
|
||||
}
|
||||
|
||||
void PlayerEquipmentPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_playerID);
|
||||
bs->Read(m_itemID);
|
||||
}
|
||||
31
source/client/network/Packets/RemoveBlockPacket.cpp
Normal file
31
source/client/network/Packets/RemoveBlockPacket.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void RemoveBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void RemoveBlockPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_REMOVE_BLOCK);
|
||||
bs->Write(m_playerID);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_z);
|
||||
bs->Write(m_y);
|
||||
}
|
||||
|
||||
void RemoveBlockPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_playerID);
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_z);
|
||||
bs->Read(m_y);
|
||||
}
|
||||
25
source/client/network/Packets/RemoveEntityPacket.cpp
Normal file
25
source/client/network/Packets/RemoveEntityPacket.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void RemoveEntityPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void RemoveEntityPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_REMOVE_ENTITY);
|
||||
bs->Write(m_id);
|
||||
}
|
||||
|
||||
void RemoveEntityPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_id);
|
||||
}
|
||||
27
source/client/network/Packets/RequestChunkPacket.cpp
Normal file
27
source/client/network/Packets/RequestChunkPacket.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void RequestChunkPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void RequestChunkPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_REQUEST_CHUNK);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_z);
|
||||
}
|
||||
|
||||
void RequestChunkPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_z);
|
||||
}
|
||||
35
source/client/network/Packets/StartGamePacket.cpp
Normal file
35
source/client/network/Packets/StartGamePacket.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void StartGamePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void StartGamePacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_START_GAME);
|
||||
bs->Write(field_4);
|
||||
bs->Write(field_8);
|
||||
bs->Write(field_C);
|
||||
bs->Write(field_10);
|
||||
bs->Write(field_14);
|
||||
bs->Write(field_18);
|
||||
}
|
||||
|
||||
void StartGamePacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(field_4);
|
||||
bs->Read(field_8);
|
||||
bs->Read(field_C);
|
||||
bs->Read(field_10);
|
||||
bs->Read(field_14);
|
||||
bs->Read(field_18);
|
||||
}
|
||||
33
source/client/network/Packets/UpdateBlockPacket.cpp
Normal file
33
source/client/network/Packets/UpdateBlockPacket.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Packet.hpp"
|
||||
|
||||
void UpdateBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback)
|
||||
{
|
||||
pCallback->handle(guid, this);
|
||||
}
|
||||
|
||||
void UpdateBlockPacket::write(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Write(PACKET_UPDATE_BLOCK);
|
||||
bs->Write(m_x);
|
||||
bs->Write(m_z);
|
||||
bs->Write(m_y);
|
||||
bs->Write(m_tile);
|
||||
bs->Write(m_data);
|
||||
}
|
||||
|
||||
void UpdateBlockPacket::read(RakNet::BitStream* bs)
|
||||
{
|
||||
bs->Read(m_x);
|
||||
bs->Read(m_z);
|
||||
bs->Read(m_y);
|
||||
bs->Read(m_tile);
|
||||
bs->Read(m_data);
|
||||
}
|
||||
Reference in New Issue
Block a user