diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-09-08 23:49:27 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-09-08 23:49:27 +0200 |
commit | 92c7d48af03a63eeeb4813fd5d10c9aff8841f0a (patch) | |
tree | 88e24216f2f52ab0458876e754e65ce951044ea6 /source | |
parent | Core now uses built in item functions ( StringToItem() ) for the /item command (diff) | |
download | cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.tar cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.tar.gz cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.tar.bz2 cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.tar.lz cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.tar.xz cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.tar.zst cuberite-92c7d48af03a63eeeb4813fd5d10c9aff8841f0a.zip |
Diffstat (limited to 'source')
-rw-r--r-- | source/BlockID.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/BlockID.cpp b/source/BlockID.cpp index 654a55e63..3652938c2 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -124,6 +124,7 @@ public: AString Desolve(short a_ItemType, short a_ItemDamage) { + // First try an exact match, both ItemType and ItemDamage ("birchplanks=5:2"): for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) { if ((itr->second.first == a_ItemType) && (itr->second.second == a_ItemDamage)) @@ -131,6 +132,20 @@ public: return itr->first; } } // for itr - m_Map[] + + // There is no exact match, try matching ItemType only ("planks=5"): + if (a_ItemDamage == 0) + { + for (ItemMap::iterator itr = m_Map.begin(), end = m_Map.end(); itr != end; ++itr) + { + if ((itr->second.first == a_ItemType) && (itr->second.second == -1)) + { + return itr->first; + } + } // for itr - m_Map[] + } + + // No match at all, synthesize a string ("5:1"): AString res; if (a_ItemDamage == -1) { |