4th batch

This commit is contained in:
Leah Anderson 2026-03-02 12:00:59 -07:00
parent 9cfc2e5b16
commit 79c1737c34
33 changed files with 94 additions and 93 deletions

View file

@ -16,8 +16,8 @@ void AddEntityPacket::_init(shared_ptr<Entity> e, int type, int data, int xp, in
x = xp;//(int) floor(e->x * 32);
y = yp;//(int) floor(e->y * 32);
z = zp;//(int) floor(e->z * 32);
yRot = static_cast<std::byte>(yRotp);
xRot = static_cast<std::byte>(xRotp);
yRot = static_cast<byte>(yRotp);
xRot = static_cast<byte>(xRotp);
this->type = type;
this->data = data;
if (data > -1) // 4J - changed "no data" value to be -1, we can have a valid entity id of 0
@ -55,7 +55,7 @@ AddEntityPacket::AddEntityPacket(shared_ptr<Entity> e, int type, int data, int y
void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J JEV add throws statement
{
id = dis->readShort();
type = std::to_integer<int>(dis->readByte());
type = dis->readByte();
#ifdef _LARGE_WORLDS
x = dis->readInt();
y = dis->readInt();
@ -79,7 +79,7 @@ void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J
void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J JEV add throws statement
{
dos->writeShort(id);
dos->writeByte(static_cast<std::byte>(type));
dos->writeByte(static_cast<byte>(type));
#ifdef _LARGE_WORLDS
dos->writeInt(x);
dos->writeInt(y);

View file

@ -39,7 +39,7 @@ AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr<Entity> e)
void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException
{
id = dis->readInt();
type = std::to_integer<int>(dis->readByte());
type = static_cast<int>(dis->readByte());
x = dis->readInt();
y = dis->readInt();
z = dis->readInt();
@ -48,7 +48,7 @@ void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException
void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeInt(id);
dos->writeByte(static_cast<std::byte>(type));
dos->writeByte(static_cast<byte>(type));
dos->writeInt(x);
dos->writeInt(y);
dos->writeInt(z);

View file

@ -14,8 +14,8 @@ AddMobPacket::AddMobPacket()
x = 0;
y = 0;
z = 0;
yRot = static_cast<std::byte>(0);
xRot = static_cast<std::byte>(0);
yRot = static_cast<byte>(0);
xRot = static_cast<byte>(0);
entityData = nullptr;
unpack = NULL;
}
@ -36,9 +36,9 @@ AddMobPacket::AddMobPacket(shared_ptr<Mob> mob, int yRotp, int xRotp, int xp, in
y = yp;//Mth::floor(mob->y * 32);
z = zp;//Mth::floor(mob->z * 32);
// 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients
yRot = static_cast<std::byte>(yRotp);
xRot = static_cast<std::byte>(xRotp);
yHeadRot = static_cast<std::byte>(yHeadRotp);
yRot = static_cast<byte>(yRotp);
xRot = static_cast<byte>(xRotp);
yHeadRot = static_cast<byte>(yHeadRotp);
// yRot = (byte) (mob->yRot * 256 / 360);
// xRot = (byte) (mob->xRot * 256 / 360);
// yHeadRot = (byte) (mob->yHeadRot * 256 / 360);
@ -67,7 +67,7 @@ AddMobPacket::AddMobPacket(shared_ptr<Mob> mob, int yRotp, int xRotp, int xp, in
void AddMobPacket::read(DataInputStream *dis) //throws IOException
{
id = dis->readShort();
type = std::to_integer<int>(dis->readByte()) & 0xff;
type = static_cast<int>(dis->readByte()) & 0xff;
#ifdef _LARGE_WORLDS
x = dis->readInt();
y = dis->readInt();
@ -91,7 +91,7 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException
void AddMobPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeShort(id);
dos->writeByte(static_cast<std::byte>(type & 0xff));
dos->writeByte(static_cast<byte>(type & 0xff));
#ifdef _LARGE_WORLDS
dos->writeInt(x);
dos->writeInt(y);

View file

@ -44,7 +44,7 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr<Player> player, PlayerUID xuid, Play
// 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients
yRot = yRotp;
xRot = xRotp;
yHeadRot = static_cast<std::byte>(yHeadRotp); // 4J Added
yHeadRot = static_cast<byte>(yHeadRotp); // 4J Added
// yRot = (byte) (player->yRot * 256 / 360);
// xRot = (byte) (player->xRot * 256 / 360);
@ -96,13 +96,13 @@ void AddPlayerPacket::write(DataOutputStream *dos) //throws IOException
dos->writeInt(x);
dos->writeInt(y);
dos->writeInt(z);
dos->writeByte(static_cast<std::byte>(yRot));
dos->writeByte(static_cast<std::byte>(xRot));
dos->writeByte(static_cast<std::byte>(m_playerIndex)); // 4J Added
dos->writeByte(static_cast<byte>(yRot));
dos->writeByte(static_cast<byte>(xRot));
dos->writeByte(static_cast<byte>(m_playerIndex)); // 4J Added
dos->writeShort(carriedItem);
dos->writePlayerUID(xuid);
dos->writePlayerUID(OnlineXuid);
dos->writeByte(static_cast<std::byte>(m_playerIndex)); // 4J Added
dos->writeByte(static_cast<byte>(m_playerIndex)); // 4J Added
dos->writeInt(m_skinId);
dos->writeInt(m_capeId);
dos->writeInt(m_uiGamePrivileges);

View file

@ -28,7 +28,7 @@ void AnimatePacket::read(DataInputStream *dis) //throws IOException
void AnimatePacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(id);
dos->writeByte(static_cast<std::byte>(action));
dos->writeByte(static_cast<byte>(action));
}
void AnimatePacket::handle(PacketListener *listener)

View file

@ -21,7 +21,7 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket()
shouldDelay = true;
xc = 0;
zc = 0;
count = (std::byte)0;
count = (byte)0;
}
ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positions, byte count, Level *level)
@ -35,7 +35,7 @@ ChunkTilesUpdatePacket::ChunkTilesUpdatePacket(int xc, int zc, shortArray positi
this->blocks = byteArray((unsigned int)count);
this->data = byteArray((unsigned int)count);
LevelChunk *levelChunk = level->getChunk(xc, zc);
for (int i = 0; (std::byte)i < count; i++)
for (int i = 0; (byte)i < count; i++)
{
int x = (positions[i] >> 12) & 15;
int z = (positions[i] >> 8) & 15;
@ -66,14 +66,14 @@ void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException
int countAndFlags = (int)dis->readByte();
bool dataAllZero = (( countAndFlags & 0x80 ) == 0x80 );
levelIdx = ( countAndFlags >> 5 ) & 3;
count = (std::byte)countAndFlags & (std::byte)0x1f;
count = (byte)countAndFlags & (byte)0x1f;
positions = shortArray((short int)count);
blocks = byteArray((unsigned int)count);
data = byteArray((unsigned int)count);
int currentBlockType = -1;
for( int i = 0; (std::byte)i < count; i++ )
for( int i = 0; (byte)i < count; i++ )
{
int xzAndFlag = dis->readShort();
int y = (int)dis->readByte();
@ -82,14 +82,14 @@ void ChunkTilesUpdatePacket::read(DataInputStream *dis) //throws IOException
{
currentBlockType = dis->read();
}
blocks[i] = (std::byte)currentBlockType;
blocks[i] = (byte)currentBlockType;
if( !dataAllZero)
{
data[i] = (std::byte)dis->read();
data[i] = (byte)dis->read();
}
else
{
data[i] = (std::byte)0;
data[i] = (byte)0;
}
}
}

View file

@ -19,7 +19,7 @@ void ClientCommandPacket::read(DataInputStream *dis)
void ClientCommandPacket::write(DataOutputStream *dos)
{
dos->writeByte((std::byte)action & (std::byte)0xff);
dos->writeByte((byte)action & (byte)0xff);
}
void ClientCommandPacket::handle(PacketListener *listener)

View file

@ -117,7 +117,7 @@ public:
void putBoolean(wchar_t * string, bool val)
{
putByte(string, val?static_cast<std::byte>(1):static_cast<std::byte>(0));
putByte(string, val?static_cast<byte>(1):static_cast<byte>(0));
}
Tag *get(wchar_t *name)
@ -200,7 +200,7 @@ public:
bool getBoolean(wchar_t *string)
{
return getByte(string) != static_cast<std::byte>(0);
return getByte(string) != static_cast<byte>(0);
}
void remove(const wstring &name)

View file

@ -25,7 +25,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile
//the next byte of data, or -1 if the end of the file is reached.
int ConsoleSaveFileInputStream::read()
{
byte byteRead = static_cast<std::byte>(0);
byte byteRead = static_cast<byte>(0);
DWORD numberOfBytesRead;
BOOL result = m_saveFile->readFile(

View file

@ -34,9 +34,9 @@ void ContainerAckPacket::read(DataInputStream *dis) //throws IOException
void ContainerAckPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)containerId);
dos->writeByte((byte)containerId);
dos->writeShort(uid);
dos->writeByte((std::byte)(accepted ? 1 : 0));
dos->writeByte((byte)(accepted ? 1 : 0));
}
int ContainerAckPacket::getEstimatedSize()

View file

@ -30,8 +30,8 @@ void ContainerButtonClickPacket::read(DataInputStream *dis)
void ContainerButtonClickPacket::write(DataOutputStream *dos)
{
dos->writeByte((std::byte)containerId);
dos->writeByte((std::byte)buttonId);
dos->writeByte((byte)containerId);
dos->writeByte((byte)buttonId);
}
int ContainerButtonClickPacket::getEstimatedSize()

View file

@ -50,9 +50,9 @@ void ContainerClickPacket::read(DataInputStream *dis) //throws IOException
void ContainerClickPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeByte((std::byte)containerId);
dos->writeByte((byte)containerId);
dos->writeShort(slotNum);
dos->writeByte((std::byte)buttonNum);
dos->writeByte((byte)buttonNum);
dos->writeShort(uid);
dos->writeBoolean(quickKey);

View file

@ -28,7 +28,7 @@ void ContainerClosePacket::read(DataInputStream *dis) //throws IOException
void ContainerClosePacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)containerId);
dos->writeByte((byte)containerId);
}
int ContainerClosePacket::getEstimatedSize()

