1
0

Fixed 1.8 world item format reading.

This commit is contained in:
Howaner 2014-10-29 15:47:43 +01:00
parent 48ac3acc84
commit 165533c27e
2 changed files with 25 additions and 3 deletions

View File

@ -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);
}

View File

@ -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();