aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ContainerOpenPacket.cpp
diff options
context:
space:
mode:
authordaoge <3523206925@qq.com>2026-03-03 03:04:10 +0800
committerGitHub <noreply@github.com>2026-03-03 03:04:10 +0800
commitb3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch)
tree267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/ContainerOpenPacket.cpp
parent84c31a2331f7a0ec85b9d438992e244f60e5020f (diff)
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/ContainerOpenPacket.cpp')
-rw-r--r--Minecraft.World/ContainerOpenPacket.cpp54
1 files changed, 42 insertions, 12 deletions
diff --git a/Minecraft.World/ContainerOpenPacket.cpp b/Minecraft.World/ContainerOpenPacket.cpp
index 7cb530cf..d5268922 100644
--- a/Minecraft.World/ContainerOpenPacket.cpp
+++ b/Minecraft.World/ContainerOpenPacket.cpp
@@ -4,20 +4,30 @@
#include "PacketListener.h"
#include "ContainerOpenPacket.h"
-ContainerOpenPacket::ContainerOpenPacket()
-{
- containerId = 0;
- type = 0;
- title = 0;
- size = 0;
-}
-
-ContainerOpenPacket::ContainerOpenPacket(int containerId, int type, int title, int size)
+void ContainerOpenPacket::_init(int containerId, int type, const wstring &title, int size, bool customName, int entityId)
{
this->containerId = containerId;
this->type = type;
this->title = title;
this->size = size;
+ this->customName = customName;
+ this->entityId = entityId;
+}
+
+ContainerOpenPacket::ContainerOpenPacket()
+{
+ _init(0, 0, L"", 0, false, 0);
+
+}
+
+ContainerOpenPacket::ContainerOpenPacket(int containerId, int type, const wstring &title, int size, bool customName)
+{
+ _init(containerId, type, title, size, customName, 0);
+}
+
+ContainerOpenPacket::ContainerOpenPacket(int containerId, int type, const wstring &title, int size, bool customName, int entityId)
+{
+ _init(containerId, type, title, size, customName, entityId);
}
void ContainerOpenPacket::handle(PacketListener *listener)
@@ -30,19 +40,39 @@ void ContainerOpenPacket::read(DataInputStream *dis) //throws IOException
{
containerId = dis->readByte() & 0xff;
type = dis->readByte() & 0xff;
- title = dis->readShort();
size = dis->readByte() & 0xff;
+ customName = dis->readBoolean();
+ if (type == HORSE)
+ {
+ entityId = dis->readInt();
+ }
+ if(customName)
+ {
+ title = readUtf(dis,64);
+ }
}
void ContainerOpenPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte(containerId & 0xff);
dos->writeByte(type & 0xff);
- dos->writeShort(title & 0xffff);
dos->writeByte(size & 0xff);
+ dos->writeBoolean(customName);
+ if (type == HORSE)
+ {
+ dos->writeInt(entityId);
+ }
+ if(customName)
+ {
+ writeUtf(title, dos);
+ }
}
int ContainerOpenPacket::getEstimatedSize()
{
- return 5;
+ if (type == HORSE)
+ {
+ return 10;
+ }
+ return 6;
}