View file

@ -28,18 +28,18 @@ void ContainerOpenPacket::handle(PacketListener *listener)
void ContainerOpenPacket::read(DataInputStream *dis) //throws IOException
{
containerId = (int)(dis->readByte() & (std::byte)0xff);
type = (int)(dis->readByte() & (std::byte)0xff);
containerId = (int)(dis->readByte() & (byte)0xff);
type = (int)(dis->readByte() & (byte)0xff);
title = dis->readShort();
size = (int)(dis->readByte() & (std::byte)0xff);
size = (int)(dis->readByte() & (byte)0xff);
}
void ContainerOpenPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)containerId & (std::byte)0xff);
dos->writeByte((std::byte)type & (std::byte)0xff);
dos->writeByte((byte)containerId & (byte)0xff);
dos->writeByte((byte)type & (byte)0xff);
dos->writeShort(title & 0xffff);
dos->writeByte((std::byte)size & (std::byte)0xff);
dos->writeByte((byte)size & (byte)0xff);
}
int ContainerOpenPacket::getEstimatedSize()

View file

@ -41,7 +41,7 @@ void ContainerSetContentPacket::read(DataInputStream *dis) //throws IOException
void ContainerSetContentPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)containerId);
dos->writeByte((byte)containerId);
dos->writeShort(items.length);
for (unsigned int i = 0; i < items.length; i++)
{

View file

@ -34,7 +34,7 @@ void ContainerSetDataPacket::read(DataInputStream *dis) //throws IOException
void ContainerSetDataPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeByte((std::byte)containerId);
dos->writeByte((byte)containerId);
dos->writeShort(id);
dos->writeShort(value);
}

