mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Make ToolItem and MaterialItem to convert names by aliases at creation time too (necessary for eg. crafting)
This commit is contained in:
parent
97c3bc408b
commit
6145a135bd
6 changed files with 37 additions and 24 deletions
|
@ -403,15 +403,8 @@ public:
|
|||
}
|
||||
virtual bool getId(const std::string &name_, content_t &result) const
|
||||
{
|
||||
std::string name = name_;
|
||||
// Convert name according to possible alias
|
||||
std::map<std::string, std::string>::const_iterator i;
|
||||
i = m_aliases.find(name);
|
||||
if(i != m_aliases.end()){
|
||||
/*infostream<<"ndef: alias active: "<<name<<" -> "<<i->second
|
||||
<<std::endl;*/
|
||||
name = i->second;
|
||||
}
|
||||
std::string name = getAlias(name_);
|
||||
// Get id
|
||||
return m_name_id_mapping.getId(name, result);
|
||||
}
|
||||
|
@ -427,6 +420,14 @@ public:
|
|||
getId(name, id);
|
||||
return get(id);
|
||||
}
|
||||
virtual std::string getAlias(const std::string &name) const
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator i;
|
||||
i = m_aliases.find(name);
|
||||
if(i != m_aliases.end())
|
||||
return i->second;
|
||||
return name;
|
||||
}
|
||||
// IWritableNodeDefManager
|
||||
virtual void set(content_t c, const ContentFeatures &def)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue