From 8aefbf335b362d78bc9c924c6f5fe876524c0b70 Mon Sep 17 00:00:00 2001 From: KobeBryant114514 <116721335+KobeBryant114514@users.noreply.github.com> Date: Sun, 20 Apr 2025 18:49:14 +0800 Subject: [PATCH] fix: fix recipe --- src/LegacyModApi.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/LegacyModApi.cpp b/src/LegacyModApi.cpp index f6c6ff4..d9172f9 100644 --- a/src/LegacyModApi.cpp +++ b/src/LegacyModApi.cpp @@ -1,10 +1,10 @@ #include "Global.h" -std::unordered_set HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"}; - ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) { - if (HardCodedKeys.count(key)) return {{ICustomRecipe::Ingredient{key}}}; - return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key, 1, 0)}); + if (auto context = magic_enum::enum_cast(key)) { + return ICustomRecipe::UnlockingRequirement(*context); + } + return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key)}); } void Export_Legacy_GMLib_ModAPI() { @@ -37,9 +37,9 @@ void Export_Legacy_GMLib_ModAPI() { std::string const& unlock) -> void { if (!GMLevel::getInstance().has_value()) return; ICustomShapedRecipe::ShapedIngredients types; - char index = 'a'; + char index = 'A'; for (auto& ing : ingredients) { - types.add(std::string{index++}, ICustomRecipe::Ingredient{ing, 1}); + types.add(std::string(1, index++), ICustomRecipe::Ingredient{ing}); } CustomRecipeRegistry::getInstance().registerShapedRecipe( recipe_id, @@ -48,7 +48,6 @@ void Export_Legacy_GMLib_ModAPI() { ItemInstance(result, count), makeRecipeUnlockingKey(unlock) ); - } ); RemoteCall::exportAs(