View file

@ -34,7 +34,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
{
// 4J Stu - TU-1 hotfix
// Fix for #13142 - Holding down the A button on the furnace ingredient slot causes the UI to display incorrect item counts
std::byte byteId = dis->readByte();
byte byteId = dis->readByte();
containerId = *(char *)&byteId;
slot = dis->readShort();
item = readItem(dis);
@ -42,7 +42,7 @@ void ContainerSetSlotPacket::read(DataInputStream *dis) //throws IOException
void ContainerSetSlotPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)containerId);
dos->writeByte((byte)containerId);
dos->writeShort(slot);
writeItem(item, dos);
}

View file

@ -138,7 +138,7 @@ bool DataInputStream::readFully(byteArray b)
}
else
{
b[i] = static_cast<std::byte>(byteRead);
b[i] = static_cast<byte>(byteRead);
}
}
return true;

View file

@ -39,9 +39,9 @@ void EntityActionAtPositionPacket::read(DataInputStream *dis) //throws IOExcepti
void EntityActionAtPositionPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(id);
dos->writeByte((std::byte)action);
dos->writeByte((byte)action);
dos->writeInt(x);
dos->writeByte((std::byte)y);
dos->writeByte((byte)y);
dos->writeInt(z);
}

View file

@ -9,7 +9,7 @@
EntityEventPacket::EntityEventPacket()
{
entityId = 0;
eventId = (std::byte)0;
eventId = (byte)0;
}
EntityEventPacket::EntityEventPacket(int entityId, byte eventId)

