the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 65 lines 1.5 kB view raw
1#include "stdafx.h" 2#include <iostream> 3#include "InputOutputStream.h" 4#include "net.minecraft.world.item.h" 5#include "PacketListener.h" 6#include "ContainerClickPacket.h" 7 8 9 10ContainerClickPacket::~ContainerClickPacket() 11{ 12} 13 14ContainerClickPacket::ContainerClickPacket() 15{ 16 containerId = 0; 17 slotNum = 0; 18 buttonNum = 0; 19 uid = 0; 20 item = nullptr; 21 clickType = 0; 22} 23 24ContainerClickPacket::ContainerClickPacket(int containerId, int slotNum, int buttonNum, int clickType, shared_ptr<ItemInstance> item, short uid) 25{ 26 this->containerId = containerId; 27 this->slotNum = slotNum; 28 this->buttonNum = buttonNum; 29 this->uid = uid; 30 this->clickType = clickType; 31 // 4J - make a copy of the relevant bits of this item, as we want our packets to have full ownership of any data they reference 32 this->item = item ? item->copy() : nullptr; 33} 34 35void ContainerClickPacket::handle(PacketListener *listener) 36{ 37 listener->handleContainerClick(shared_from_this()); 38} 39 40void ContainerClickPacket::read(DataInputStream *dis) //throws IOException 41{ 42 containerId = dis->readByte(); 43 slotNum = dis->readShort(); 44 buttonNum = dis->readByte(); 45 uid = dis->readShort(); 46 clickType = dis->readByte(); 47 48 item = readItem(dis); 49} 50 51void ContainerClickPacket::write(DataOutputStream *dos) // throws IOException 52{ 53 dos->writeByte(containerId); 54 dos->writeShort(slotNum); 55 dos->writeByte(buttonNum); 56 dos->writeShort(uid); 57 dos->writeByte(clickType); 58 59 writeItem(item, dos); 60} 61 62int ContainerClickPacket::getEstimatedSize() 63{ 64 return 4 + 4 + 2 + 1; 65}