Server plugins
Recipes and tags
Recipes, brewing mixes and tags are the server's, so vanilla clients can join a server whose plugins add them: a vanilla client sees a plugin's recipes of vanilla items. Plugins add recipes and mixes in code and recipe and tag files in their data folder. Recipes and mixes may use a mod's items too, and players then need that mod (see Blocks and items).
Recipes
server.RegisterRecipes(ShapedRecipeBuilder.Create(CraftingBookCategory.Misc)
.WithKey('F', new ItemStack(ItemsRegistry.RottenFlesh, 1))
.WithPattern("FF", "FF")
.HasNoGroup()
.WithIdentifier("example:leather_from_rotten_flesh")
.WithResult(new ItemStack(ItemsRegistry.Leather, 1))
.Build());
IServer.RegisterRecipes adds recipes to that server's recipe set, next to vanilla's. Registration copies the
recipe, so changing it afterwards has no effect.
- Crafting tables and the player's 2x2 grid craft shaped and shapeless recipes. Vanilla's are tried first, so a plugin's recipe can't take over a vanilla pattern.
- Every player's recipe book shows them. Obsidian has no recipe unlocking: every player knows every crafting recipe.
- Furnaces, blast furnaces and smokers cook smelting, blasting and smoking recipes, and campfires campfire recipes. Cooking progress, fuel and earned experience are saved.
- The stonecutter and smithing table make their recipes' results.
An identifier (in snake case) names one recipe, and registering a taken one throws. Players online see recipes added and removed without reconnecting. When the plugin unloads, its recipes stop matching and leave the recipe books.
Crafting evaluation
IServer.EvaluateCrafting(IReadOnlyList<ItemStack?> grid, int width) works out one craft from a 2x2 or 3x3 grid,
without changing the inputs. Pass width * width slots in row-major order, without the result slot; null and empty
stacks are empty slots. It returns null when nothing matches. Special recipes aren't matched.
The CraftingEvaluation it returns has the Output, the RecipeIdentifier, the ConsumedCounts and Remainders
of each slot, and the RecipeRevision. It reserves nothing: check the inventory when you make the craft, and compare
RecipeRevision with IServer.CraftingRecipeRevision to tell whether the recipes changed meanwhile.
IServer.GetRecipe(string identifier) returns a copy of a built-in recipe by its identifier, or null. Vanilla's
identifiers have no namespace (cake); plugins' keep theirs. Custom recipe types use GetRecipes(type) instead.
Custom recipe types
Register a server-side machine recipe type during ConfigureRegistry. Its identifier is in the plugin's namespace;
the returned RecipeType<TRecipe> keeps its numeric identity across reloads. The serializer reads JSON and matches
the machine's input slots:
public override void ConfigureRegistry(IPluginRegistry registry)
{
pressRecipes = registry.RegisterRecipeType("ruby:press", new PressRecipeSerializer());
}
// On the machine's tick, in its block entity, using the plugin's IServer and copies of its input stacks:
var recipe = this.Server?.FindRecipe(pressRecipes, new ItemStack?[] { ingredient });
The example looks recipes up in a mod's block entity; any plugin code with its IServer looks them up the same way.
Implement IRecipeSerializer<TRecipe>: Read(string identifier, JsonElement json) returns an immutable recipe, and
Matches(TRecipe recipe, IReadOnlyList<ItemStack?> inputs) tests one without changing anything. Each file under
data/<namespace>/recipe/<path>.json names its serializer in type, like "type": "ruby:press". Its identifier is
<namespace>:<path>, and the other fields are the serializer's. Clone any JsonElement you keep. A plugin's recipe
files can also use vanilla's recipe types, cooking included. Malformed files are logged and left out.
Ingredients take item identifiers and item tags, like "#c:ingots/iron", in lists too. A tag without a namespace is
minecraft's: "#logs" means "#minecraft:logs". An unknown tag is logged and its recipe left out. Recipes are read
again when tags change on plugin load or unload.
IServer.FindRecipe<TRecipe>(RecipeType<TRecipe> type, IReadOnlyList<ItemStack?> inputs)returns the first matching recipe by identifier, or null.IServer.GetRecipes<TRecipe>(RecipeType<TRecipe> type)returns all the type's recipes in that order, for a machine's screen to list (ObsidianMod's grinder sends them as its menu opens).
Look the recipe up each tick rather than keeping it across reloads. Unloading the plugin removes the type and its recipes.
Custom types stay on the server. Clients aren't sent them, so they don't need a mod. A plugin with a screen of its own
sends the display data itself, over a payload channel or as its menu's open data. A both mod registers its types in
its shared ConfigureRegistry; on the client, RegisterRecipeType gives the type and reads no recipes. The server's
standalone data packs don't load recipe files; only plugins' are read.
Brewing
public override void ConfigureRegistry(IPluginRegistry registry)
{
registry.AddPotionMix(Potion.Awkward, ItemsRegistry.Emerald, Potion.Luck);
registry.AddContainerMix(ItemsRegistry.Potion, ItemsRegistry.Emerald, ItemsRegistry.LingeringPotion);
}
A potion mix brews a bottle of one potion into the same kind of bottle of another; a container mix turns one kind of bottle (a potion, splash or lingering potion) into another of the same potion, as gunpowder does. Vanilla's mixes are tried first, so a plugin can't change what vanilla brews.
- A plugin's mixes are removed when it unloads, and their ingredients may be its own items.
- Plugins can't add potions.
- Clients aren't sent plugins' mixes, so a client first shows the slot refusing a plugin's ingredient, until the server corrects the window.
Tags
Tags are data pack tag files: data/<namespace>/tags/block/<path>.json, tags/item/..., tags/entity_type/...,
tags/worldgen/biome/..., tags/worldgen/placed_feature/... or tags/worldgen/configured_carver/.... They take
values (identifiers, # followed by a tag, or { "id": ..., "required": false }), replace, and NeoForge's
remove.
A file for a vanilla tag adds to it, for example data/minecraft/tags/block/mineable/pickaxe.json to mine a block with
a pickaxe; other files make new tags, or add to Obsidian's convention tags. Tags merge vanilla's,
then the loaded plugins' in load order, then the server's data packs' (see
Data packs and overriding vanilla), again whenever a plugin
loads or unloads. IPluginRegistry.AddToTag adds entries from code. Recipe ingredients can use item tags (see
Custom recipe types).
The generator makes a RubyTags class with a TagKey per tag of the plugin's namespaces:
if (RubyTags.Blocks.Ores.Contains(block))
...
A tag whose required entry is missing keeps its earlier entries rather than disappearing. Players already connected get the changed tags when a plugin loads or unloads.
Biome tags hold vanilla's and plugins' biomes, so a plugin's biome can join #minecraft:is_overworld, and biome
modifiers and level stems can name a plugin's biome tags. Placed feature and configured carver tags stay on the
server, for biomes' features and carvers and for biome modifiers.
Convention tags
Obsidian ships tags in the shared c namespace that NeoForge's and Fabric's mods use, filled with vanilla's entries,
so plugins can name and extend common groups without depending on each other: a biome modifier on #c:is_overworld,
a check of #c:ingots/iron, or a plugin's data/c/tags/block/ores.json (and tags/item/ores.json) adding its ore
to #c:ores.
They act as a built-in data pack between vanilla's tags and plugins' files, so plugins add to them or replace them.
They refer to vanilla's tags where those hold the set, so a plugin's entry in #minecraft:iron_ores is in
#c:ores/iron too. They're kept in Obsidian/Registries/convention_tags.json.
- Blocks and items:
c:oresandc:ores/<material>(coal, copper, diamond, emerald, gold, iron, lapis, redstone, quartz, netherite_scrap),c:ores_in_ground/<stone|deepslate|netherrack>,c:storage_blocks/<material>,c:chests(/wooden,/trapped,/ender,/copper),c:barrels,c:glass_blocks,c:glass_panes,c:stones,c:cobblestones,c:sands,c:gravels,c:obsidians,c:netherracks,c:end_stones,c:bookshelves,c:fences,c:fence_gates,c:stripped_logs,c:stripped_woods,c:concretes,c:glazed_terracottas,c:player_workstations/<crafting_tables|furnaces>andc:dyed/<color>; blocks alsoc:crops. - Items:
c:ingots,c:nuggets,c:gems,c:raw_materialsandc:dusts, each with/<material>,c:dyes/<color>,c:toolsandc:tools/<kind>(bow, brush, crossbow, fishing_rod, igniter, mace, shear, shield, spear, mining_tool, melee_weapon, ranged_weapon),c:armors,c:foods/...,c:crops/...,c:seeds/...,c:rods/...,c:buckets/...,c:bricks/...,c:music_discs,c:potions, and single materials likec:strings,c:leathers,c:slime_ballsandc:ender_pearls. - Entity types:
c:bosses,c:minecarts,c:boats, andc:capturing_not_supportedandc:teleporting_not_supported, which hold the bosses. - Biomes:
c:is_overworld,c:is_nether,c:is_endandc:is_void;c:is_hot(warmer than 0.9, the warm ocean and the nether),c:is_cold(0.3 or colder, and cold oceans),c:is_wetandc:is_dry(no rain, the nether and the end), each with/overworld,/netheror/endparts; andc:is_forest,c:is_ocean,c:is_deep_ocean,c:is_shallow_ocean,c:is_river,c:is_beach,c:is_mountain(/peak,/slope),c:is_desert,c:is_plains,c:is_savanna,c:is_jungle,c:is_snowy,c:is_taiga,c:is_swamp,c:is_badlands,c:is_cave,c:is_mushroomand a few more, likec:is_windsweptandc:is_outer_end_island.
Plugins can't tag fluids, so there are no c: fluid tags.