View file

@ -99,9 +99,9 @@ void ExplodePacket::write(DataOutputStream *dos) //throws IOException
int xx = tp.x-xp;
int yy = tp.y-yp;
int zz = tp.z-zp;
dos->writeByte((std::byte)xx);
dos->writeByte((std::byte)yy);
dos->writeByte((std::byte)zz);
dos->writeByte((byte)xx);
dos->writeByte((byte)yy);
dos->writeByte((byte)zz);
}
}

View file

@ -85,7 +85,7 @@ ssize_t ReadFile(int fd, void* buffer, size_t byteRead, DWORD* numberOfBytesRead
//the next byte of data, or -1 if the end of the file is reached.
int FileInputStream::read()
{
byte byteRead = static_cast<std::byte>(0);
byte byteRead = static_cast<byte>(0);
DWORD numberOfBytesRead;
BOOL bSuccess = ReadFile(

View file

@ -44,8 +44,8 @@ void GameEventPacket::read(DataInputStream *dis) //throws IOException
void GameEventPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)_event);
dos->writeByte((std::byte)param);
dos->writeByte((byte)_event);
dos->writeByte((byte)param);
}
void GameEventPacket::handle(PacketListener *listener)

View file

@ -34,7 +34,7 @@ void InteractPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeInt(source);
dos->writeInt(target);
dos->writeByte((std::byte)action);
dos->writeByte((byte)action);
}
void InteractPacket::handle(PacketListener *listener)

View file

@ -28,7 +28,7 @@ void KickPlayerPacket::read(DataInputStream *dis) //throws IOException
void KickPlayerPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((std::byte)m_networkSmallId);
dos->writeByte((byte)m_networkSmallId);
}
int KickPlayerPacket::getEstimatedSize()

View file

@ -28,7 +28,7 @@ void LevelEventPacket::read(DataInputStream *dis) //throws IOException
{
type = dis->readInt();
x = dis->readInt();
y = (int)(dis->readByte() & (std::byte)0xff);
y = (int)(dis->readByte() & (byte)0xff);
z = dis->readInt();
data = dis->readInt();
}
@ -37,7 +37,7 @@ void LevelEventPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(type);
dos->writeInt(x);
dos->writeByte((std::byte)(y & 0xff));
dos->writeByte((byte)(y & 0xff));
dos->writeInt(z);
dos->writeInt(data);
}

View file

@ -15,7 +15,7 @@ public:
void write(DataOutput *dos)
{
if (list.size() > 0) type = (list[0])->getId();
else type = static_cast<std::byte>(1);
else type = static_cast<byte>(1);
dos->writeByte(type);
dos->writeInt((int)list.size());

View file

@ -145,16 +145,16 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
}
dos->writeLong(seed);
dos->writeInt(gameType);
dos->writeByte((std::byte)dimension);
dos->writeByte((std::byte)mapHeight);
dos->writeByte((std::byte)maxPlayers);
dos->writeByte((byte)dimension);
dos->writeByte((byte)mapHeight);
dos->writeByte((byte)maxPlayers);
dos->writePlayerUID(m_offlineXuid);
dos->writePlayerUID(m_onlineXuid);
dos->writeBoolean(m_friendsOnlyUGC);
dos->writeInt(m_ugcPlayersVersion);
dos->writeByte((std::byte)difficulty);
dos->writeByte((byte)difficulty);
dos->writeInt(m_multiplayerInstanceId);
dos->writeByte((std::byte)m_playerIndex);
dos->writeByte((byte)m_playerIndex);
dos->writeInt(m_playerSkinId);
dos->writeInt(m_playerCapeId);
dos->writeBoolean(m_isGuest);

