void cProtocol161::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_ATTACH_ENTITY); WriteInt(a_Entity.GetUniqueID()); WriteInt((a_Vehicle == NULL) ? -1 : a_Vehicle->GetUniqueID()); WriteBool(false); // TODO: "Should use leash?" -> no Flush(); }
void cProtocol132::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_ENTITY_EQUIPMENT); WriteInt (a_Entity.GetUniqueID()); WriteShort(a_SlotNum); WriteItem (a_Item); Flush(); }
void cProtocol125::SendEntityMetadata(const cEntity & a_Entity) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_METADATA); WriteInt (a_Entity.GetUniqueID()); AString MetaData = GetEntityMetaData(a_Entity); SendData(MetaData.data(), MetaData.size()); Flush(); }
void cProtocol125::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_ENTITY_EFFECT); WriteInt (a_Entity.GetUniqueID()); WriteByte ((Byte)a_EffectID); WriteByte ((Byte)a_Amplifier); WriteShort(a_Duration); Flush(); }
void cProtocol125::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ ) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_USE_BED); WriteInt (a_Entity.GetUniqueID()); WriteByte(0); // Unknown byte only 0 has been observed WriteInt (a_BlockX); WriteByte((Byte)a_BlockY); WriteInt (a_BlockZ); Flush(); }
void cProtocol125::SendTeleportEntity(const cEntity & a_Entity) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_ENT_TELEPORT); WriteInt (a_Entity.GetUniqueID()); WriteInt ((int)(floor(a_Entity.GetPosX() * 32))); WriteInt ((int)(floor(a_Entity.GetPosY() * 32))); WriteInt ((int)(floor(a_Entity.GetPosZ() * 32))); WriteChar ((char)((a_Entity.GetYaw() / 360.f) * 256)); WriteChar ((char)((a_Entity.GetPitch() / 360.f) * 256)); Flush(); }
void cProtocol125::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_SPAWN_OBJECT); WriteInt (a_Vehicle.GetUniqueID()); WriteByte (a_VehicleType); WriteInt ((int)(a_Vehicle.GetPosX() * 32)); WriteInt ((int)(a_Vehicle.GetPosY() * 32)); WriteInt ((int)(a_Vehicle.GetPosZ() * 32)); WriteByte ((Byte)((a_Vehicle.GetPitch() / 360.f) * 256)); WriteByte ((Byte)((a_Vehicle.GetRotation() / 360.f) * 256)); WriteInt (1); WriteShort((short)(a_Vehicle.GetSpeedX() * 400)); WriteShort((short)(a_Vehicle.GetSpeedY() * 400)); WriteShort((short)(a_Vehicle.GetSpeedZ() * 400)); Flush(); }
void cProtocol125::SendEntityMetadata(const cEntity & a_Entity) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_METADATA); WriteInt (a_Entity.GetUniqueID()); WriteCommonMetadata(a_Entity); if (a_Entity.IsMob()) { WriteMobMetadata(((const cMonster &)a_Entity)); } else { WriteEntityMetadata(a_Entity); } WriteByte(0x7f); Flush(); }
void cProtocol146::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_SPAWN_OBJECT); WriteInt (a_Entity.GetUniqueID()); WriteByte(a_ObjectType); WriteInt ((int)(a_Entity.GetPosX() * 32)); WriteInt ((int)(a_Entity.GetPosY() * 32)); WriteInt ((int)(a_Entity.GetPosZ() * 32)); WriteByte(a_Pitch); WriteByte(a_Yaw); WriteInt (a_ObjectData); if (a_ObjectData != 0) { WriteShort((short)(a_Entity.GetSpeedX() * 400)); WriteShort((short)(a_Entity.GetSpeedY() * 400)); WriteShort((short)(a_Entity.GetSpeedZ() * 400)); } Flush(); }
virtual bool Item(cEntity * a_Entity) override { if (a_Entity->GetUniqueID() == m_Pusher->GetUniqueID()) { return false; } // we only push other mobs, boats and minecarts if ((a_Entity->GetEntityType() != etMonster) && (a_Entity->GetEntityType() != etMinecart) && (a_Entity->GetEntityType() != etBoat)) { return false; } Vector3d v3Delta = a_Entity->GetPosition() - m_Pusher->GetPosition(); v3Delta.y = 0.0; // we only push sideways v3Delta *= 1.0 / (v3Delta.Length() + 0.01); // we push harder if we're close // QUESTION: is there an additional multiplier for this? current shoving seems a bit weak a_Entity->AddSpeed(v3Delta); return false; }