diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/SignUpdatePacket.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/SignUpdatePacket.cpp')
| -rw-r--r-- | Minecraft.World/SignUpdatePacket.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Minecraft.World/SignUpdatePacket.cpp b/Minecraft.World/SignUpdatePacket.cpp new file mode 100644 index 00000000..7b3a3217 --- /dev/null +++ b/Minecraft.World/SignUpdatePacket.cpp @@ -0,0 +1,71 @@ +#include "stdafx.h" +#include <iostream> +#include "InputOutputStream.h" +#include "PacketListener.h" +#include "net.minecraft.world.level.tile.entity.h" +#include "SignUpdatePacket.h" + + + +SignUpdatePacket::SignUpdatePacket() +{ + shouldDelay = true; + m_bVerified=false; + m_bCensored=false; + x = 0; + y = 0; + z = 0; + +} + +SignUpdatePacket::SignUpdatePacket(int x, int y, int z, bool bVerified, bool bCensored, wstring lines[]) +{ + shouldDelay = true; + this->m_bVerified=bVerified; + this->m_bCensored=bCensored; + this->x = x; + this->y = y; + this->z = z; + for( int i = 0; i < MAX_SIGN_LINES; i++ ) this->lines[i] = lines[i]; +} + +void SignUpdatePacket::read(DataInputStream *dis) //throws IOException +{ + x = dis->readInt(); + y = dis->readShort(); + z = dis->readInt(); + this->m_bVerified=dis->readBoolean(); + this->m_bCensored=dis->readBoolean();; + for (int i = 0; i < MAX_SIGN_LINES; i++) + lines[i] = readUtf(dis, SignTileEntity::MAX_LINE_LENGTH); +} + +void SignUpdatePacket::write(DataOutputStream *dos) //throws IOException +{ + dos->writeInt(x); + dos->writeShort(y); + dos->writeInt(z); + dos->writeBoolean(m_bVerified); + dos->writeBoolean(m_bCensored); + for (int i = 0; i < MAX_SIGN_LINES; i++) + writeUtf(lines[i], dos); +} + +void SignUpdatePacket::handle(PacketListener *listener) +{ + listener->handleSignUpdate(shared_from_this()); +} + +int SignUpdatePacket::getEstimatedSize() +{ + int l = 0; + l+=sizeof(int); + l+=sizeof(short); + l+=sizeof(int); + l+=sizeof(byte); + l+=sizeof(byte); + + for (int i = 0; i < MAX_SIGN_LINES; i++) + l += (int)lines[i].length(); + return l; +} |