View file

@ -92,11 +92,11 @@ void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException
void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacket::write(dos);
dos->writeByte((std::byte)xa);
dos->writeByte((std::byte)ya);
dos->writeByte((std::byte)za);
dos->writeByte((std::byte)yRot);
dos->writeByte((std::byte)xRot);
dos->writeByte((byte)xa);
dos->writeByte((byte)ya);
dos->writeByte((byte)za);
dos->writeByte((byte)yRot);
dos->writeByte((byte)xRot);
}
int MoveEntityPacket::PosRot::getEstimatedSize()
@ -126,9 +126,9 @@ void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException
void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacket::write(dos);
dos->writeByte((std::byte)xa);
dos->writeByte((std::byte)ya);
dos->writeByte((std::byte)za);
dos->writeByte((byte)xa);
dos->writeByte((byte)ya);
dos->writeByte((byte)za);
}
int MoveEntityPacket::Pos::getEstimatedSize()
@ -158,8 +158,8 @@ void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException
void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException
{
MoveEntityPacket::write(dos);
dos->writeByte((std::byte)yRot);
dos->writeByte((std::byte)xRot);
dos->writeByte((byte)yRot);
dos->writeByte((byte)xRot);
}
int MoveEntityPacket::Rot::getEstimatedSize()

View file

@ -146,7 +146,7 @@ void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOExcepti
short idAndY = id | ya << 11;
dos->writeShort(idAndY);
char XandZ = ( xa << 4 ) | ( za & 0x0f );
dos->writeByte((std::byte)XandZ);
dos->writeByte((byte)XandZ);
}
int MoveEntityPacketSmall::Pos::getEstimatedSize()

View file

@ -6,10 +6,11 @@
#include "PacketListener.h"
#include "Packet.h"
#include "com.mojang.nbt.h"
#include "../Minecraft.Client/Windows64/Windows64_App.h"
#ifndef _CONTENT_PACKAGE
#include "..\Minecraft.Client\Minecraft.h"
#include "..\Minecraft.Client\Gui.h"
#include "../Minecraft.Client/Minecraft.h"
#include "../Minecraft.Client/Gui.h"
#endif
void Packet::staticCtor()

View file

@ -7,18 +7,18 @@ using namespace std;
class Tag
{
public:
static const byte TAG_End = static_cast<std::byte>(0);
static const byte TAG_Byte = static_cast<std::byte>(1);
static const byte TAG_Short = static_cast<std::byte>(2);
static const byte TAG_Int = static_cast<std::byte>(3);
static const byte TAG_Long = static_cast<std::byte>(4);
static const byte TAG_Float = static_cast<std::byte>(5);
static const byte TAG_Double = static_cast<std::byte>(6);
static const byte TAG_Byte_Array = static_cast<std::byte>(7);
static const byte TAG_String = static_cast<std::byte>(8);
static const byte TAG_List = static_cast<std::byte>(9);
static const byte TAG_Compound = static_cast<std::byte>(10);
static const byte TAG_Int_Array = static_cast<std::byte>(11);
static const byte TAG_End = static_cast<byte>(0);
static const byte TAG_Byte = static_cast<byte>(1);
static const byte TAG_Short = static_cast<byte>(2);
static const byte TAG_Int = static_cast<byte>(3);
static const byte TAG_Long = static_cast<byte>(4);
static const byte TAG_Float = static_cast<byte>(5);
static const byte TAG_Double = static_cast<byte>(6);
static const byte TAG_Byte_Array = static_cast<byte>(7);
static const byte TAG_String = static_cast<byte>(8);
static const byte TAG_List = static_cast<byte>(9);
static const byte TAG_Compound = static_cast<byte>(10);
static const byte TAG_Int_Array = static_cast<byte>(11);
private:
wstring name;

View file

@ -441,7 +441,7 @@ const int QNET_SENDDATA_SEQUENTIAL = 0;
struct XRNM_SEND_BUFFER
{
DWORD dwDataSize;
std::byte *pbyData;
byte *pbyData;
};
const int D3DBLEND_CONSTANTALPHA = 0;