1
0
Fork 0

Anvil: Wolf collar color is a byte in Vanilla.

Kept the old Int reading for compatibility reasons.
Ref.: #1448
This commit is contained in:
madmaxoft 2014-09-23 22:22:38 +02:00
parent d04ab9b703
commit 8d9dfc5d1a
2 changed files with 18 additions and 4 deletions

View File

@ -582,7 +582,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
m_Writer.AddByte("Sitting", Wolf.IsSitting() ? 1 : 0);
m_Writer.AddByte("Angry", Wolf.IsAngry() ? 1 : 0);
m_Writer.AddInt("CollarColor", Wolf.GetCollarColor());
m_Writer.AddByte("CollarColor", (unsigned char)Wolf.GetCollarColor());
break;
}
case cMonster::mtZombie:

View File

@ -2476,10 +2476,24 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
Monster->SetIsAngry(Angry);
}
int CollarColorIdx = a_NBT.FindChildByName(a_TagIdx, "CollarColor");
if ((CollarColorIdx > 0) && (a_NBT.GetType(CollarColorIdx) == TAG_Int))
if (CollarColorIdx > 0)
{
int CollarColor = a_NBT.GetInt(CollarColorIdx);
Monster->SetCollarColor(CollarColor);
switch (a_NBT.GetType(CollarColorIdx))
{
case TAG_Byte:
{
// Vanilla uses this
unsigned char CollarColor = a_NBT.GetByte(CollarColorIdx);
Monster->SetCollarColor(CollarColor);
break;
}
case TAG_Int:
{
// Old MCS code used this, keep reading it for compatibility reasons:
Monster->SetCollarColor(a_NBT.GetInt(CollarColorIdx));
break;
}
}
}
a_Entities.push_back(Monster.release());
}