From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/AddGlobalEntityPacket.cpp | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Minecraft.World/AddGlobalEntityPacket.cpp (limited to 'Minecraft.World/AddGlobalEntityPacket.cpp') diff --git a/Minecraft.World/AddGlobalEntityPacket.cpp b/Minecraft.World/AddGlobalEntityPacket.cpp new file mode 100644 index 00000000..bfb27331 --- /dev/null +++ b/Minecraft.World/AddGlobalEntityPacket.cpp @@ -0,0 +1,65 @@ +#include "stdafx.h" +#include +#include +#include "InputOutputStream.h" +#include "net.minecraft.world.entity.h" +#include "net.minecraft.world.entity.global.h" +#include "PacketListener.h" +#include "AddGlobalEntityPacket.h" + + + +const int AddGlobalEntityPacket::LIGHTNING = 1; + +AddGlobalEntityPacket::AddGlobalEntityPacket() +{ + id = -1; + x = 0; + y = 0; + x = 0; + type = 0; +} + +AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr e) +{ + id = e->entityId; + x = Mth::floor(e->x * 32); + y = Mth::floor(e->y * 32); + z = Mth::floor(e->z * 32); + if (dynamic_pointer_cast(e) != NULL) + { + this->type = LIGHTNING; + } + else + { + this->type = 0; + } +} + +void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException +{ + id = dis->readInt(); + type = dis->readByte(); + x = dis->readInt(); + y = dis->readInt(); + z = dis->readInt(); +} + +void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException +{ + dos->writeInt(id); + dos->writeByte(type); + dos->writeInt(x); + dos->writeInt(y); + dos->writeInt(z); +} + +void AddGlobalEntityPacket::handle(PacketListener *listener) +{ + listener->handleAddGlobalEntity(shared_from_this()); +} + +int AddGlobalEntityPacket::getEstimatedSize() +{ + return 17; +} -- cgit v1.2.3