From 9d41d3c35956ee7a3c73b16bfc12b80f6b786292 Mon Sep 17 00:00:00 2001 From: notmatthewbeshay <92357869+NotMachow@users.noreply.github.com> Date: Wed, 11 Mar 2026 07:27:46 +1100 Subject: [PATCH] Use fixed-width byte values in world data --- Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp | 6 +++--- Minecraft.World/Entities/Mob.cpp | 2 +- Minecraft.World/Network/Packets/TileUpdatePacket.cpp | 4 ++-- Minecraft.World/WorldGen/Biomes/DesertBiome.cpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp index c28e1a903..68b589787 100644 --- a/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp @@ -13,8 +13,8 @@ SkullTileEntity::SkullTileEntity() void SkullTileEntity::save(CompoundTag *tag) { TileEntity::save(tag); - tag->putByte(L"SkullType", (BYTE) (skullType & 0xff)); - tag->putByte(L"Rot", (BYTE) (rotation & 0xff)); + tag->putByte(L"SkullType", static_cast(skullType & 0xff)); + tag->putByte(L"Rot", static_cast(rotation & 0xff)); tag->putString(L"ExtraType", extraType); } @@ -69,4 +69,4 @@ std::shared_ptr SkullTileEntity::clone() result->rotation = rotation; result->extraType = extraType; return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/Entities/Mob.cpp b/Minecraft.World/Entities/Mob.cpp index 4b64f0363..44e733151 100644 --- a/Minecraft.World/Entities/Mob.cpp +++ b/Minecraft.World/Entities/Mob.cpp @@ -1097,7 +1097,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag) MobEffectInstance *effect = it->second; CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Id", (BYTE) effect->getId()); + tag->putByte(L"Id", static_cast(effect->getId())); tag->putByte(L"Amplifier", (char) effect->getAmplifier()); tag->putInt(L"Duration", effect->getDuration()); listTag->add(tag); diff --git a/Minecraft.World/Network/Packets/TileUpdatePacket.cpp b/Minecraft.World/Network/Packets/TileUpdatePacket.cpp index 6c94d0e2b..563461500 100644 --- a/Minecraft.World/Network/Packets/TileUpdatePacket.cpp +++ b/Minecraft.World/Network/Packets/TileUpdatePacket.cpp @@ -33,7 +33,7 @@ void TileUpdatePacket::read(DataInputStream *dis) //throws IOException block = (int)dis->readShort() & 0xffff; - BYTE dataLevel = dis->readByte(); + std::uint8_t dataLevel = dis->readByte(); data = dataLevel & 0xf; levelIdx = (dataLevel>>4) & 0xf; #else @@ -61,7 +61,7 @@ void TileUpdatePacket::write(DataOutputStream *dos) //throws IOException dos->writeInt(z); dos->writeShort(block); - BYTE dataLevel = ((levelIdx & 0xf ) << 4) | (data & 0xf); + std::uint8_t dataLevel = ((levelIdx & 0xf ) << 4) | (data & 0xf); dos->writeByte(dataLevel); #else // 4J - for our fixed size map, we can pack x & z into 10 bits each (-512 -> 511), y into 8 bits (0 to 255) diff --git a/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp b/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp index 09947db05..198d44406 100644 --- a/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp +++ b/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp @@ -10,8 +10,8 @@ DesertBiome::DesertBiome(int id) : Biome(id) friendlies.clear(); friendlies_chicken.clear(); // 4J added friendlies_wolf.clear(); // 4J added - this->topMaterial = (BYTE) Tile::sand_Id; - this->material = (BYTE) Tile::sand_Id; + this->topMaterial = static_cast(Tile::sand_Id); + this->material = static_cast(Tile::sand_Id); decorator->treeCount = -999; decorator->deadBushCount = 2; @@ -30,4 +30,4 @@ void DesertBiome::decorate(Level *level, Random *random, int xo, int zo) Feature *well = new DesertWellFeature(); well->place(level, random, x, level->getHeightmap(x, z) + 1, z); } -} \ No newline at end of file +}