-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
480ea9d
commit f92c0e1
Showing
9 changed files
with
568 additions
and
83 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#pragma once | ||
#include "GMLIB/DllExport.h" | ||
#include "GMLIB/Mod/Recipe/CustomFurnaceRecipe.h" | ||
#include "GMLIB/Mod/Recipe/CustomShapedRecipe.h" | ||
#include "GMLIB/Mod/Recipe/CustomShapelessRecipe.h" | ||
#include "GMLIB/Mod/Recipe/CustomShulkerBoxRecipe.h" | ||
|
||
namespace GMLIB::Mod::Recipe { | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomShapedRecipe, T>::value | ||
GMLIB_API void registerShapedRecipe(); | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomShapelessRecipe, T>::value | ||
GMLIB_API void registerShapelessRecipe(); | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomFurnaceRecipe, T>::value | ||
GMLIB_API void registerFurnaceRecipe(); | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomShulkerBoxRecipe, T>::value | ||
GMLIB_API void registerShulkerBoxRecipe(); | ||
|
||
GMLIB_API bool unregisterRecipe(std::string recipe_id); | ||
|
||
namespace RapidRecipeLoader { | ||
|
||
GMLIB_API bool loadJsonRecipe(std::string json); | ||
GMLIB_API bool loadJsonRecipe(nlohmann::json json); | ||
|
||
GMLIB_API void addFurnaceRecipe( | ||
std::string recipeId, | ||
RecipeIngredient input, | ||
RecipeIngredient output, | ||
std::vector<std::string> craftingTags, | ||
std::variant<std::string, std::vector<RecipeIngredient>> unlock | ||
); | ||
|
||
GMLIB_API void | ||
addBrewingMixRecipe(std::string recipeId, std::string input, std::string output, RecipeIngredient reagent); | ||
|
||
GMLIB_API void addBrewingContainerRecipe( | ||
std::string recipeId, | ||
RecipeIngredient input, | ||
RecipeIngredient output, | ||
RecipeIngredient reagent, | ||
std::variant<std::string, std::vector<RecipeIngredient>> unlock | ||
); | ||
|
||
GMLIB_API void addSmithingTransformRecipe( | ||
std::string recipeId, | ||
std::string smithingTemplate, | ||
std::string base, | ||
std::string addition, | ||
std::string result | ||
); | ||
|
||
GMLIB_API void | ||
addSmithingTrimRecipe(std::string recipeId, std::string smithingTemplate, std::string base, std::string addition); | ||
|
||
GMLIB_API void addStoneCutterRecipe( | ||
std::string recipeId, | ||
RecipeIngredient input, | ||
RecipeIngredient output, | ||
std::variant<std::string, std::vector<RecipeIngredient>> unlock, | ||
int priority | ||
); | ||
|
||
GMLIB_API void addCustomCraftingTagRecipe( | ||
std::string recipeId, | ||
std::vector<RecipeIngredient> ingredients, | ||
RecipeIngredient result, | ||
std::vector<std::string> tags, | ||
std::variant<std::string, std::vector<RecipeIngredient>> unlock, | ||
int priority | ||
); | ||
|
||
GMLIB_API void addShapelessCraftingTableRecipe( | ||
std::string recipeId, | ||
std::vector<RecipeIngredient> ingredients, | ||
RecipeIngredient result, | ||
std::variant<std::string, std::vector<RecipeIngredient>> unlock, | ||
int priority | ||
); | ||
|
||
GMLIB_API void addShapedCraftingTableRecipe( | ||
std::string recipeId, | ||
std::vector<std::string> shape, | ||
std::vector<std::pair<std::string, RecipeIngredient>> ingredients, | ||
RecipeIngredient result, | ||
std::variant<std::string, std::vector<RecipeIngredient>> unlock, | ||
int priority | ||
); | ||
|
||
GMLIB_API void addShapedCraftingTableRecipe( | ||
std::string recipeId, | ||
std::vector<std::string> shape, | ||
std::vector<RecipeIngredient> ingredients, | ||
RecipeIngredient result, | ||
std::vector<RecipeIngredient> unlock, | ||
int priority | ||
); | ||
|
||
} // namespace RapidRecipeLoader | ||
|
||
} // namespace GMLIB::Mod::Recipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
#include "GMLIB/DllExport.h" | ||
|
||
namespace GMLIB::Mod::Recipe { | ||
|
||
class CustomFurnaceRecipe { | ||
public: | ||
|
||
virtual ItemInstance getInput() = 0; | ||
|
||
virtual ItemInstance getResult() = 0; | ||
|
||
virtual std::vector<HashedString> getCraftingTags() = 0; | ||
}; | ||
} // namespace GMLIB::Mod::Recipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
#include "GMLIB/DllExport.h" | ||
|
||
namespace GMLIB::Mod::Recipe { | ||
|
||
class CustomShapedRecipe { | ||
public: | ||
virtual std::string getRecipeId() = 0; | ||
|
||
virtual ItemInstance getResult() = 0; | ||
|
||
virtual std::vector<std::string> getShape() = 0; | ||
|
||
virtual std::vector<Recipes::Type> getIngredients() = 0; | ||
|
||
virtual std::vector<HashedString> getCraftingTags() { return {"crafting_table"}; } | ||
|
||
virtual int getPriority() { return 50; } | ||
|
||
virtual std::function<std::unique_ptr< | ||
ShapedRecipe>(std::string, int, int, std::vector<class RecipeIngredient> const&, std::vector<class ItemInstance> const&, class HashedString, int, class mce::UUID const*, std::optional<class RecipeUnlockingRequirement>, class SemVersion const&)> | ||
getConstructor() { | ||
return nullptr; | ||
} | ||
|
||
virtual std::optional<class RecipeUnlockingRequirement> getRecipeUnlockingRequirement() { return {}; } | ||
|
||
virtual SemVersion getSemVersion() { return SemVersion(1, 20, 50, "", ""); } | ||
}; | ||
|
||
|
||
} // namespace GMLIB::Mod::Recipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "GMLIB/DllExport.h" | ||
|
||
namespace GMLIB::Mod::Recipe { | ||
|
||
class CustomShapelessRecipe { | ||
public: | ||
virtual std::string getRecipeId() = 0; | ||
|
||
virtual ItemInstance getResult() = 0; | ||
|
||
virtual std::vector<Recipes::Type> getIngredients() = 0; | ||
|
||
virtual std::vector<HashedString> getCraftingTags() { return {"crafting_table"}; } | ||
|
||
virtual int getPriority() { return 50; } | ||
|
||
virtual std::function<std::unique_ptr< | ||
ShapelessRecipe>(std::string, std::vector<class RecipeIngredient> const&, std::vector<class ItemInstance> const&, class HashedString, int, class mce::UUID const*, std::optional<class RecipeUnlockingRequirement>, class SemVersion const&)> | ||
getConstructor() { | ||
return nullptr; | ||
} | ||
|
||
virtual std::optional<class RecipeUnlockingRequirement> getRecipeUnlockingRequirement() { return {}; } | ||
|
||
virtual SemVersion getSemVersion() { return SemVersion(1, 20, 50, "", ""); } | ||
}; | ||
|
||
} // namespace GMLIB::Mod::Recipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include "GMLIB/DllExport.h" | ||
|
||
namespace GMLIB::Mod::Recipe { | ||
|
||
class CustomShulkerBoxRecipe { | ||
public: | ||
virtual std::string getRecipeId() = 0; | ||
|
||
virtual ItemInstance getResult() = 0; | ||
|
||
virtual std::vector<Recipes::Type> getIngredients() = 0; | ||
|
||
virtual std::vector<HashedString> getCraftingTags() { return {"crafting_table"}; } | ||
|
||
virtual std::optional<class RecipeUnlockingRequirement> getRecipeUnlockingRequirement() { return {}; } | ||
|
||
virtual SemVersion getSemVersion() { return SemVersion(1, 20, 50, "", ""); } | ||
}; | ||
|
||
|
||
} // namespace GMLIB::Mod::Recipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include "Global.h" | ||
#include <GMLIB/Mod/Recipe/CustomFurnaceRecipe.h> | ||
#include <GMLIB/Mod/Recipe/CustomShapedRecipe.h> | ||
#include <GMLIB/Mod/Recipe/CustomShapelessRecipe.h> | ||
#include <GMLIB/Mod/Recipe/CustomShulkerBoxRecipe.h> | ||
|
||
using RecipesMap = std::map< | ||
class HashedString, | ||
class std::map< | ||
std::string, | ||
class std::shared_ptr<class Recipe>, | ||
struct std::less<std::string>, | ||
class std::allocator<struct std::pair<std::string const, class std::shared_ptr<class Recipe>>>>, | ||
struct std::less<class HashedString>, | ||
class std::allocator<struct std::pair< | ||
class HashedString const, | ||
class std::map< | ||
std::string, | ||
class std::shared_ptr<class Recipe>, | ||
struct std::less<std::string>, | ||
class std::allocator<struct std::pair<std::string const, class std::shared_ptr<class Recipe>>>>>>>; | ||
|
||
namespace GMLIB::Mod::Recipe { | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomShapedRecipe, T>::value | ||
void registerShapedRecipe() { | ||
SharedPtr<T> ShapedRecipe = SharedPtr<T>::makeShared(); | ||
return ll::service::bedrock::getLevel()->getRecipes().addShapedRecipe( | ||
ShapedRecipe->getRecipeId(), | ||
ShapedRecipe->getResult(), | ||
ShapedRecipe->getShape(), | ||
ShapedRecipe->getIngredients(), | ||
ShapedRecipe->getCraftingTags(), | ||
ShapedRecipe->getPriority(), | ||
ShapedRecipe->getConstructor(), | ||
ShapedRecipe->getRecipeUnlockingRequirement(), | ||
ShapedRecipe->getSemVersion() | ||
); | ||
} | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomShapelessRecipe, T>::value | ||
void registerShapelessRecipe() { | ||
SharedPtr<T> ShapelessRecipe = SharedPtr<T>::makeShared(); | ||
return ll::service::bedrock::getLevel()->getRecipes().addShapelessRecipe( | ||
ShapelessRecipe->getRecipeId(), | ||
ShapelessRecipe->getResult(), | ||
ShapelessRecipe->getIngredients(), | ||
ShapelessRecipe->getCraftingTags(), | ||
ShapelessRecipe->getPriority(), | ||
ShapelessRecipe->getConstructor(), | ||
ShapelessRecipe->getRecipeUnlockingRequirement(), | ||
ShapelessRecipe->getSemVersion() | ||
); | ||
} | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomFurnaceRecipe, T>::value | ||
void registerFurnaceRecipe() { | ||
SharedPtr<T> FurnaceRecipe = SharedPtr<T>::makeShared(); | ||
return ll::service::bedrock::getLevel()->getRecipes().addFurnaceRecipeAuxData( | ||
FurnaceRecipe->getInput(), | ||
FurnaceRecipe->getResult(), | ||
FurnaceRecipe->getCraftingTags() | ||
); | ||
} | ||
|
||
template <class T> | ||
requires std::is_base_of<CustomShulkerBoxRecipe, T>::value | ||
void registerShulkerBoxRecipe() { | ||
SharedPtr<T> ShulkerBoxRecipe = SharedPtr<T>::makeShared(); | ||
return ll::service::bedrock::getLevel()->getRecipes().addShulkerBoxRecipe( | ||
ShulkerBoxRecipe->getRecipeId(), | ||
ShulkerBoxRecipe->getResult(), | ||
ShulkerBoxRecipe->getIngredients(), | ||
ShulkerBoxRecipe->getCraftingTags(), | ||
ShulkerBoxRecipe->getRecipeUnlockingRequirement(), | ||
ShulkerBoxRecipe->getSemVersion() | ||
); | ||
} | ||
|
||
bool unregisterRecipe(std::string recipe_id) { | ||
auto AllRecipes = ll::service::bedrock::getLevel()->getRecipes().getRecipesAllTags(); | ||
for (auto& recipe : AllRecipes) { | ||
if (recipe.second.count(recipe_id)) { | ||
recipe.second.erase(recipe_id); | ||
CraftingDataPacket::prepareFromRecipes(ll::service::bedrock::getLevel()->getRecipes(), true)->sendToClients(); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
|
||
} // namespace GMLIB::Mod::Recipe |
Oops, something went wrong.