minecraft-pi-reborn/example-mods/recipes/recipes.cpp

65 lines
1.5 KiB
C++
Raw Normal View History

2022-06-27 18:47:55 +00:00
// Headers
#include <libreborn/libreborn.h>
#include <symbols/minecraft.h>
#include <mods/misc/misc.h>
// Custom Crafting Recipes
2024-09-23 00:02:40 +00:00
#define SAND 12
2024-01-07 01:36:59 +00:00
static void Recipes_injection(Recipes *recipes) {
2022-06-27 18:47:55 +00:00
// Add
Recipes_Type type1 = {
.item = 0,
.tile = 0,
.instance = {
.count = 1,
2024-09-23 00:02:40 +00:00
.id = SAND,
2022-06-27 18:47:55 +00:00
.auxiliary = 0
},
.letter = 'a'
};
Recipes_Type type2 = {
.item = 0,
.tile = 0,
.instance = {
.count = 1,
.id = 13,
.auxiliary = 0
},
.letter = 'b'
};
ItemInstance result = {
.count = 1,
.id = 344,
.auxiliary = 0
};
2024-01-07 01:36:59 +00:00
std::vector<Recipes_Type> types = {type1, type2};
2024-07-15 07:09:19 +00:00
recipes->addShapelessRecipe(result, types);
2022-06-27 18:47:55 +00:00
}
// Custom Furnace Recipes
2024-01-07 01:36:59 +00:00
static void FurnaceRecipes_injection(FurnaceRecipes *recipes) {
2022-06-27 18:47:55 +00:00
// Add
2024-01-07 01:36:59 +00:00
ItemInstance result = {
.count = 1,
.id = 246,
.auxiliary = 0
};
2024-07-15 07:09:19 +00:00
recipes->addFurnaceRecipe(49, result);
2022-06-27 18:47:55 +00:00
}
// Init
__attribute__((constructor)) static void init_recipes() {
// Log
INFO("Loading Custom Recipes");
// Setup
misc_run_on_recipes_setup(Recipes_injection);
misc_run_on_furnace_recipes_setup(FurnaceRecipes_injection);
2024-09-23 00:02:40 +00:00
// Recipe Remainder
overwrite_calls(Minecraft_init, [](Minecraft_init_t original, Minecraft *self) {
original(self);
Item::items[SAND]->craftingRemainingItem = Item::snowball;
});
2022-06-27 18:47:55 +00:00
}