API reference Obsidian.API.Plugins
IPluginRegistry interface
public interface IPluginRegistry
In Obsidian.API.
Methods
AddContainerMix(Item, Item, Item)
IPluginRegistry AddContainerMix(Item from, Item ingredient, Item to);Adds a container mix to brewing stands: ingredient brews a from bottle into a to bottle of the same potion, like gunpowder brews potions into splash potions. The rules are IPluginRegistry.AddPotionMix's.
AddPotionMix(Potion, Item, Potion)
IPluginRegistry AddPotionMix(Potion from, Item ingredient, Potion to);Adds a potion mix to brewing stands, like NeoForge's brewing recipes: ingredient brews a bottle of from (a potion, splash or lingering potion) into the same kind of bottle of to. The ingredient slot takes the ingredient, and shift-clicking sends it there.
Remarks
Brewing recipes (vanilla's minecraft:brewing recipes and plugins' recipe files) are tried first, then plugins' mixes in the order they were added, so a mix can't change what a recipe brews. The mix is removed when the plugin unloads; a reload adds it again. Servers that don't brew, like the Obsidian client, ignore mixes.
AddToCreativeTab(string, IEnumerable<Item>, Item)
IPluginRegistry AddToCreativeTab(string tab, IEnumerable<Item> items, Item after = null);Adds items to a creative tab, vanilla's (like minecraft:ingredients) or a plugin's, like NeoForge's BuildCreativeModeTabContentsEvent: at the end of the tab, or right after the last of after's stacks when the tab shows it. The search tab shows every tab's items, so items added to the hotbar, search or inventory tabs, or to a tab that isn't registered, aren't shown. The rules are IPluginRegistry.RegisterCreativeTab's.
Parameters
tab- The tab's identifier.
items- The items to add, in order.
after- The item to add them after, or null for the end.
AddToTag(string, string, IEnumerable<string>)
IPluginRegistry AddToTag(string registry, string tag, params IEnumerable<string> entries);Adds entries to a tag, vanilla's or a new one, like a tag file in the plugin's data/ folder would: the entries are identifiers, or other tags' identifiers after a #, and the tag fails (keeping its earlier entries) when one doesn't exist. The entries are removed when the plugin unloads.
Parameters
registry- The tag's registry:
block,itemorentity_type. tag- The tag's identifier, like
minecraft:mineable/pickaxe. entries- The entries to add, like
myplugin:ruby_oreor#c:ores.
Remarks
Tag files are the usual way, like a NeoForge or Fabric mod's data pack: data/<namespace>/tags/<registry>/<path>.json with values, replace and NeoForge's remove. Clients get the tags when they join.
IPluginRegistry MapCommand(string name, Delegate contextDelegate);IPluginRegistry MapCommand(string name, ValueTaskContextDelegate<CommandContext> contextDelegate);IPluginRegistry MapCommands();MapEvent(Delegate, Priority)
IPluginRegistry MapEvent(Delegate contextDelegate, Priority priority = 0);Registers a handler whose first parameter identifies the event.
Remarks
Handlers may run concurrently; see IEventDispatcher for the threading contract.
MapEvent<TEventArgs>(ValueTaskContextDelegate<TEventArgs>, Priority)
IPluginRegistry MapEvent<TEventArgs>(ValueTaskContextDelegate<TEventArgs> contextDelegate, Priority priority = 0) where TEventArgs : BaseMinecraftEventArgs;Registers a handler for an event.
Remarks
Handlers can run concurrently across levels and connections. Make shared state thread-safe; see IEventDispatcher for the threading contract.
MapEvents()
IPluginRegistry MapEvents();Registers attributed handlers from the plugin's MinecraftEventHandler modules.
Remarks
Handlers may run concurrently; see IEventDispatcher for the threading contract.
MapPayload<TPayload>(PayloadPhase, PayloadDirection, PayloadHandler<TPayload>, string, bool)
IPluginRegistry MapPayload<TPayload>(PayloadPhase phase, PayloadDirection direction, PayloadHandler<TPayload> handler = null, string version = "1", bool optional = false) where TPayload : ICustomPayload<TPayload>;Registers a payload channel for TPayload, negotiated with NeoForge clients during configuration, and checked against the channels Fabric clients register. The registration is removed when the plugin unloads.
Parameters
phase- The connection phase the channel is used in.
direction- Which way the channel carries payloads.
handler- Handles payloads clients send on the channel; required to receive them, and not allowed for a clientbound channel.
version- The channel version; a NeoForge client mod must declare the same one. Fabric channels have no version, so when a reload changes the payload's encoding, change the channel id too.
optional- Whether clients without the channel may still connect.
RegisterAdvancementTrigger<TInstance>(string, AdvancementConditionsCodec<TInstance>)
AdvancementTrigger<TInstance> RegisterAdvancementTrigger<TInstance>(string identifier, AdvancementConditionsCodec<TInstance> conditions);Registers server advancement conditions during ConfigureRegistry; unloaded triggers are inert.
RegisterAttachment<TValue>(string, ComponentCodec<TValue>, ComponentNetworkCodec<TValue>, bool)
AttachmentType<TValue> RegisterAttachment<TValue>(string identifier, ComponentCodec<TValue> codec, ComponentNetworkCodec<TValue> networkCodec = null, bool copyOnDeath = false);Registers detached entity, player and chunk data; a network codec enables optional client sync.
RegisterBiomeRegion(string, string, int, IEnumerable<ClimateBiome>)
IPluginRegistry RegisterBiomeRegion(string identifier, string dimension, int weight, IEnumerable<ClimateBiome> biomes);Registers a biome region with a parameter list of its own, like a data/<namespace>/biome_region file with biomes, which it's read as once the plugin's biomes are registered: where the region is, its biomes are picked from the climate, so every climate should find a fitting biome, oceans and caves included.
Parameters
identifier- The region's identifier, in the plugin's namespace.
dimension- The dimension's level stem, like
minecraft:overworld. weight- How often the region is picked, from 1 to 1000, against the dimension's own layout's 10.
biomes- The region's biomes and their climates, in order, which decides ties.
Remarks
The rules are those of the other overload.
RegisterBiomeRegion(string, string, int, IReadOnlyDictionary<string, string>)
IPluginRegistry RegisterBiomeRegion(string identifier, string dimension, int weight, IReadOnlyDictionary<string, string> replace);Registers a biome region that swaps some of a dimension's biomes for others, like a data/<namespace>/biome_region file with replace, which it's read as once the plugin's biomes are registered.
Parameters
identifier- The region's identifier, in the plugin's namespace.
dimension- The dimension's level stem, like
minecraft:overworld. weight- How often the region is picked, from 1 to 1000, against the dimension's own layout's 10.
replace- The biome generated instead of each biome, or of each biome of a tag (
#c:is_plains).
Remarks
Register regions in PluginBase.ConfigureRegistry. A region that can't be read, like one naming a biome that doesn't exist, is logged and left out, as a file would be. Servers that don't generate worlds, like the Obsidian client, ignore regions.
RegisterBlock(string, BlockProperties)
BlockType RegisterBlock(string identifier, BlockProperties properties = null);Registers a block, like a NeoForge mod's block: its identifier is in the plugin's namespace, it gets the next free block id and its states the next free state ids, and unless BlockProperties.Item is null an item with the same identifier that places it. Registering it again, e.g. when the plugin reloads, gives back the same block with the new properties and behaviour; its state properties can't change until the server restarts.
Parameters
identifier- The block's identifier, like
myplugin:ruby_block. properties- The block's properties and behaviour; the defaults if null.
Returns
The block, to get its states from.
Remarks
Like a plugin's items, its blocks need NeoForge or Fabric clients with a matching mod, and stay registered until the server stops. A world saved with them loads them as air once the plugin is gone.
RegisterBlockEntity<TBlockEntity>(string, IEnumerable<BlockType>)
BlockEntityType RegisterBlockEntity<TBlockEntity>(string identifier, params IEnumerable<BlockType> blocks) where TBlockEntity : BlockEntity, new();Registers a block entity type, like a NeoForge mod's BlockEntityType: blocks get a TBlockEntity wherever they're set, which is saved, ticked and sent to clients (see BlockEntity). Its identifier is in the plugin's namespace, and it gets the next free block entity type id. Registering it again, e.g. when the plugin reloads, gives back the same type with the new blocks and class.
Type parameters
TBlockEntity- The block entity, created with its parameterless constructor.
Parameters
identifier- The type's identifier, like
myplugin:counter. blocks- The plugin's blocks that have the block entity.
Returns
The block entity type.
Remarks
Like a plugin's blocks, its block entity types need NeoForge or Fabric clients with a matching mod, and stay registered until the server stops. When the plugin unloads, its block entities are saved into their chunks and let go of; they're kept as saved until the plugin loads again, which creates them again from what was saved.
IPluginRegistry RegisterCommandArgumentHandler<T>(BaseArgumentParser<T> parser);RegisterComponentType<TValue>(string, ComponentCodec<TValue>, ComponentNetworkCodec<TValue>)
PluginComponentType<TValue> RegisterComponentType<TValue>(string identifier, ComponentCodec<TValue> codec, ComponentNetworkCodec<TValue> networkCodec = null);Registers a data component type, like a NeoForge mod's DataComponentType: stacks hold values of it (see ItemStack.Set), saved with codec under its identifier beside vanilla's components. Its identifier is in the plugin's namespace, and it gets the next free id after vanilla's types. Registering it again, e.g. when the plugin reloads, gives back a type with the same id and the new codecs.
Parameters
identifier- The type's identifier, like
myplugin:charge. codec- Saves and loads the type's values.
networkCodec- Sends the type's values to clients, whose mod registers the same type with the same codec. Without one, the type is the server's own, like vanilla's components that aren't synced: clients never get its values.
Returns
The type, to read and set its values on stacks with.
Remarks
A type with a network codec is synced to clients like a plugin's items, so only NeoForge and Fabric clients with a matching mod can join, and stays synced until the server stops. When the plugin unloads, stacks keep its values as they were saved, saving and loading them unchanged, and its codecs read them again once it's back.
RegisterCreativeTab(string, CreativeTabProperties)
IPluginRegistry RegisterCreativeTab(string identifier, CreativeTabProperties properties);Registers a creative tab, like a NeoForge mod's CreativeModeTab: the Obsidian client shows it in the creative inventory after vanilla's tabs (or CreativeTabProperties.After another), on further pages once vanilla's ten places are full, and its items in the search tab. Its identifier is in the plugin's namespace. The tab and the plugin's additions to tabs (see IPluginRegistry.AddToCreativeTab) are removed when the plugin unloads; a reload registers them again.
Parameters
identifier- The tab's identifier, like
myplugin:rubies. properties- The tab's title, icon, place and items.
Remarks
Like vanilla's and NeoForge's, creative tabs are the client's: they aren't synced, so servers only check the registration, and a player in creative mode can set any item in their inventory whatever the tabs show, which a server accepts like vanilla's. A plugin's items appear in no tab unless it puts them in one.
RegisterCustomStatistic(string)
int RegisterCustomStatistic(string identifier);Registers a synced custom statistic in the plugin's namespace during ConfigureRegistry.
RegisterEntity(string, EntityProperties)
EntityDefinition RegisterEntity(string identifier, EntityProperties properties = null);Registers an entity type, like a NeoForge mod's: its identifier is in the plugin's namespace, and it gets the next free entity type id. Its entities are mobs, projectiles or objects (see EntityKind), spawned with ILevel.SpawnEntity. Registering it again, e.g. when the plugin reloads, gives back the same type with the new properties and behaviour; its kind can't change until the server restarts.
Remarks
Like a plugin's blocks, its entity types need NeoForge or Fabric clients with a matching mod, whose entity is of the same kind, and stay registered until the server stops. Saved entities of a type whose plugin is gone are kept as they were saved.
RegisterFeatureType<TFeature>(string)
IPluginRegistry RegisterFeatureType<TFeature>(string identifier) where TFeature : ConfiguredFeatureBase;Registers a feature type, like a NeoForge mod's Feature: the plugin's configured feature files (and other plugins') name it in their type, and its config object sets its properties.
Type parameters
TFeature- The feature, a class with a parameterless constructor (public or not) whose
ConfiguredFeatureBase.Typereturnsidentifier.
Parameters
identifier- The type's identifier, in the plugin's namespace, like
myplugin:pillar.
Remarks
Register worldgen types in PluginBase.ConfigureRegistry, before the plugin's data is read. They're gone when the plugin unloads, with the features made of them, and a reload registers them again. Feature configs are read like vanilla's: snake_case keys set the matching settable properties, and properties typed as worldgen interfaces (IIntProvider, IBlockStateProvider, IBlockPredicate, IRuleTest, ...) take any type of that kind, vanilla's or a plugin's. Worldgen types run on the server's generation threads, which every level shares: don't block them waiting for asynchronous work, whose continuations would wait for the thread blocked.
RegisterGenerator<TGenerator>(string)
IPluginRegistry RegisterGenerator<TGenerator>(string identifier) where TGenerator : class, ILevelGenerator;Registers a level generator that worlds and dimensions name by its identifier: a world's Generator in worlds.json, or a child dimension's name there. Each level using it gets its own instance, created with the plugin's services, and saves the identifier.
Type parameters
TGenerator- The generator. Its
ILevelGenerator.Idisn't used.
Parameters
identifier- The generator's identifier, in the plugin's namespace.
Remarks
Register generators in PluginBase.ConfigureRegistry. A level using one stops generating new chunks when the plugin unloads, or when the generator throws, and generates again with a new instance once the plugin loads again; until then, and after a restart without the plugin, its chunks already generated still load. Each call into the generator holds a call into the plugin, a chunk at a time.
RegisterItem(string, ItemProperties)
Item RegisterItem(string identifier, ItemProperties properties = null);Registers an item, like a NeoForge mod's item: its identifier is in the plugin's namespace (its id), and it gets the next free item id. Registering it again, e.g. when the plugin reloads, gives back the same item with the new properties and behaviour.
Parameters
identifier- The item's identifier, like
myplugin:ruby. properties- The item's properties and behaviour; the defaults if null.
Returns
The item, to create stacks of.
Remarks
Clients without the plugin can't show its items, so once a plugin registered items, only NeoForge and Fabric clients with a matching mod can join. When the plugin unloads, its items lose their behaviour but stay registered, and synced to clients, until the server stops: stacks of them may still be in inventories and the world.
RegisterMenu(string, int, int)
MenuDefinition RegisterMenu(string identifier, int rows, int columns = 9);Registers a menu type, like a NeoForge mod's MenuType: a grid of slots above the player's inventory, whose identifier is in the plugin's namespace and which gets the next free menu id. Open it for a player with IPlayer.OpenInventoryAsync and a MenuContainer. Registering it again, e.g. when the plugin reloads, gives back the same type; its shape can't change until the server restarts.
Parameters
identifier- The menu type's identifier, like
myplugin:pouch. rows- How many rows of slots it has, from 1 to 6.
columns- How many slots each row has, from 1 to 9.
Returns
The menu type, to create containers of.
Remarks
Like a plugin's blocks, its menu types need NeoForge or Fabric clients with a matching mod, which shows their screens, and stay registered until the server stops.
RegisterParticle(string)
ParticleDefinition RegisterParticle(string identifier);Registers a particle type without options, like a NeoForge mod's SimpleParticleType: its identifier is in the plugin's namespace, and it gets the next free particle type id. Send it to players with ILevel.SpawnParticles. Registering it again, e.g. when the plugin reloads, gives back the same type.
Parameters
identifier- The particle type's identifier, like
myplugin:spark.
Returns
The particle type, which is the particle to send.
Remarks
Like a plugin's blocks, its particle types need NeoForge or Fabric clients with a matching mod, which draws them, and stay registered until the server stops.
RegisterPlacementModifierType<TModifier>(string)
IPluginRegistry RegisterPlacementModifierType<TModifier>(string identifier) where TModifier : PlacementModifierBase;Registers a placement modifier type, like a NeoForge mod's PlacementModifierType: placed feature files name it in a placement entry's type, and the entry's other keys set its properties. The rules are IPluginRegistry.RegisterFeatureType's.
Type parameters
TModifier- The modifier, usually a
SinglePlacementModifierBaseorPlacementFilterBase.
Parameters
identifier- The type's identifier, in the plugin's namespace.
RegisterPortal(string, PortalProperties)
PortalType RegisterPortal(string identifier, PortalProperties properties);Registers a server portal in the plugin's namespace; its behaviour is removed on unload.
Remarks
Portals are the server's: the Obsidian client, running a both mod's ConfigureRegistry, keeps only the portal's identity, and draws its blocks like any.
RegisterRecipeType<TRecipe>(string, IRecipeSerializer<TRecipe>)
RecipeType<TRecipe> RegisterRecipeType<TRecipe>(string identifier, IRecipeSerializer<TRecipe> serializer) where TRecipe : class;Registers a server-side recipe type in this plugin's namespace during ConfigureRegistry. Recipe files name it in type; its serializer and recipes stop matching on unload. Vanilla clients receive no custom types.
RegisterSavedData<TValue>(string, ComponentCodec<TValue>)
SavedDataType<TValue> RegisterSavedData<TValue>(string identifier, ComponentCodec<TValue> codec);Registers persistent world/level data. Call during ConfigureRegistry.
RegisterSound(string, float?)
SoundEvent RegisterSound(string identifier, float? fixedRange = null);Declares a sound event in this plugin's namespace during ConfigureRegistry on either side. Use the returned value with SoundEffectBuilder.Create and IPlayer.SendSoundAsync, or with the client's sound API. Sounds use vanilla's inline holders (identifier and optional fixed range), so no ids or registry sync are needed and a sound-only plugin does not prevent vanilla clients joining. Clients need its resource pack to hear it. Unload removes the declaration; re-register on reload to replace its range.
RegisterWorldgenType<TBase, TValue>(string)
IPluginRegistry RegisterWorldgenType<TBase, TValue>(string identifier) where TValue : class, TBase;Registers a type of another kind of worldgen value that data chooses by its type (or predicate_type, processor_type), like NeoForge's int provider, density function or biome source types: features', noise settings' and level stems' JSON can then name it wherever a TBase is expected. The rules are IPluginRegistry.RegisterFeatureType's, and one identifier may name types of different kinds.
Type parameters
TBase- The kind of value, an interface or abstract class:
IIntProvider,IFloatProvider,IHeightProvider,IBlockStateProvider,IBlockPredicate,IRuleTest, a tree part (TrunkPlacer,FoliagePlacer,RootPlacer,TreeDecorator,FeatureSize),StructureProcessor, a structure type (CustomStructure), a pool element type (CustomPoolElement),IDensityFunction,ISurfaceRule(for anICustomSurfaceRule),ISurfaceCondition(for anICustomSurfaceCondition),BiomeSourceBase, or one of the plugin's own that its features' properties use. TValue- The type to register.
Parameters
identifier- The type's identifier, in the plugin's namespace.
Remarks
A density function whose properties hold density functions, noises or splines must implement IDensityFunction.MapAll to map them, as vanilla's do: generation seeds noises and binds caches through it.