mirror of
https://github.com/cuberite/cuberite.git
synced 2025-01-08 11:57:39 +08:00
WriteBlockEntity: don't write position multiple times (#5373)
This commit is contained in:
parent
9914393c63
commit
1616108af3
@ -609,10 +609,6 @@ void cProtocol_1_11_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
|
||||
|
||||
void cProtocol_1_11_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEntity & a_BlockEntity) const
|
||||
{
|
||||
a_Writer.AddInt("x", a_BlockEntity.GetPosX());
|
||||
a_Writer.AddInt("y", a_BlockEntity.GetPosY());
|
||||
a_Writer.AddInt("z", a_BlockEntity.GetPosZ());
|
||||
|
||||
switch (a_BlockEntity.GetBlockType())
|
||||
{
|
||||
case E_BLOCK_BED:
|
||||
@ -621,7 +617,6 @@ void cProtocol_1_11_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockE
|
||||
a_Writer.AddInt("color", BedEntity.GetColor()); // New: multicoloured beds
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_MOB_SPAWNER:
|
||||
{
|
||||
auto & MobSpawnerEntity = static_cast<const cMobSpawnerEntity &>(a_BlockEntity);
|
||||
@ -631,9 +626,12 @@ void cProtocol_1_11_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockE
|
||||
a_Writer.AddShort("Delay", MobSpawnerEntity.GetSpawnDelay());
|
||||
break;
|
||||
}
|
||||
|
||||
default: Super::WriteBlockEntity(a_Writer, a_BlockEntity);
|
||||
default: return Super::WriteBlockEntity(a_Writer, a_BlockEntity);
|
||||
}
|
||||
|
||||
a_Writer.AddInt("x", a_BlockEntity.GetPosX());
|
||||
a_Writer.AddInt("y", a_BlockEntity.GetPosY());
|
||||
a_Writer.AddInt("z", a_BlockEntity.GetPosZ());
|
||||
}
|
||||
|
||||
|
||||
|
@ -3089,10 +3089,6 @@ void cProtocol_1_8_0::SendPacket(cPacketizer & a_Pkt)
|
||||
|
||||
void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEntity & a_BlockEntity) const
|
||||
{
|
||||
a_Writer.AddInt("x", a_BlockEntity.GetPosX());
|
||||
a_Writer.AddInt("y", a_BlockEntity.GetPosY());
|
||||
a_Writer.AddInt("z", a_BlockEntity.GetPosZ());
|
||||
|
||||
switch (a_BlockEntity.GetBlockType())
|
||||
{
|
||||
case E_BLOCK_WALL_BANNER:
|
||||
@ -3102,16 +3098,12 @@ void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEn
|
||||
a_Writer.AddInt("Base", static_cast<Int32>(BannerEntity.GetBaseColor()));
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_BEACON:
|
||||
case E_BLOCK_CHEST:
|
||||
{
|
||||
auto & BeaconEntity = static_cast<const cBeaconEntity &>(a_BlockEntity);
|
||||
a_Writer.AddInt("Primary", BeaconEntity.GetPrimaryEffect());
|
||||
a_Writer.AddInt("Secondary", BeaconEntity.GetSecondaryEffect());
|
||||
a_Writer.AddInt("Levels", BeaconEntity.GetBeaconLevel());
|
||||
// Nothing!
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_COMMAND_BLOCK:
|
||||
{
|
||||
auto & CommandBlockEntity = static_cast<const cCommandBlockEntity &>(a_BlockEntity);
|
||||
@ -3128,23 +3120,12 @@ void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEn
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_ENCHANTMENT_TABLE:
|
||||
{
|
||||
auto & EnchantingTableEntity = static_cast<const cEnchantingTableEntity &>(a_BlockEntity);
|
||||
if (!EnchantingTableEntity.GetCustomName().empty())
|
||||
{
|
||||
a_Writer.AddString("CustomName", EnchantingTableEntity.GetCustomName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_END_PORTAL:
|
||||
{
|
||||
// Nothing!
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_HEAD:
|
||||
{
|
||||
auto & MobHeadEntity = static_cast<const cMobHeadEntity &>(a_BlockEntity);
|
||||
@ -3166,7 +3147,6 @@ void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEn
|
||||
a_Writer.EndCompound();
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_FLOWER_POT:
|
||||
{
|
||||
auto & FlowerPotEntity = static_cast<const cFlowerPotEntity &>(a_BlockEntity);
|
||||
@ -3174,7 +3154,6 @@ void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEn
|
||||
a_Writer.AddInt("Data", static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemDamage));
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_MOB_SPAWNER:
|
||||
{
|
||||
auto & MobSpawnerEntity = static_cast<const cMobSpawnerEntity &>(a_BlockEntity);
|
||||
@ -3182,12 +3161,15 @@ void cProtocol_1_8_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEn
|
||||
a_Writer.AddShort("Delay", MobSpawnerEntity.GetSpawnDelay());
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
a_Writer.AddInt("x", a_BlockEntity.GetPosX());
|
||||
a_Writer.AddInt("y", a_BlockEntity.GetPosY());
|
||||
a_Writer.AddInt("z", a_BlockEntity.GetPosZ());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1482,13 +1482,12 @@ void cProtocol_1_9_0::SendEntitySpawn(const cEntity & a_Entity, const UInt8 a_Ob
|
||||
|
||||
void cProtocol_1_9_0::WriteBlockEntity(cFastNBTWriter & a_Writer, const cBlockEntity & a_BlockEntity) const
|
||||
{
|
||||
a_Writer.AddInt("x", a_BlockEntity.GetPosX());
|
||||
a_Writer.AddInt("y", a_BlockEntity.GetPosY());
|
||||
a_Writer.AddInt("z", a_BlockEntity.GetPosZ());
|
||||
|
||||
if (a_BlockEntity.GetBlockType() == E_BLOCK_MOB_SPAWNER)
|
||||
{
|
||||
auto & MobSpawnerEntity = static_cast<const cMobSpawnerEntity &>(a_BlockEntity);
|
||||
a_Writer.AddInt("x", a_BlockEntity.GetPosX());
|
||||
a_Writer.AddInt("y", a_BlockEntity.GetPosY());
|
||||
a_Writer.AddInt("z", a_BlockEntity.GetPosZ());
|
||||
a_Writer.BeginCompound("SpawnData"); // New: SpawnData compound
|
||||
a_Writer.AddString("id", cMonster::MobTypeToVanillaName(MobSpawnerEntity.GetEntity()));
|
||||
a_Writer.EndCompound();
|
||||
|
Loading…
Reference in New Issue
Block a user