summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2016-01-12 00:52:25 +0100
committerworktycho <work.tycho@gmail.com>2016-01-12 00:52:25 +0100
commit7aa0b7299dad299a0b980d66793f43c70ecdd55f (patch)
tree3653367aaab3ddaeee96b5c3f9c3c6ed6d4bb9fd /src
parentMerge pull request #2848 from Nakkar/master (diff)
parentChanged the format of the MobHead data to allow MobHeads working on MInecraft 1.8 (diff)
downloadcuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.tar
cuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.tar.gz
cuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.tar.bz2
cuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.tar.lz
cuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.tar.xz
cuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.tar.zst
cuberite-7aa0b7299dad299a0b980d66793f43c70ecdd55f.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/MobHeadEntity.cpp43
-rw-r--r--src/BlockEntities/MobHeadEntity.h24
-rw-r--r--src/Protocol/Protocol17x.cpp2
-rw-r--r--src/Protocol/Protocol18x.cpp15
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp15
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp43
6 files changed, 125 insertions, 17 deletions
diff --git a/src/BlockEntities/MobHeadEntity.cpp b/src/BlockEntities/MobHeadEntity.cpp
index 3275bf7f2..542e920ba 100644
--- a/src/BlockEntities/MobHeadEntity.cpp
+++ b/src/BlockEntities/MobHeadEntity.cpp
@@ -14,8 +14,7 @@
cMobHeadEntity::cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_HEAD, a_BlockX, a_BlockY, a_BlockZ, a_World),
m_Type(SKULL_TYPE_SKELETON),
- m_Rotation(SKULL_ROTATION_NORTH),
- m_Owner("")
+ m_Rotation(SKULL_ROTATION_NORTH)
{
}
@@ -35,9 +34,9 @@ bool cMobHeadEntity::UsedBy(cPlayer * a_Player)
void cMobHeadEntity::SetType(const eMobHeadType & a_Type)
{
- if ((!m_Owner.empty()) && (a_Type != SKULL_TYPE_PLAYER))
+ if ((!m_OwnerName.empty()) && (a_Type != SKULL_TYPE_PLAYER))
{
- m_Owner = "";
+ m_OwnerName = m_OwnerUUID = m_OwnerTexture = m_OwnerTextureSignature = "";
}
m_Type = a_Type;
}
@@ -55,13 +54,43 @@ void cMobHeadEntity::SetRotation(eMobHeadRotation a_Rotation)
-void cMobHeadEntity::SetOwner(const AString & a_Owner)
+void cMobHeadEntity::SetOwner(const cPlayer & a_Owner)
{
- if ((a_Owner.length() > 16) || (m_Type != SKULL_TYPE_PLAYER))
+ if (m_Type != SKULL_TYPE_PLAYER)
{
return;
}
- m_Owner = a_Owner;
+
+ m_OwnerName = a_Owner.GetName();
+ m_OwnerUUID = a_Owner.GetUUID();
+
+ const Json::Value & Properties = a_Owner.GetClientHandle()->GetProperties();
+ for (auto & Node : Properties)
+ {
+ if (Node.get("name", "").asString() == "textures")
+ {
+ m_OwnerTexture = Node.get("value", "").asString();
+ m_OwnerTextureSignature = Node.get("signature", "").asString();
+ break;
+ }
+ }
+}
+
+
+
+
+
+void cMobHeadEntity::SetOwner(const AString & a_OwnerUUID, const AString & a_OwnerName, const AString & a_OwnerTexture, const AString & a_OwnerTextureSignature)
+{
+ if (m_Type != SKULL_TYPE_PLAYER)
+ {
+ return;
+ }
+
+ m_OwnerUUID = a_OwnerUUID;
+ m_OwnerName = a_OwnerName;
+ m_OwnerTexture = a_OwnerTexture;
+ m_OwnerTextureSignature = a_OwnerTextureSignature;
}
diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h
index f25cb3a16..2eb932068 100644
--- a/src/BlockEntities/MobHeadEntity.h
+++ b/src/BlockEntities/MobHeadEntity.h
@@ -39,8 +39,11 @@ public:
/** Set the rotation of the mob head */
void SetRotation(eMobHeadRotation a_Rotation);
- /** Set the player name for mob heads with player type */
- void SetOwner(const AString & a_Owner);
+ /** Set the player for mob heads with player type */
+ void SetOwner(const cPlayer & a_Owner);
+
+ /** Sets the player components for the mob heads with player type */
+ void SetOwner(const AString & a_OwnerUUID, const AString & a_OwnerName, const AString & a_OwnerTexture, const AString & a_OwnerTextureSignature);
/** Returns the type of the mob head */
eMobHeadType GetType(void) const { return m_Type; }
@@ -49,7 +52,16 @@ public:
eMobHeadRotation GetRotation(void) const { return m_Rotation; }
/** Returns the player name of the mob head */
- AString GetOwner(void) const { return m_Owner; }
+ AString GetOwnerName(void) const { return m_OwnerName; }
+
+ /** Returns the player UUID of the mob head */
+ AString GetOwnerUUID(void) const { return m_OwnerUUID; }
+
+ /** Returns the texture of the mob head */
+ AString GetOwnerTexture(void) const { return m_OwnerTexture; }
+
+ /** Returns the texture signature of the mob head */
+ AString GetOwnerTextureSignature(void) const { return m_OwnerTextureSignature; }
// tolua_end
@@ -60,7 +72,11 @@ private:
eMobHeadType m_Type;
eMobHeadRotation m_Rotation;
- AString m_Owner;
+
+ AString m_OwnerName;
+ AString m_OwnerUUID;
+ AString m_OwnerTexture;
+ AString m_OwnerTextureSignature;
} ; // tolua_export
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 010e1a8ba..1c8c81bbd 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -2784,7 +2784,7 @@ void cProtocol172::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_
Writer.AddInt("z", MobHeadEntity.GetPosZ());
Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF);
Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF);
- Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str());
+ Writer.AddString("ExtraType", MobHeadEntity.GetOwnerName());
Writer.AddString("id", "Skull"); // "Tile Entity ID" - MC wiki; vanilla server always seems to send this though
break;
}
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index d80e9d034..c80907ed8 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -3109,8 +3109,21 @@ void cProtocol180::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_
Writer.AddInt("z", MobHeadEntity.GetPosZ());
Writer.AddByte("SkullType", MobHeadEntity.GetType() & 0xFF);
Writer.AddByte("Rot", MobHeadEntity.GetRotation() & 0xFF);
- Writer.AddString("ExtraType", MobHeadEntity.GetOwner().c_str());
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: http://minecraft.gamepedia.com/Head#Block_entity
+ Writer.BeginCompound("Owner");
+ Writer.AddString("Id", MobHeadEntity.GetOwnerUUID());
+ 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;
}
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index b0451e427..3a0823491 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -358,7 +358,20 @@ void cNBTChunkSerializer::AddMobHeadEntity(cMobHeadEntity * a_MobHead)
AddBasicTileEntity(a_MobHead, "Skull");
m_Writer.AddByte ("SkullType", a_MobHead->GetType() & 0xFF);
m_Writer.AddByte ("Rot", a_MobHead->GetRotation() & 0xFF);
- m_Writer.AddString("ExtraType", a_MobHead->GetOwner());
+
+ // The new Block Entity format for a Mob Head. See: http://minecraft.gamepedia.com/Head#Block_entity
+ m_Writer.BeginCompound("Owner");
+ m_Writer.AddString("Id", a_MobHead->GetOwnerUUID());
+ m_Writer.AddString("Name", a_MobHead->GetOwnerName());
+ m_Writer.BeginCompound("Properties");
+ m_Writer.BeginList("textures", TAG_Compound);
+ m_Writer.BeginCompound("");
+ m_Writer.AddString("Signature", a_MobHead->GetOwnerTextureSignature());
+ m_Writer.AddString("Value", a_MobHead->GetOwnerTexture());
+ m_Writer.EndCompound();
+ m_Writer.EndList();
+ m_Writer.EndCompound();
+ m_Writer.EndCompound();
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 5138717a7..3d325d354 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1293,10 +1293,47 @@ cBlockEntity * cWSSAnvil::LoadMobHeadFromNBT(const cParsedNBT & a_NBT, int a_Tag
MobHead->SetRotation(static_cast<eMobHeadRotation>(a_NBT.GetByte(currentLine)));
}
- currentLine = a_NBT.FindChildByName(a_TagIdx, "ExtraType");
- if (currentLine >= 0)
+ int ownerLine = a_NBT.FindChildByName(a_TagIdx, "Owner");
+ if (ownerLine >= 0)
{
- MobHead->SetOwner(a_NBT.GetString(currentLine));
+ AString OwnerName, OwnerUUID, OwnerTexture, OwnerTextureSignature;
+
+ currentLine = a_NBT.FindChildByName(ownerLine, "Id");
+ if (currentLine >= 0)
+ {
+ OwnerUUID = a_NBT.GetString(currentLine);
+ }
+
+ currentLine = a_NBT.FindChildByName(ownerLine, "Name");
+ if (currentLine >= 0)
+ {
+ OwnerName = a_NBT.GetString(currentLine);
+ }
+
+ int textureLine = a_NBT.GetFirstChild( // The first texture of
+ a_NBT.FindChildByName( // The texture list of
+ a_NBT.FindChildByName( // The Properties compound of
+ ownerLine, // The Owner compound
+ "Properties"
+ ),
+ "textures"
+ )
+ );
+ if (textureLine >= 0)
+ {
+ currentLine = a_NBT.FindChildByName(textureLine, "Signature");
+ if (currentLine >= 0)
+ {
+ OwnerTextureSignature = a_NBT.GetString(currentLine);
+ }
+
+ currentLine = a_NBT.FindChildByName(textureLine, "Value");
+ if (currentLine >= 0)
+ {
+ OwnerTexture = a_NBT.GetString(currentLine);
+ }
+ }
+ MobHead->SetOwner(OwnerUUID, OwnerName, OwnerTexture, OwnerTextureSignature);
}
return MobHead.release();