Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/o7410/recipebooklib
A Minecraft library for registering categories and groups to the recipe book
https://github.com/o7410/recipebooklib
Last synced: 4 days ago
JSON representation
A Minecraft library for registering categories and groups to the recipe book
- Host: GitHub
- URL: https://github.com/o7410/recipebooklib
- Owner: O7410
- License: other
- Created: 2024-07-15T17:04:18.000Z (7 months ago)
- Default Branch: 1.21
- Last Pushed: 2024-07-16T11:01:44.000Z (7 months ago)
- Last Synced: 2024-12-12T15:16:10.612Z (about 2 months ago)
- Language: Java
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A library for registering new categories and groups to the recipe book
Why does this exist?
Without this library you need multiple mixins, this library handles that for you!
More than 1 mod can use this library at the same time!
Currently, I am not aware of any other libraries that do this
### **Supported platforms**
Currently, this library only supports Fabric 1.20.4, 1.20.6, and 1.21
If you want it for a different version, [create an issue on the GitHub page](https://github.com/O7410/RecipeBookLib/issues/new)## For players/server owners:
### Install this mod and fabric api## For devs:
### Example Usage:in `onInitializeClient`:
```java
ChangeGroupForRecipeCallback.EVENT.register(recipeEntry -> {
if (recipeEntry.value() instanceof CustomRecipe customRecipe) {
if (customRecipe.getResult(null).isIn(CustomItemTags.FRUIT)) {
return Optional.of(CustomRecipeBookAdditions.FRUIT_GROUP);
}
if (customRecipe.getResult(null).isIn(CustomItemTags.MEAT)) {
return Optional.of(CustomRecipeBookAdditions.MEAT_GROUP);
}
if (customRecipe.getResult(null).isIn(CustomItemTags.METALS) || customRecipe.getResult(null).isIn(CustomItemTags.GEMS)) {
return Optional.of(CustomRecipeBookAdditions.METALS_AND_GEMS_GROUP);
}
}
return Optional.empty();
});
```
Then, it is recommended to create a new class to store all of the groups and categories, like this:
```java
public class CustomRecipeBookAdditions {
public static final RecipeBookGroup CUSTOM_SEARCH_GROUP = RecipeBookLibApi.registerGroup("CUSTOM_SEARCH_GROUP", new ItemStack(Items.COMPASS));
public static final RecipeBookGroup FRUIT_GROUP = RecipeBookLibApi.registerGroup("FRUIT_GROUP", new ItemStack(Items.APPLE));
public static final RecipeBookGroup MEAT_GROUP = RecipeBookLibApi.registerGroup("MEAT_GROUP", new ItemStack(Items.COOKED_BEEF));
public static final RecipeBookGroup METALS_AND_GEMS_GROUP = RecipeBookLibApi.registerGroup("METALS_AND_GEMS_GROUP", new ItemStack(Items.IRON_INGOT), new ItemStack(Items.EMERALD));public static final List CUSTOM_CRAFTING_GROUPS = ImmutableList.of(
CUSTOM_SEARCH_GROUP,
FRUIT_GROUP,
MEAT_GROUP,
METALS_AND_GEMS_GROUP
);public static final RecipeBookCategory CUSTOM_CRAFTING = RecipeBookLibApi.registerCategory("CUSTOM_CRAFTING", CUSTOM_CRAFTING_GROUPS);
static {
RecipeBookLibApi.registerSearchGroup(CUSTOM_SEARCH_GROUP, List.of(
FRUIT_GROUP,
MEAT_GROUP,
METALS_AND_GEMS_GROUP
));
}public static void registerRecipeBookAdditions() {
YourMod.LOGGER.info("Registering recipe book additions for " + YourMod.MOD_ID);
}
}
```
and don't forget to "wake up" the class by calling `registerRecipeBookAdditions` in `onInitialize`.Then, in your custom screen handler that extends `AbstractRecipeScreenHandler`, you can use the custom category like this:
```java
@Override
public RecipeBookCategory getCategory() {
return CustomRecipeBookAdditions.CUSTOM_CRAFTING;
}
```RecipeBookLib by 7410 is licensed under CC BY-NC 4.0