the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 78 lines 1.7 kB view raw
1#include "stdafx.h" 2#include <iostream> 3#include "InputOutputStream.h" 4#include "PacketListener.h" 5#include "ContainerOpenPacket.h" 6 7void ContainerOpenPacket::_init(int containerId, int type, const wstring &title, int size, bool customName, int entityId) 8{ 9 this->containerId = containerId; 10 this->type = type; 11 this->title = title; 12 this->size = size; 13 this->customName = customName; 14 this->entityId = entityId; 15} 16 17ContainerOpenPacket::ContainerOpenPacket() 18{ 19 _init(0, 0, L"", 0, false, 0); 20 21} 22 23ContainerOpenPacket::ContainerOpenPacket(int containerId, int type, const wstring &title, int size, bool customName) 24{ 25 _init(containerId, type, title, size, customName, 0); 26} 27 28ContainerOpenPacket::ContainerOpenPacket(int containerId, int type, const wstring &title, int size, bool customName, int entityId) 29{ 30 _init(containerId, type, title, size, customName, entityId); 31} 32 33void ContainerOpenPacket::handle(PacketListener *listener) 34{ 35 listener->handleContainerOpen(shared_from_this()); 36} 37 38 39void ContainerOpenPacket::read(DataInputStream *dis) //throws IOException 40{ 41 containerId = dis->readByte() & 0xff; 42 type = dis->readByte() & 0xff; 43 size = dis->readByte() & 0xff; 44 customName = dis->readBoolean(); 45 if (type == HORSE) 46 { 47 entityId = dis->readInt(); 48 } 49 if(customName) 50 { 51 title = readUtf(dis,64); 52 } 53} 54 55void ContainerOpenPacket::write(DataOutputStream *dos) //throws IOException 56{ 57 dos->writeByte(containerId & 0xff); 58 dos->writeByte(type & 0xff); 59 dos->writeByte(size & 0xff); 60 dos->writeBoolean(customName); 61 if (type == HORSE) 62 { 63 dos->writeInt(entityId); 64 } 65 if(customName) 66 { 67 writeUtf(title, dos); 68 } 69} 70 71int ContainerOpenPacket::getEstimatedSize() 72{ 73 if (type == HORSE) 74 { 75 return 10; 76 } 77 return 6; 78}