Files
MinecraftConsoles/Minecraft.World/SetEquippedItemPacket.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

69 lines
2.0 KiB
C++

#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "net.minecraft.world.item.h"
#include "PacketListener.h"
#include "SetEquippedItemPacket.h"
SetEquippedItemPacket::SetEquippedItemPacket()
{
entity = 0;
slot = 0;
item = nullptr;
}
SetEquippedItemPacket::SetEquippedItemPacket(int entity, int slot, shared_ptr<ItemInstance> item)
{
this->entity = entity;
this->slot = slot;
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
this->item = item == nullptr ? nullptr : item->copy();
}
void SetEquippedItemPacket::read(DataInputStream *dis) //throws IOException
{
entity = dis->readInt();
slot = dis->readShort();
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
item = readItem(dis);
}
void SetEquippedItemPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(entity);
dos->writeShort(slot);
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
writeItem(item, dos);
}
void SetEquippedItemPacket::handle(PacketListener *listener)
{
listener->handleSetEquippedItem(shared_from_this());
}
int SetEquippedItemPacket::getEstimatedSize()
{
return 4 + 2 * 2;
}
// 4J Stu - Brought forward from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
shared_ptr<ItemInstance> SetEquippedItemPacket::getItem()
{
return item;
}
bool SetEquippedItemPacket::canBeInvalidated()
{
return true;
}
bool SetEquippedItemPacket::isInvalidatedBy(shared_ptr<Packet> packet)
{
shared_ptr<SetEquippedItemPacket> target = dynamic_pointer_cast<SetEquippedItemPacket>(packet);
return target->entity == entity && target->slot == slot;
}