summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol_1_9.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-03-15 18:06:58 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-03-18 00:44:59 +0100
commite3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a (patch)
tree81cc0687c9ffd438dff76e646dc81a5a6b54377f /src/Protocol/Protocol_1_9.cpp
parentMob heads, banners cannot be used (diff)
downloadcuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.tar
cuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.tar.gz
cuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.tar.bz2
cuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.tar.lz
cuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.tar.xz
cuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.tar.zst
cuberite-e3fe9e5e93fbf8ce26a61719fdb4ccd9a627d37a.zip
Diffstat (limited to 'src/Protocol/Protocol_1_9.cpp')
-rw-r--r--src/Protocol/Protocol_1_9.cpp146
1 files changed, 28 insertions, 118 deletions
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 916d3c206..4ebf826bf 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -128,6 +128,7 @@ void cProtocol_1_9_0::SendBossBarAdd(UInt32 a_UniqueID, const cCompositeChat & a
case BossBarColor::Purple: return 5U;
case BossBarColor::White: return 6U;
}
+ UNREACHABLE("Unsupported boss bar property");
}());
Pkt.WriteVarInt32([a_DivisionType]
{
@@ -139,6 +140,7 @@ void cProtocol_1_9_0::SendBossBarAdd(UInt32 a_UniqueID, const cCompositeChat & a
case BossBarDivisionType::TwelveNotches: return 3U;
case BossBarDivisionType::TwentyNotches: return 4U;
}
+ UNREACHABLE("Unsupported boss bar property");
}());
{
UInt8 Flags = 0x00;
@@ -237,6 +239,7 @@ void cProtocol_1_9_0::SendBossBarUpdateStyle(UInt32 a_UniqueID, BossBarColor a_C
case BossBarColor::Purple: return 5U;
case BossBarColor::White: return 6U;
}
+ UNREACHABLE("Unsupported boss bar property");
}());
Pkt.WriteVarInt32([a_DivisionType]
{
@@ -248,6 +251,7 @@ void cProtocol_1_9_0::SendBossBarUpdateStyle(UInt32 a_UniqueID, BossBarColor a_C
case BossBarDivisionType::TwelveNotches: return 3U;
case BossBarDivisionType::TwentyNotches: return 4U;
}
+ UNREACHABLE("Unsupported boss bar property");
}());
}
@@ -1450,6 +1454,30 @@ 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)
+{
+ 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.BeginCompound("SpawnData"); // New: SpawnData compound
+ a_Writer.AddString("id", cMonster::MobTypeToVanillaName(MobSpawnerEntity.GetEntity()));
+ a_Writer.EndCompound();
+ a_Writer.AddShort("Delay", MobSpawnerEntity.GetSpawnDelay());
+ }
+ else
+ {
+ Super::WriteBlockEntity(a_Writer, a_BlockEntity);
+ }
+}
+
+
+
+
+
void cProtocol_1_9_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
{
short ItemType = a_Item.m_ItemType;
@@ -1620,124 +1648,6 @@ void cProtocol_1_9_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
-void cProtocol_1_9_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<const cBannerEntity &>(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<Int32>(BannerEntity.GetBaseColor()));
- break;
- }
-
- case E_BLOCK_BEACON:
- {
- auto & BeaconEntity = static_cast<const cBeaconEntity &>(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<const cCommandBlockEntity &>(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<const cMobHeadEntity &>(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<const cFlowerPotEntity &>(a_BlockEntity);
- Writer.AddInt("x", FlowerPotEntity.GetPosX());
- Writer.AddInt("y", FlowerPotEntity.GetPosY());
- Writer.AddInt("z", FlowerPotEntity.GetPosZ());
- Writer.AddInt("Item", static_cast<Int32>(FlowerPotEntity.GetItem().m_ItemType));
- Writer.AddInt("Data", static_cast<Int32>(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<const cMobSpawnerEntity &>(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_9_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity)
{
// Common metadata: