| 192 | } |
| 193 | |
| 194 | ItemDatabase::ItemConfig ItemDatabase::itemConfig(String const& itemName, Json parameters, Maybe<float> level, Maybe<uint64_t> seed) const { |
| 195 | auto const& data = itemData(itemName); |
| 196 | |
| 197 | ItemConfig itemConfig; |
| 198 | if (data.assetsConfig) |
| 199 | itemConfig.config = Root::singleton().assets()->json(*data.assetsConfig); |
| 200 | itemConfig.directory = data.directory; |
| 201 | itemConfig.config = jsonMerge(itemConfig.config, data.customConfig); |
| 202 | itemConfig.parameters = parameters; |
| 203 | |
| 204 | if (auto builder = itemConfig.config.optString("builder")) { |
| 205 | RecursiveMutexLocker locker(m_luaMutex); |
| 206 | auto context = m_luaRoot->createContext(*builder); |
| 207 | context.setCallbacks("root", LuaBindings::makeRootCallbacks()); |
| 208 | context.setCallbacks("sb", LuaBindings::makeUtilityCallbacks()); |
| 209 | luaTie(itemConfig.config, itemConfig.parameters) = context.invokePath<LuaTupleReturn<Json, Json>>( |
| 210 | "build", itemConfig.directory, itemConfig.config, itemConfig.parameters, level, seed); |
| 211 | } |
| 212 | |
| 213 | return itemConfig; |
| 214 | } |
| 215 | |
| 216 | Maybe<String> ItemDatabase::itemFile(String const& itemName) const { |
| 217 | if (!hasItem(itemName)) { |
no test coverage detected