From e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 15 Mar 2021 17:06:58 +0000 Subject: Deduplicate WriteBlockEntity --- src/Protocol/Protocol_1_10.cpp | 118 ----------------------------------------- 1 file changed, 118 deletions(-) (limited to 'src/Protocol/Protocol_1_10.cpp') diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp index 6b88fbe2a..6db08c916 100644 --- a/src/Protocol/Protocol_1_10.cpp +++ b/src/Protocol/Protocol_1_10.cpp @@ -581,124 +581,6 @@ void cProtocol_1_10_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & -void cProtocol_1_10_0::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_BlockEntity) -{ - cFastNBTWriter Writer; - - switch (a_BlockEntity.GetBlockType()) - { - case E_BLOCK_WALL_BANNER: - case E_BLOCK_STANDING_BANNER: - { - auto & BannerEntity = static_cast(a_BlockEntity); - Writer.AddInt("x", BannerEntity.GetPosX()); - Writer.AddInt("y", BannerEntity.GetPosY()); - Writer.AddInt("z", BannerEntity.GetPosZ()); - Writer.AddString("id", "Banner"); - Writer.AddInt("Base", static_cast(BannerEntity.GetBaseColor())); - break; - } - - case E_BLOCK_BEACON: - { - auto & BeaconEntity = static_cast(a_BlockEntity); - Writer.AddInt("x", BeaconEntity.GetPosX()); - Writer.AddInt("y", BeaconEntity.GetPosY()); - Writer.AddInt("z", BeaconEntity.GetPosZ()); - Writer.AddInt("Primary", BeaconEntity.GetPrimaryEffect()); - Writer.AddInt("Secondary", BeaconEntity.GetSecondaryEffect()); - Writer.AddInt("Levels", BeaconEntity.GetBeaconLevel()); - Writer.AddString("id", "Beacon"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though - break; - } - - case E_BLOCK_COMMAND_BLOCK: - { - auto & CommandBlockEntity = static_cast(a_BlockEntity); - Writer.AddByte("TrackOutput", 1); // Neither I nor the MC wiki has any idea about this - Writer.AddInt("SuccessCount", CommandBlockEntity.GetResult()); - Writer.AddInt("x", CommandBlockEntity.GetPosX()); - Writer.AddInt("y", CommandBlockEntity.GetPosY()); - Writer.AddInt("z", CommandBlockEntity.GetPosZ()); - Writer.AddString("Command", CommandBlockEntity.GetCommand()); - // You can set custom names for windows in Vanilla - // For a command block, this would be the 'name' prepended to anything it outputs into global chat - // MCS doesn't have this, so just leave it @ '@'. (geddit?) - Writer.AddString("CustomName", "@"); - Writer.AddString("id", "Control"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though - if (!CommandBlockEntity.GetLastOutput().empty()) - { - Writer.AddString("LastOutput", Printf("{\"text\":\"%s\"}", CommandBlockEntity.GetLastOutput().c_str())); - } - break; - } - - case E_BLOCK_HEAD: - { - auto & MobHeadEntity = static_cast(a_BlockEntity); - Writer.AddInt("x", MobHeadEntity.GetPosX()); - Writer.AddInt("y", MobHeadEntity.GetPosY()); - Writer.AddInt("z", MobHeadEntity.GetPosZ()); - Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF); - Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF); - Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though - - // The new Block Entity format for a Mob Head. See: https://minecraft.gamepedia.com/Head#Block_entity - Writer.BeginCompound("Owner"); - Writer.AddString("Id", MobHeadEntity.GetOwnerUUID().ToShortString()); - Writer.AddString("Name", MobHeadEntity.GetOwnerName()); - Writer.BeginCompound("Properties"); - Writer.BeginList("textures", TAG_Compound); - Writer.BeginCompound(""); - Writer.AddString("Signature", MobHeadEntity.GetOwnerTextureSignature()); - Writer.AddString("Value", MobHeadEntity.GetOwnerTexture()); - Writer.EndCompound(); - Writer.EndList(); - Writer.EndCompound(); - Writer.EndCompound(); - break; - } - - case E_BLOCK_FLOWER_POT: - { - auto & FlowerPotEntity = static_cast(a_BlockEntity); - Writer.AddInt("x", FlowerPotEntity.GetPosX()); - Writer.AddInt("y", FlowerPotEntity.GetPosY()); - Writer.AddInt("z", FlowerPotEntity.GetPosZ()); - Writer.AddInt("Item", static_cast(FlowerPotEntity.GetItem().m_ItemType)); - Writer.AddInt("Data", static_cast(FlowerPotEntity.GetItem().m_ItemDamage)); - Writer.AddString("id", "FlowerPot"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though - break; - } - - case E_BLOCK_MOB_SPAWNER: - { - auto & MobSpawnerEntity = static_cast(a_BlockEntity); - Writer.AddInt("x", MobSpawnerEntity.GetPosX()); - Writer.AddInt("y", MobSpawnerEntity.GetPosY()); - Writer.AddInt("z", MobSpawnerEntity.GetPosZ()); - Writer.BeginCompound("SpawnData"); - Writer.AddString("id", cMonster::MobTypeToVanillaName(MobSpawnerEntity.GetEntity())); - Writer.EndCompound(); - Writer.AddShort("Delay", MobSpawnerEntity.GetSpawnDelay()); - Writer.AddString("id", "MobSpawner"); - break; - } - - default: - { - break; - } - } - - Writer.Finish(); - a_Pkt.WriteBuf(Writer.GetResult()); -} - - - - - void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) { using namespace Metadata; -- cgit v1.2.3