aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/TextureAndGeometryChangePacket.cpp
blob: 04c88bed5fdc4f9889972bdaa0c7c8f45f7a3165 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "net.minecraft.world.entity.h"
#include "PacketListener.h"
#include "TextureAndGeometryChangePacket.h"




TextureAndGeometryChangePacket::TextureAndGeometryChangePacket()
{
	id = -1;
	path = L"";
	dwSkinID = 0;
}

TextureAndGeometryChangePacket::TextureAndGeometryChangePacket(shared_ptr<Entity> e, const wstring &path)
{
	id = e->entityId;
	this->path = path;
	wstring skinValue = path.substr(7,path.size());
	skinValue = skinValue.substr(0,skinValue.find_first_of(L'.'));
	std::wstringstream ss;
	ss << std::dec << skinValue.c_str();
	ss >> dwSkinID;
	dwSkinID = MAKE_SKIN_BITMASK(true, dwSkinID);

}

void TextureAndGeometryChangePacket::read(DataInputStream *dis) //throws IOException 
{
	id = dis->readInt();
	dwSkinID = dis->readInt();
	path = dis->readUTF();
}

void TextureAndGeometryChangePacket::write(DataOutputStream *dos) //throws IOException 
{
	dos->writeInt(id);
	dos->writeInt(dwSkinID);
	dos->writeUTF(path);
}

void TextureAndGeometryChangePacket::handle(PacketListener *listener) 
{
	listener->handleTextureAndGeometryChange(shared_from_this());
}

int TextureAndGeometryChangePacket::getEstimatedSize() 
{
	return 8 + (int)path.size();
}