mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-25 06:04:59 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -5,56 +5,45 @@
|
||||
#include "PacketListener.h"
|
||||
#include "ContainerSetContentPacket.h"
|
||||
|
||||
ContainerSetContentPacket::~ContainerSetContentPacket() { delete[] items.data; }
|
||||
|
||||
ContainerSetContentPacket::ContainerSetContentPacket() { containerId = 0; }
|
||||
|
||||
ContainerSetContentPacket::~ContainerSetContentPacket()
|
||||
{
|
||||
delete[] items.data;
|
||||
ContainerSetContentPacket::ContainerSetContentPacket(
|
||||
int containerId, std::vector<std::shared_ptr<ItemInstance> >* newItems) {
|
||||
this->containerId = containerId;
|
||||
items = ItemInstanceArray((int)newItems->size());
|
||||
for (unsigned int i = 0; i < items.length; i++) {
|
||||
std::shared_ptr<ItemInstance> item = newItems->at(i);
|
||||
items[i] = item == NULL ? nullptr : item->copy();
|
||||
}
|
||||
}
|
||||
|
||||
ContainerSetContentPacket::ContainerSetContentPacket()
|
||||
void ContainerSetContentPacket::read(
|
||||
DataInputStream* dis) // throws IOException
|
||||
{
|
||||
containerId = 0;
|
||||
containerId = (int)dis->readByte();
|
||||
int count = dis->readShort();
|
||||
items = ItemInstanceArray(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
items[i] = readItem(dis);
|
||||
}
|
||||
}
|
||||
|
||||
ContainerSetContentPacket::ContainerSetContentPacket(int containerId, std::vector<std::shared_ptr<ItemInstance> > *newItems)
|
||||
void ContainerSetContentPacket::write(
|
||||
DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
this->containerId = containerId;
|
||||
items = ItemInstanceArray((int)newItems->size());
|
||||
for (unsigned int i = 0; i < items.length; i++)
|
||||
{
|
||||
std::shared_ptr<ItemInstance> item = newItems->at(i);
|
||||
items[i] = item == NULL ? nullptr : item->copy();
|
||||
}
|
||||
dos->writeByte((uint8_t)containerId);
|
||||
dos->writeShort(items.length);
|
||||
for (unsigned int i = 0; i < items.length; i++) {
|
||||
writeItem(items[i], dos);
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
containerId = (int)dis->readByte();
|
||||
int count = dis->readShort();
|
||||
items = ItemInstanceArray(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
items[i] = readItem(dis);
|
||||
}
|
||||
void ContainerSetContentPacket::handle(PacketListener* listener) {
|
||||
listener->handleContainerContent(shared_from_this());
|
||||
}
|
||||
|
||||
void ContainerSetContentPacket::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
dos->writeByte((uint8_t)containerId);
|
||||
dos->writeShort(items.length);
|
||||
for (unsigned int i = 0; i < items.length; i++)
|
||||
{
|
||||
writeItem(items[i], dos);
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerSetContentPacket::handle(PacketListener *listener)
|
||||
{
|
||||
listener->handleContainerContent(shared_from_this());
|
||||
}
|
||||
|
||||
int ContainerSetContentPacket::getEstimatedSize()
|
||||
{
|
||||
return 3 + items.length * 5;
|
||||
int ContainerSetContentPacket::getEstimatedSize() {
|
||||
return 3 + items.length * 5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user