Use fixed-width byte values in world data

This commit is contained in:
notmatthewbeshay 2026-03-11 07:27:46 +11:00
parent 52eb80c3eb
commit 9d41d3c359
4 changed files with 9 additions and 9 deletions

View file

@ -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<std::uint8_t>(skullType & 0xff));
tag->putByte(L"Rot", static_cast<std::uint8_t>(rotation & 0xff));
tag->putString(L"ExtraType", extraType);
}
@ -69,4 +69,4 @@ std::shared_ptr<TileEntity> SkullTileEntity::clone()
result->rotation = rotation;
result->extraType = extraType;
return result;
}
}

View file

@ -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<std::uint8_t>(effect->getId()));
tag->putByte(L"Amplifier", (char) effect->getAmplifier());
tag->putInt(L"Duration", effect->getDuration());
listTag->add(tag);

View file

@ -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)

View file

@ -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<std::uint8_t>(Tile::sand_Id);
this->material = static_cast<std::uint8_t>(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);
}
}
}