Merge pull request #1575 from mc-server/1.8-Item
Fixed 1.8 world item format reading.
This commit is contained in:
commit
d898fb904b
@ -217,7 +217,12 @@ BLOCKTYPE BlockStringToType(const AString & a_BlockTypeString)
|
||||
|
||||
bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item)
|
||||
{
|
||||
return gsBlockIDMap.ResolveItem(TrimString(a_ItemTypeString), a_Item);
|
||||
AString ItemName = TrimString(a_ItemTypeString);
|
||||
if (ItemName.substr(0, 10) == "minecraft:")
|
||||
{
|
||||
ItemName = ItemName.substr(10);
|
||||
}
|
||||
return gsBlockIDMap.ResolveItem(ItemName, a_Item);
|
||||
}
|
||||
|
||||
|
||||
|
@ -696,11 +696,28 @@ cBlockEntity * cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int a
|
||||
bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
int Type = a_NBT.FindChildByName(a_TagIdx, "id");
|
||||
if ((Type < 0) || (a_NBT.GetType(Type) != TAG_Short))
|
||||
if (Type <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
a_Item.m_ItemType = a_NBT.GetShort(Type);
|
||||
|
||||
if (a_NBT.GetType(Type) == TAG_String)
|
||||
{
|
||||
if (!StringToItem(a_NBT.GetString(Type), a_Item))
|
||||
{
|
||||
// Can't resolve item type
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (a_NBT.GetType(Type) == TAG_Short)
|
||||
{
|
||||
a_Item.m_ItemType = a_NBT.GetShort(Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a_Item.m_ItemType < 0)
|
||||
{
|
||||
a_Item.Empty();
|
||||
|
Loading…
Reference in New Issue
Block a user