the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 57 lines 1.3 kB view raw
1#include "stdafx.h" 2#include <iostream> 3#include "InputOutputStream.h" 4#include "PacketListener.h" 5#include "net.minecraft.world.entity.h" 6#include "SetEntityLinkPacket.h" 7 8 9 10SetEntityLinkPacket::SetEntityLinkPacket() 11{ 12 sourceId = -1; 13 destId = -1; 14 type = -1; 15} 16 17SetEntityLinkPacket::SetEntityLinkPacket(int linkType, shared_ptr<Entity> sourceEntity, shared_ptr<Entity> destEntity) 18{ 19 type = linkType; 20 this->sourceId = sourceEntity->entityId; 21 this->destId = destEntity != NULL ? destEntity->entityId : -1; 22} 23 24int SetEntityLinkPacket::getEstimatedSize() 25{ 26 return 8; 27} 28 29void SetEntityLinkPacket::read(DataInputStream *dis) //throws IOException 30{ 31 sourceId = dis->readInt(); 32 destId = dis->readInt(); 33 type = dis->readUnsignedByte(); 34} 35 36void SetEntityLinkPacket::write(DataOutputStream *dos) //throws IOException 37{ 38 dos->writeInt(sourceId); 39 dos->writeInt(destId); 40 dos->writeByte(type); 41} 42 43void SetEntityLinkPacket::handle(PacketListener *listener) 44{ 45 listener->handleEntityLinkPacket(shared_from_this()); 46} 47 48bool SetEntityLinkPacket::canBeInvalidated() 49{ 50 return true; 51} 52 53bool SetEntityLinkPacket::isInvalidatedBy(shared_ptr<Packet> packet) 54{ 55 shared_ptr<SetEntityLinkPacket> target = dynamic_pointer_cast<SetEntityLinkPacket>(packet); 56 return target->sourceId == sourceId; 57}