Skip to content

Commit

Permalink
Fixed 1.8 world item format reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
Howaner committed Oct 29, 2014
1 parent 48ac3ac commit 165533c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/BlockID.cpp
Expand Up @@ -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);
}


Expand Down
21 changes: 19 additions & 2 deletions src/WorldStorage/WSSAnvil.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit 165533c

Please sign in to comment.