diff --git a/Minecraft.Client/Network/ClientConnection.h b/Minecraft.Client/Network/ClientConnection.h index 58d1dfd77..97d8855ae 100644 --- a/Minecraft.Client/Network/ClientConnection.h +++ b/Minecraft.Client/Network/ClientConnection.h @@ -1,10 +1,12 @@ #pragma once #include "../../Minecraft.World/Headers/net.minecraft.network.h" + class Minecraft; class MultiPlayerLevel; class SavedDataStorage; class Socket; class MultiplayerLocalPlayer; +class SetRidingPacket; class ClientConnection : public PacketListener { private: diff --git a/Minecraft.World/Blocks/TheEndPortalTile.h b/Minecraft.World/Blocks/TheEndPortalTile.h index f5aefef57..6e3531777 100644 --- a/Minecraft.World/Blocks/TheEndPortalTile.h +++ b/Minecraft.World/Blocks/TheEndPortalTile.h @@ -1,11 +1,14 @@ #pragma once #include "TileEntities/EntityTile.h" +#include "BaseEntityTile.h" #include #if !defined(_WIN32) #include #endif +class IconRegister; + class TheEndPortal : public BaseEntityTile { public: #if defined(_WIN32) diff --git a/Minecraft.World/IO/NBT/ListTag.h b/Minecraft.World/IO/NBT/ListTag.h index c112795cd..d528b12da 100644 --- a/Minecraft.World/IO/NBT/ListTag.h +++ b/Minecraft.World/IO/NBT/ListTag.h @@ -53,7 +53,7 @@ public: return std::wstring(buf); } - void print(char* prefix, std::ostream out) { + void print(char* prefix, std::wostream& out) { Tag::print(prefix, out); out << prefix << "{" << std::endl; @@ -62,8 +62,9 @@ public: strcpy(newPrefix, prefix); strcat(newPrefix, " "); AUTO_VAR(itEnd, list.end()); - for (AUTO_VAR(it, list.begin()); it != itEnd; it++) + for (AUTO_VAR(it, list.begin()); it != itEnd; it++) { (*it)->print(newPrefix, out); + } delete[] newPrefix; out << prefix << "}" << std::endl; } diff --git a/Minecraft.World/IO/NBT/Tag.cpp b/Minecraft.World/IO/NBT/Tag.cpp index 74bc4a802..955adf6c7 100644 --- a/Minecraft.World/IO/NBT/Tag.cpp +++ b/Minecraft.World/IO/NBT/Tag.cpp @@ -40,9 +40,9 @@ bool Tag::equals(Tag* obj) { return true; } -void Tag::print(std::ostream out) { out << ""; } +void Tag::print(std::ostream& out) { out << ""; } -void Tag::print(char* prefix, std::wostream out) { +void Tag::print(char* prefix, std::wostream& out) { std::wstring name = getName(); out << prefix; diff --git a/Minecraft.World/IO/NBT/Tag.h b/Minecraft.World/IO/NBT/Tag.h index c80209d72..a4c8ea07d 100644 --- a/Minecraft.World/IO/NBT/Tag.h +++ b/Minecraft.World/IO/NBT/Tag.h @@ -29,8 +29,8 @@ public: virtual void load(DataInput* dis, int tagDepth) = 0; virtual std::wstring toString() = 0; virtual uint8_t getId() = 0; - void print(std::ostream out); - void print(char* prefix, std::wostream out); + void print(std::ostream& out); + void print(char* prefix, std::wostream& out); std::wstring getName(); Tag* setName(const std::wstring& name); static Tag* readNamedTag(DataInput* dis); diff --git a/Minecraft.World/Network/Packets/AddPlayerPacket.cpp b/Minecraft.World/Network/Packets/AddPlayerPacket.cpp index 0a83a7293..fb2a6520a 100644 --- a/Minecraft.World/Network/Packets/AddPlayerPacket.cpp +++ b/Minecraft.World/Network/Packets/AddPlayerPacket.cpp @@ -1,5 +1,4 @@ #include "../../Platform/stdafx.h" -#include #include #include "../../IO/Streams/InputOutputStream.h" #include "../../Headers/net.minecraft.world.entity.player.h" @@ -44,9 +43,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, // this in sync with other clients yRot = yRotp; xRot = xRotp; - yHeadRot = static_cast(yHeadRotp); // 4J Added - // yRot = (std::uint8_t) (player->yRot * 256 / 360); - // xRot = (std::uint8_t) (player->xRot * 256 / 360); + yHeadRot = yHeadRotp; // 4J Added + // yRot = (byte) (player->yRot * 256 / 360); + // xRot = (byte) (player->xRot * 256 / 360); // printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot // %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot); @@ -57,7 +56,7 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, this->xuid = xuid; this->OnlineXuid = OnlineXuid; - m_playerIndex = static_cast(player->getPlayerIndex()); + m_playerIndex = (BYTE)player->getPlayerIndex(); m_skinId = player->getCustomSkin(); m_capeId = player->getCustomCape(); m_uiGamePrivileges = player->getAllPlayerGamePrivileges(); @@ -73,17 +72,19 @@ void AddPlayerPacket::read(DataInputStream* dis) // throws IOException x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); - yRot = static_cast(dis->readByte()); - xRot = static_cast(dis->readByte()); + yRot = dis->readByte(); + xRot = dis->readByte(); yHeadRot = dis->readByte(); // 4J Added carriedItem = dis->readShort(); xuid = dis->readPlayerUID(); OnlineXuid = dis->readPlayerUID(); m_playerIndex = dis->readByte(); - m_skinId = static_cast(dis->readInt()); - m_capeId = static_cast(dis->readInt()); - int privileges = dis->readInt(); - m_uiGamePrivileges = static_cast(privileges); + INT skinId = dis->readInt(); + m_skinId = *(DWORD*)&skinId; + INT capeId = dis->readInt(); + m_capeId = *(DWORD*)&capeId; + INT privileges = dis->readInt(); + m_uiGamePrivileges = *(unsigned int*)&privileges; MemSect(1); unpack = SynchedEntityData::unpack(dis); MemSect(0); @@ -98,13 +99,13 @@ void AddPlayerPacket::write(DataOutputStream* dos) // throws IOException dos->writeInt(z); dos->writeByte(static_cast(yRot)); dos->writeByte(static_cast(xRot)); - dos->writeByte(static_cast(m_playerIndex)); // 4J Added + dos->writeByte(static_cast(yHeadRot)); // 4J Added dos->writeShort(carriedItem); dos->writePlayerUID(xuid); dos->writePlayerUID(OnlineXuid); - dos->writeByte(static_cast(m_playerIndex)); // 4J Added - dos->writeInt(static_cast(m_skinId)); - dos->writeInt(static_cast(m_capeId)); + dos->writeByte(static_cast(m_playerIndex)); + dos->writeInt(m_skinId); + dos->writeInt(m_capeId); dos->writeInt(m_uiGamePrivileges); entityData->packAll(dos); } @@ -115,10 +116,10 @@ void AddPlayerPacket::handle(PacketListener* listener) { int AddPlayerPacket::getEstimatedSize() { int iSize = sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + - sizeof(int) + sizeof(int) + sizeof(std::uint8_t) + - sizeof(std::uint8_t) + sizeof(short) + sizeof(PlayerUID) + - sizeof(PlayerUID) + sizeof(int) + sizeof(std::uint8_t) + - sizeof(unsigned int) + sizeof(std::uint8_t); + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) + + sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + + sizeof(uint8_t); if (entityData != NULL) { iSize += entityData->getSizeInBytes(); diff --git a/Minecraft.World/Network/Packets/LevelEventPacket.cpp b/Minecraft.World/Network/Packets/LevelEventPacket.cpp index 6ca46a95f..21f01e753 100644 --- a/Minecraft.World/Network/Packets/LevelEventPacket.cpp +++ b/Minecraft.World/Network/Packets/LevelEventPacket.cpp @@ -12,30 +12,34 @@ LevelEventPacket::LevelEventPacket() { z = 0; } -LevelEventPacket::LevelEventPacket(int type, int x, int y, int z, int data) { +LevelEventPacket::LevelEventPacket(int type, int x, int y, int z, int data, + bool globalEvent) { this->type = type; this->x = x; this->y = y; this->z = z; this->data = data; + this->globalEvent = globalEvent; } void LevelEventPacket::read(DataInputStream* dis) // throws IOException { type = dis->readInt(); x = dis->readInt(); - y = (int)(dis->readByte() & (uint8_t)0xff); + y = dis->readByte() & 0xff; z = dis->readInt(); data = dis->readInt(); + globalEvent = dis->readBoolean(); } void LevelEventPacket::write(DataOutputStream* dos) // throws IOException { dos->writeInt(type); dos->writeInt(x); - dos->writeByte((uint8_t)(y & 0xff)); + dos->writeByte(y & 0xff); dos->writeInt(z); dos->writeInt(data); + dos->writeBoolean(globalEvent); } void LevelEventPacket::handle(PacketListener* listener) { @@ -43,3 +47,5 @@ void LevelEventPacket::handle(PacketListener* listener) { } int LevelEventPacket::getEstimatedSize() { return 4 * 5 + 1; } + +bool LevelEventPacket::isGlobalEvent() { return globalEvent; }