Added CustomName saving.
This commit is contained in:
parent
079634d18c
commit
5c53608dd0
@ -710,7 +710,10 @@ void cMonster::SetCustomName(const AString & a_CustomName)
|
||||
m_CustomName = a_CustomName.substr(0, 64);
|
||||
}
|
||||
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
if (m_World != NULL)
|
||||
{
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -720,7 +723,10 @@ void cMonster::SetCustomName(const AString & a_CustomName)
|
||||
void cMonster::SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible)
|
||||
{
|
||||
m_CustomNameAlwaysVisible = a_CustomNameAlwaysVisible;
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
if (m_World != NULL)
|
||||
{
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -504,6 +504,8 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
|
||||
m_Writer.AddFloat("", a_Monster->GetDropChanceBoots());
|
||||
m_Writer.EndList();
|
||||
m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot());
|
||||
m_Writer.AddString("CustomName", a_Monster->GetCustomName());
|
||||
m_Writer.AddByte("CustomNameVisible", (char)a_Monster->IsCustomNameAlwaysVisible());
|
||||
switch (a_Monster->GetMobType())
|
||||
{
|
||||
case cMonster::mtBat:
|
||||
|
@ -2640,6 +2640,19 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT &
|
||||
a_Monster.SetCanPickUpLoot(CanPickUpLoot);
|
||||
}
|
||||
|
||||
int CustomNameTag = a_NBT.FindChildByName(a_TagIdx, "CustomName");
|
||||
if ((CustomNameTag > 0) && (a_NBT.GetType(CustomNameTag) == TAG_String))
|
||||
{
|
||||
a_Monster.SetCustomName(a_NBT.GetString(CustomNameTag));
|
||||
}
|
||||
|
||||
int CustomNameVisibleTag = a_NBT.FindChildByName(a_TagIdx, "CustomNameVisible");
|
||||
if ((CustomNameVisibleTag > 0) && (a_NBT.GetType(CustomNameVisibleTag) == TAG_Byte))
|
||||
{
|
||||
bool CustomNameVisible = (a_NBT.GetByte(CustomNameVisibleTag) == 1);
|
||||
a_Monster.SetCustomNameAlwaysVisible(CustomNameVisible);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user