Trait Registrar
pub trait Registrar:
ArmPosesRegistrar
+ AttributesRegistrar
+ BiomeModifiersRegistrar
+ BlockEntitiesRegistrar
+ BlocksRegistrar
+ CommandArgumentsRegistrar
+ DatapackRegistriesRegistrar
+ DimensionsRegistrar
+ EffectsRegistrar
+ EntitiesRegistrar
+ EntityAttributesRegistrar
+ FluidsRegistrar
+ GameRulesRegistrar
+ ItemsRegistrar
+ KeyMappingsRegistrar
+ MenusRegistrar
+ ParticlesRegistrar
+ RecipeBooksRegistrar
+ RegistrationRefusalRegistrar
+ SettingsRegistrar
+ SpawnPlacementsRegistrar
+ StructuresRegistrar
+ TicketsRegistrar { }Expand description
What a mod’s Hooks::register attaches its parts with, and
declares its block entity types and ticket controllers on. A thing takes one part of each
kind: the same kind twice on one thing refuses the mods at startup, naming both.
Mods call the generic methods on dyn Registrar after requesting registry keys;
they reach the trait’s own methods, one implementation for native and wasm mods.
Implementations§
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn block_entity_type(&mut self, id: &str) -> BlockEntityTypeBuilder<'_>
pub fn block_entity_type(&mut self, id: &str) -> BlockEntityTypeBuilder<'_>
Declare a block entity type in a namespace owned by this mod’s manifest.
pub fn block_entity_part<P>(
&mut self,
kind: &BlockEntityTypeKey,
part: P,
) -> Result<(), BlockEntityPartError>where
P: BlockEntityPart,
pub fn block_entity_part<P>(
&mut self,
kind: &BlockEntityTypeKey,
part: P,
) -> Result<(), BlockEntityPartError>where
P: BlockEntityPart,
Attach a Part to a native type, including one another mod declares later. Vanilla keys are usable for capabilities, but not for native payload Parts.
pub fn block_entity_capability<T>(
&mut self,
key: &CapabilityKey<T>,
kind: &BlockEntityTypeKey,
provider: impl Fn(&mut dyn ServerHost, BlockSide) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
pub fn block_entity_capability<T>(
&mut self,
key: &CapabilityKey<T>,
kind: &BlockEntityTypeKey,
provider: impl Fn(&mut dyn ServerHost, BlockSide) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
Answer capability key for block entity type kind with provider, which gives
a handler for one block entity and side, or none:
r.block_entity_capability(&ITEMS, &press, |_, _| Some(Box::new(PressItems))).
Like NeoForge’s RegisterCapabilitiesEvent, providers add up: in the fork’s chosen order
(NeoForge’s javadoc states none), the game’s own is asked first, then the mods’ in
registration order, and the first to answer wins.
pub fn block_entity_capability_before_game<T>(
&mut self,
key: &CapabilityKey<T>,
kind: &BlockEntityTypeKey,
provider: impl Fn(&mut dyn ServerHost, BlockSide) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
pub fn block_entity_capability_before_game<T>(
&mut self,
key: &CapabilityKey<T>,
kind: &BlockEntityTypeKey,
provider: impl Fn(&mut dyn ServerHost, BlockSide) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
block_entity_capability, asked ahead of the game’s own
provider (NeoForge’s priority), as a mod that replaces how a block entity’s slots are
reached.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn block_part<P>(&mut self, block: BlockKey, part: P)where
P: BlockPart,
pub fn block_part<P>(&mut self, block: BlockKey, part: P)where
P: BlockPart,
Attach part to block block (mymod:shaft, minecraft:oak_log).
pub fn block_part_tag<P>(&mut self, tag: &str, part: P)where
P: BlockPart,
pub fn block_part_tag<P>(&mut self, tag: &str, part: P)where
P: BlockPart,
Attach part to every block in tag tag (minecraft:logs, without #), as each game’s
tags have it when its world opens and after /reload.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn register_command_argument<T>(&mut self, name: &str, argument: T)where
T: CommandArgumentType,
pub fn register_command_argument<T>(&mut self, name: &str, argument: T)where
T: CommandArgumentType,
Register command argument type name (machine or mymod:machine), once, from
Hooks::register: a usage then names it as an argument’s kind,
Command::new("machine use <machine:mymod:machine>"), and the game parses and
completes that argument with it. A name in an unowned namespace, an empty name, and an
id registered twice refuse the mods at startup, naming the mod.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn register_dimension(&mut self, name: &str, settings: DimensionSettings)
pub fn register_dimension(&mut self, name: &str, settings: DimensionSettings)
Register dimension name (pocket or mymod:pocket) once at startup:
every world then has the level mymod:pocket, shaped and generated by
settings, as if a data pack below all the others gave it. A data pack
can replace its level stem or dimension type. The id may use any
manifest-owned namespace; an unowned namespace, an empty name, a name that is no
folder of the world (../x, a//b, capitals), a vanilla
level, an id registered twice, a build height the dimension type codec
refuses and an unknown generator refuse the mods at startup, naming
the mod.
pub fn register_chunk_generator<T>(&mut self, name: &str, generator: T)where
T: ChunkGenerator,
pub fn register_chunk_generator<T>(&mut self, name: &str, generator: T)where
T: ChunkGenerator,
Register chunk generator name (void or mymod:void) once at
startup: a level whose stem names mymod:void then has the terrain of
generator, whose build_terrain
runs on the worldgen worker threads. The level gets no surface, carvers
or features. The id may use any manifest-owned namespace. An unowned
namespace, an empty name, a name that is no folder of the world and an id
registered twice refuse the mods at startup, naming the mod.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn entity_part<P>(&mut self, entity: &str, part: P)where
P: EntityPart,
pub fn entity_part<P>(&mut self, entity: &str, part: P)where
P: EntityPart,
Attach part to the entity type entity (minecraft:zombie): its
EntityPart::register_goals runs at every Mob construction of that
type, spawning or loading, and its goals join the mob’s selectors
beside vanilla’s (#1077).
pub fn entity_capability<T, C>(
&mut self,
key: &EntityCapabilityKey<T, C>,
kind: &str,
provider: impl Fn(&mut dyn ServerHost, EntityRef, C) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
C: 'static,
pub fn entity_capability<T, C>(
&mut self,
key: &EntityCapabilityKey<T, C>,
kind: &str,
provider: impl Fn(&mut dyn ServerHost, EntityRef, C) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
C: 'static,
Answer entity capability key for entity type kind (mymod:robot,
minecraft:player) with provider, which gives a handler for one entity, or none:
r.entity_capability(&ENTITY_ITEMS, "mymod:robot", |_, robot, ()| Some(Box::new(Cargo(robot)))).
Asked as block_entity_capability’s are.
pub fn entity_capability_before_game<T, C>(
&mut self,
key: &EntityCapabilityKey<T, C>,
kind: &str,
provider: impl Fn(&mut dyn ServerHost, EntityRef, C) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
C: 'static,
pub fn entity_capability_before_game<T, C>(
&mut self,
key: &EntityCapabilityKey<T, C>,
kind: &str,
provider: impl Fn(&mut dyn ServerHost, EntityRef, C) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
C: 'static,
entity_capability, asked ahead of the game’s own provider,
as a mod that replaces how a player’s inventory is reached.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn fluid_part<P>(&mut self, fluid: &str, part: P)where
P: FluidPart,
pub fn fluid_part<P>(&mut self, fluid: &str, part: P)where
P: FluidPart,
Attach part to the world fluid fluid, a mod’s, by the id it was declared with.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn item_part_tag<P>(&mut self, tag: &str, part: P)where
P: ItemPart,
pub fn item_part_tag<P>(&mut self, tag: &str, part: P)where
P: ItemPart,
Attach part to every item in tag tag (minecraft:axes, without #).
pub fn item_part<P>(&mut self, item: ItemKey, part: P)where
P: ItemPart,
pub fn item_part<P>(&mut self, item: ItemKey, part: P)where
P: ItemPart,
Attach part to item item (mymod:wrench).
pub fn item_capability<T>(
&mut self,
key: &ItemCapabilityKey<T>,
item: &str,
provider: impl Fn(&mut dyn ServerHost, &ItemPlace) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
pub fn item_capability<T>(
&mut self,
key: &ItemCapabilityKey<T>,
item: &str,
provider: impl Fn(&mut dyn ServerHost, &ItemPlace) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
Answer item capability key for item item (mymod:backpack) with provider, which
gives a handler for the stack at one place, or none: r.item_capability(&ITEM_ITEMS, "mymod:backpack", |_, _| Some(Box::new(Backpack))). Asked as
block_entity_capability’s are.
pub fn item_capability_before_game<T>(
&mut self,
key: &ItemCapabilityKey<T>,
item: &str,
provider: impl Fn(&mut dyn ServerHost, &ItemPlace) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
pub fn item_capability_before_game<T>(
&mut self,
key: &ItemCapabilityKey<T>,
item: &str,
provider: impl Fn(&mut dyn ServerHost, &ItemPlace) -> Option<Box<T>> + Send + Sync + 'static,
)where
T: 'static + ?Sized,
item_capability, asked ahead of the game’s own provider.
§impl dyn Registrar + '_
impl dyn Registrar + '_
pub fn register_structure_type<T>(&mut self, name: &str, ty: T)where
T: StructureType,
pub fn register_structure_type<T>(&mut self, name: &str, ty: T)where
T: StructureType,
Register structure type name (tower or mymod:tower), the way
NeoForge’s registries STRUCTURE_TYPE and STRUCTURE_PIECE register
once at startup: a data pack structure with "type": "modid:tower"
then generates by ty’s code — its own start and pieces, placed by the
game’s own spacing, biome and terrain-adaptation checks. The type’s id
is in a namespace owned by the calling mod’s manifest (mymod:tower); another mod’s
namespace, an empty name and an id registered twice refuse the mods at
startup, naming the mod. ty‘s load_piece is its saved pieces’
loader: keep the type for as long as the game runs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".