TU19: fix build fallout across Client, World, NBT and Network

This commit is contained in:
MatthewBeshay 2026-03-22 12:45:21 +11:00
parent d9aa793075
commit 91b13bccee
7 changed files with 41 additions and 28 deletions

View file

@ -1,10 +1,12 @@
#pragma once #pragma once
#include "../../Minecraft.World/Headers/net.minecraft.network.h" #include "../../Minecraft.World/Headers/net.minecraft.network.h"
class Minecraft; class Minecraft;
class MultiPlayerLevel; class MultiPlayerLevel;
class SavedDataStorage; class SavedDataStorage;
class Socket; class Socket;
class MultiplayerLocalPlayer; class MultiplayerLocalPlayer;
class SetRidingPacket;
class ClientConnection : public PacketListener { class ClientConnection : public PacketListener {
private: private:

View file

@ -1,11 +1,14 @@
#pragma once #pragma once
#include "TileEntities/EntityTile.h" #include "TileEntities/EntityTile.h"
#include "BaseEntityTile.h"
#include <cstdint> #include <cstdint>
#if !defined(_WIN32) #if !defined(_WIN32)
#include <pthread.h> #include <pthread.h>
#endif #endif
class IconRegister;
class TheEndPortal : public BaseEntityTile { class TheEndPortal : public BaseEntityTile {
public: public:
#if defined(_WIN32) #if defined(_WIN32)

View file

@ -53,7 +53,7 @@ public:
return std::wstring(buf); return std::wstring(buf);
} }
void print(char* prefix, std::ostream out) { void print(char* prefix, std::wostream& out) {
Tag::print(prefix, out); Tag::print(prefix, out);
out << prefix << "{" << std::endl; out << prefix << "{" << std::endl;
@ -62,8 +62,9 @@ public:
strcpy(newPrefix, prefix); strcpy(newPrefix, prefix);
strcat(newPrefix, " "); strcat(newPrefix, " ");
AUTO_VAR(itEnd, list.end()); 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); (*it)->print(newPrefix, out);
}
delete[] newPrefix; delete[] newPrefix;
out << prefix << "}" << std::endl; out << prefix << "}" << std::endl;
} }

View file

