the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include <iostream>
3#include "InputOutputStream.h"
4#include "PacketListener.h"
5#include "RespawnPacket.h"
6#include "LevelType.h"
7
8RespawnPacket::RespawnPacket()
9{
10 this->dimension = 0;
11 this->difficulty = 1;
12 this->mapSeed = 0;
13 this->mapHeight = 0;
14 this->playerGameType = NULL;
15 this->m_newSeaLevel = false;
16 m_pLevelType = NULL;
17 m_newEntityId = 0;
18 m_xzSize = LEVEL_MAX_WIDTH;
19 m_hellScale = HELL_LEVEL_MAX_SCALE;
20}
21
22RespawnPacket::RespawnPacket(char dimension, __int64 mapSeed, int mapHeight, GameType *playerGameType, char difficulty, LevelType *pLevelType, bool newSeaLevel, int newEntityId, int xzSize, int hellScale)
23{
24 this->dimension = dimension;
25 this->mapSeed = mapSeed;
26 this->mapHeight = mapHeight;
27 this->playerGameType = playerGameType;
28 this->difficulty = difficulty;
29 this->m_newSeaLevel = newSeaLevel;
30 this->m_pLevelType=pLevelType;
31 this->m_newEntityId = newEntityId;
32 m_xzSize = xzSize;
33 m_hellScale = hellScale;
34 app.DebugPrintf("RespawnPacket - Difficulty = %d\n",difficulty);
35
36}
37
38void RespawnPacket::handle(PacketListener *listener)
39{
40 listener->handleRespawn(shared_from_this());
41}
42
43void RespawnPacket::read(DataInputStream *dis) //throws IOException
44{
45 dimension = dis->readByte();
46 playerGameType = GameType::byId(dis->readByte());
47 mapHeight = dis->readShort();
48 wstring typeName = readUtf(dis, 16);
49 m_pLevelType = LevelType::getLevelType(typeName);
50 if (m_pLevelType == NULL)
51 {
52 m_pLevelType = LevelType::lvl_normal;
53 }
54 mapSeed = dis->readLong();
55 difficulty = dis->readByte();
56 m_newSeaLevel = dis->readBoolean();
57 m_newEntityId = dis->readShort();
58#ifdef _LARGE_WORLDS
59 m_xzSize = dis->readShort();
60 m_hellScale = dis->read();
61#endif
62 app.DebugPrintf("RespawnPacket::read - Difficulty = %d\n",difficulty);
63
64}
65
66void RespawnPacket::write(DataOutputStream *dos) //throws IOException
67{
68 dos->writeByte(dimension);
69 dos->writeByte(playerGameType->getId());
70 dos->writeShort(mapHeight);
71 if (m_pLevelType == NULL)
72 {
73 writeUtf(L"", dos);
74 }
75 else
76 {
77 writeUtf(m_pLevelType->getGeneratorName(), dos);
78 }
79 dos->writeLong(mapSeed);
80 dos->writeByte(difficulty);
81 dos->writeBoolean(m_newSeaLevel);
82 dos->writeShort(m_newEntityId);
83#ifdef _LARGE_WORLDS
84 dos->writeShort(m_xzSize);
85 dos->write(m_hellScale);
86#endif
87}
88
89int RespawnPacket::getEstimatedSize()
90{
91 int length=0;
92 if (m_pLevelType != NULL)
93 {
94 length = (int)m_pLevelType->getGeneratorName().length();
95 }
96 return 13+length;
97}