API for other plugins
Repository
Code (Text):
maven { url 'https://jitpack.io' }
Dependency
Code (Text):
implementation("com.github.darksoulq:NeverEnoughRecipes:<version>")
Replace
<version> with the latest GitHub release.
Creating a Recipe Layout
Code (Java):
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
public
class YourRecipeParser
implements RecipeLayout
<YourRecipeClass
>
{
@Override
public Class
<YourRecipeClass
> getRecipeClass
(
)
{
return YourRecipeClass.
class
;
}
@Override
public ParsedRecipeView parseRecipe
(YourRecipeClass recipe
)
{
Map
<
Integer, List
<ItemStack
>> slotMap
=
new HashMap
<>
(
)
;
// fill slotMap
return
new ParsedRecipeView
(slotMap, texture, offset, providerItem
)
;
}
@Override
public Set
<Integer
> getOutputSlots
(
)
{
// return output slots
// items in these slots will have this recipe added as a "use"
return
Set.
of
(
)
;
}
}
Notes
- Texture: Refer to AbyssalLib for loading fonts and TextureGlyphs
- Offset: Use -8 if your texture matches the base texture size
- ProviderItem: The block this recipe belongs to (e.g. crafting table ItemStack)
Registering Content
Add item to namespace
Code (Java):
NerApi.
addItemToNamespace
(itemStack,
"namespace"
)
;
Makes the item visible in the main menu.
namespace can be anything (e.g. your plugin name).
Register recipe
Code (Java):
NerApi.
registerRecipe
(resultStack, recipe
)
;
Assigns a recipe to a result.
A single recipe can be registered to multiple results.
Register layout
Code (Java):
NerApi.
registerLayout
(recipeLayout
)
;
Add item without namespace
Code (Java):
NerApi.
addItem
(itemStack
)
;
Search Filters
Code (Java):
NerApi.
registerMenuFilter
(
"prefix",
(query, item
)
->
{
// return true/false
}
)
;
Ignoring Vanilla Recipes
Code (Java):
NerApi.
ignoreVanillaRecipe
(namespacedKey
)
;
Call this in
onEnable() if:
- You remove vanilla recipes
- You plan to re-handle them with your own parser