@ -40,9 +40,9 @@ bool Tag::equals(Tag* obj) {
return true; 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(); std::wstring name = getName();
out << prefix; out << prefix;

View file

@ -29,8 +29,8 @@ public:
virtual void load(DataInput* dis, int tagDepth) = 0; virtual void load(DataInput* dis, int tagDepth) = 0;
virtual std::wstring toString() = 0; virtual std::wstring toString() = 0;
virtual uint8_t getId() = 0; virtual uint8_t getId() = 0;
void print(std::ostream out); void print(std::ostream& out);
void print(char* prefix, std::wostream out); void print(char* prefix, std::wostream& out);
std::wstring getName(); std::wstring getName();
Tag* setName(const std::wstring& name); Tag* setName(const std::wstring& name);
static Tag* readNamedTag(DataInput* dis); static Tag* readNamedTag(DataInput* dis);

View file

@ -1,5 +1,4 @@
#include "../../Platform/stdafx.h" #include "../../Platform/stdafx.h"
#include <cstring>
#include <iostream> #include <iostream>
#include "../../IO/Streams/InputOutputStream.h" #include "../../IO/Streams/InputOutputStream.h"
#include "../../Headers/net.minecraft.world.entity.player.h" #include "../../Headers/net.minecraft.world.entity.player.h"
@ -44,9 +43,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr<Player> player, PlayerUID xuid,
// this in sync with other clients // this in sync with other clients
yRot = yRotp; yRot = yRotp;
xRot = xRotp; xRot = xRotp;
yHeadRot = static_cast<std::uint8_t>(yHeadRotp); // 4J Added yHeadRot = yHeadRotp; // 4J Added
// yRot = (std::uint8_t) (player->yRot * 256 / 360); // yRot = (byte) (player->yRot * 256 / 360);
// xRot = (std::uint8_t) (player->xRot * 256 / 360); // xRot = (byte) (player->xRot * 256 / 360);
// printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot // 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); // %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot);
@ -57,7 +56,7 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr<Player> player, PlayerUID xuid,
this->xuid = xuid; this->xuid = xuid;
this->OnlineXuid = OnlineXuid; this->OnlineXuid = OnlineXuid;
m_playerIndex = static_cast<std::uint8_t>(player->getPlayerIndex()); m_playerIndex = (BYTE)player->getPlayerIndex();
m_skinId = player->getCustomSkin(); m_skinId = player->getCustomSkin();
m_capeId = player->getCustomCape(); m_capeId = player->getCustomCape();
m_uiGamePrivileges = player->getAllPlayerGamePrivileges(); m_uiGamePrivileges = player->getAllPlayerGamePrivileges();
@ -73,17 +72,19 @@ void AddPlayerPacket::read(DataInputStream* dis) // throws IOException
x = dis->readInt(); x = dis->readInt();
y = dis->readInt(); y = dis->readInt();
z = dis->readInt(); z = dis->readInt();
yRot = static_cast<char>(dis->readByte()); yRot = dis->readByte();
xRot = static_cast<char>(dis->readByte()); xRot = dis->readByte();
yHeadRot = dis->readByte(); // 4J Added yHeadRot = dis->readByte(); // 4J Added
carriedItem = dis->readShort(); carriedItem = dis->readShort();
xuid = dis->readPlayerUID(); xuid = dis->readPlayerUID();
OnlineXuid = dis->readPlayerUID(); OnlineXuid = dis->readPlayerUID();
m_playerIndex = dis->readByte(); m_playerIndex = dis->readByte();
m_skinId = static_cast<std::uint32_t>(dis->readInt()); INT skinId = dis->readInt();
m_capeId = static_cast<std::uint32_t>(dis->readInt()); m_skinId = *(DWORD*)&skinId;
int privileges = dis->readInt(); INT capeId = dis->readInt();
m_uiGamePrivileges = static_cast<unsigned int>(privileges); m_capeId = *(DWORD*)&capeId;
INT privileges = dis->readInt();
m_uiGamePrivileges = *(unsigned int*)&privileges;
MemSect(1); MemSect(1);
unpack = SynchedEntityData::unpack(dis); unpack = SynchedEntityData::unpack(dis);
MemSect(0); MemSect(0);
@ -98,13 +99,13 @@ void AddPlayerPacket::write(DataOutputStream* dos) // throws IOException
dos->writeInt(z); dos->writeInt(z);
dos->writeByte(static_cast<std::uint8_t>(yRot)); dos->writeByte(static_cast<std::uint8_t>(yRot));
dos->writeByte(static_cast<std::uint8_t>(xRot)); dos->writeByte(static_cast<std::uint8_t>(xRot));
dos->writeByte(static_cast<std::uint8_t>(m_playerIndex)); // 4J Added dos->writeByte(static_cast<std::uint8_t>(yHeadRot)); // 4J Added
dos->writeShort(carriedItem); dos->writeShort(carriedItem);
dos->writePlayerUID(xuid); dos->writePlayerUID(xuid);
dos->writePlayerUID(OnlineXuid); dos->writePlayerUID(OnlineXuid);
dos->writeByte(static_cast<std::uint8_t>(m_playerIndex)); // 4J Added dos->writeByte(static_cast<std::uint8_t>(m_playerIndex));
dos->writeInt(static_cast<int>(m_skinId)); dos->writeInt(m_skinId);
dos->writeInt(static_cast<int>(m_capeId)); dos->writeInt(m_capeId);
dos->writeInt(m_uiGamePrivileges); dos->writeInt(m_uiGamePrivileges);
entityData->packAll(dos); entityData->packAll(dos);
} }
@ -115,10 +116,10 @@ void AddPlayerPacket::handle(PacketListener* listener) {
int AddPlayerPacket::getEstimatedSize() { int AddPlayerPacket::getEstimatedSize() {
int iSize = sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + int iSize = sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) +
sizeof(int) + sizeof(int) + sizeof(std::uint8_t) + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) +
sizeof(std::uint8_t) + sizeof(short) + sizeof(PlayerUID) + sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) +
sizeof(PlayerUID) + sizeof(int) + sizeof(std::uint8_t) + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) +
sizeof(unsigned int) + sizeof(std::uint8_t); sizeof(uint8_t);
if (entityData != NULL) { if (entityData != NULL) {
iSize += entityData->getSizeInBytes(); iSize += entityData->getSizeInBytes();

View file

@ -12,30 +12,34 @@ LevelEventPacket::LevelEventPacket() {
z = 0; 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->type = type;
this->x = x; this->x = x;
this->y = y; this->y = y;
this->z = z; this->z = z;
this->data = data; this->data = data;
this->globalEvent = globalEvent;
} }
void LevelEventPacket::read(DataInputStream* dis) // throws IOException void LevelEventPacket::read(DataInputStream* dis) // throws IOException
{ {
type = dis->readInt(); type = dis->readInt();
x = dis->readInt(); x = dis->readInt();
y = (int)(dis->readByte() & (uint8_t)0xff); y = dis->readByte() & 0xff;
z = dis->readInt(); z = dis->readInt();
data = dis->readInt(); data = dis->readInt();
globalEvent = dis->readBoolean();
} }
void LevelEventPacket::write(DataOutputStream* dos) // throws IOException void LevelEventPacket::write(DataOutputStream* dos) // throws IOException
{ {
dos->writeInt(type); dos->writeInt(type);
dos->writeInt(x); dos->writeInt(x);
dos->writeByte((uint8_t)(y & 0xff)); dos->writeByte(y & 0xff);
dos->writeInt(z); dos->writeInt(z);
dos->writeInt(data); dos->writeInt(data);
dos->writeBoolean(globalEvent);
} }
void LevelEventPacket::handle(PacketListener* listener) { void LevelEventPacket::handle(PacketListener* listener) {
@ -43,3 +47,5 @@ void LevelEventPacket::handle(PacketListener* listener) {
} }
int LevelEventPacket::getEstimatedSize() { return 4 * 5 + 1; } int LevelEventPacket::getEstimatedSize() { return 4 * 5 + 1; }
bool LevelEventPacket::isGlobalEvent() { return globalEvent; }