### Start local development server with yarn start Source: https://github.com/architectury/architectury-docs/blob/main/README.md Starts the local development server and opens a browser window. Changes are reflected live without restarting the server. ```bash yarn start ``` -------------------------------- ### Lifecycle Event Registration Examples Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/lifecycle-events.mdx Code examples for registering listeners to the lifecycle events documented in the source. ```APIDOC ## LifecycleEvent.SERVER_STARTED ### Description Registers a listener that is called when the server is ready to accept players. ### Event `LifecycleEvent.SERVER_STARTED` ### Listener Signature `Consumer` ### Parameters - **server** (`MinecraftServer`) - The server instance that has started. ### Example ```java LifecycleEvent.SERVER_STARTED.register(server -> { System.out.println("Server is up with " + server.getPlayerCount() + " players"); }); ``` ``` ```APIDOC ## LifecycleEvent.SERVER_LEVEL_LOAD ### Description Registers a listener that is called when a level is loaded on the server. ### Event `LifecycleEvent.SERVER_LEVEL_LOAD` ### Listener Signature `Consumer` ### Parameters - **level** (`ServerLevel`) - The level that was loaded. ### Example ```java LifecycleEvent.SERVER_LEVEL_LOAD.register(level -> { // initialize per-level data }); ``` ``` ```APIDOC ## LifecycleEvent.TAGS_UPDATED ### Description Registers a listener that is called when tags have finished loading and are ready to use. ### Event `LifecycleEvent.TAGS_UPDATED` ### Listener Signature `TagsUpdated` (functional interface with method `tagsUpdated(RegistryAccess registries, boolean client)`) ### Parameters - **registries** (`RegistryAccess`) - The registry access containing the loaded tags. - **client** (`boolean`) - `true` if this happened on the client as a result of receiving tags from a server, `false` on the server. ### Example ```java LifecycleEvent.TAGS_UPDATED.register((registries, client) -> { // rebuild any caches you keep that are keyed on tags }); ``` ``` ```APIDOC ## LifecycleEvent.DATAPACK_SYNC ### Description Registers a listener that is called when data pack contents are about to be sent to a player. ### Event `LifecycleEvent.DATAPACK_SYNC` ### Listener Signature `Sync` (functional interface with method `sync(ServerPlayer player, boolean joined)`) ### Parameters - **player** (`ServerPlayer`) - The player that data pack contents are about to be sent to. - **joined** (`boolean`) - `true` if the player just joined, `false` if the server reloaded its resources. ### Example ```java LifecycleEvent.DATAPACK_SYNC.register((player, joined) -> { // send your mod's data-driven content to `player` }); ``` ``` -------------------------------- ### Install dependencies with yarn Source: https://github.com/architectury/architectury-docs/blob/main/README.md Installs the project dependencies required for the Docusaurus website. ```bash yarn ``` -------------------------------- ### Run client-only setup with EnvExecutor.runInEnv Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/environment.mdx Runs client-only setup only on the client. The outer supplier is only invoked on the matching side, so client-only classes are never loaded on the server. Always wrap side-only code this way to avoid crashing the dedicated server. ```java // Run client-only setup, only on the client: EnvExecutor.runInEnv(Env.CLIENT, () -> ClientInit::init); ``` -------------------------------- ### ArchitecturyBucketItem Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-base-classes.mdx Documentation for the ArchitecturyBucketItem class, including its constructor, methods, and a usage example. ```APIDOC ## ArchitecturyBucketItem ### Description Creates a bucket item for a fluid. Register it in `Registries.ITEM`, typically with `craftRemainder(Items.BUCKET)`. ### Constructor `ArchitecturyBucketItem(Supplier fluid, Item.Properties properties)` ### Parameters - **fluid** (Supplier) - Required - The fluid this bucket holds. - **properties** (Item.Properties) - Required - The item properties, typically including `craftRemainder(Items.BUCKET)` and `setId(...)`. ### Methods - **getContainedFluid()** - Returns the `Fluid` the bucket holds. (You can also read it through the injected `arch$getFluid()` on any `BucketItem`.) ### Example ```java public static final RegistrySupplier OIL_BUCKET = ITEMS.register("oil_bucket", () -> { ResourceKey key = ResourceKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(MOD_ID, "oil_bucket")); return new ArchitecturyBucketItem(OIL_STILL, new Item.Properties().craftRemainder(Items.BUCKET).setId(key)); }); ``` ``` -------------------------------- ### START_TRACKING Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/entity-events.mdx Notification event fired when a player starts tracking an entity. ```APIDOC ## Event: START_TRACKING ### Description Notification event fired when a player starts tracking an entity. ### Listener Method `startTracking(Entity, ServerPlayer)` ### Cancellable No ``` -------------------------------- ### Use RegistrySupplier.get() and listen() Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/deferred-register.mdx Use a RegistrySupplier to get the registered object with get() or to run a callback once the entry is registered with listen(Consumer). The supplier implements Supplier, so it can be used almost anywhere either is expected. ```java // Use the supplier wherever you need the object: ItemStack stack = new ItemStack(MyMod.RUBY.get()); // React once an entry is fully registered: MyMod.RUBY.listen(item -> { // ... }); ``` -------------------------------- ### Query mods with Platform.isModLoaded(), getMod(), getOptionalMod(), getMods(), getModIds() Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/platform-class.mdx Queries loaded mods: checks if a mod is loaded, gets a mod by ID (throwing if absent), gets an optional mod, and lists all mods or their IDs. getMod and getOptionalMod return a Mod container with metadata. ```java if (Platform.isModLoaded("jei")) { // integrate with JEI } Mod mod = Platform.getMod("mymod"); // throws if absent Optional maybe = Platform.getOptionalMod("jei"); // empty if absent Collection all = Platform.getMods(); Collection ids = Platform.getModIds(); ``` -------------------------------- ### InteractionEvent.CLIENT_PRE_ATTACK Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/interaction-events.mdx Documentation for the CLIENT_PRE_ATTACK interaction event, including its callback signature, parameters, return values, and a Java registration example. ```APIDOC ## InteractionEvent.CLIENT_PRE_ATTACK ### Description Fires once per client tick while the attack key is held or was pressed, before the attack is processed. Interrupting with a false result cancels the attack and any block breaking that would have continued this tick. ### Event `InteractionEvent.CLIENT_PRE_ATTACK` ### Callback Signature `(player, clickCount) -> EventResult` ### Parameters - **player** (`LocalPlayer`) - The client-side player. Always the `LocalPlayer`. - **clickCount** (`int`) - How many times the attack key was pressed since the last tick; zero means the key is merely being held down. ### Return Value - `EventResult.interruptFalse()` - Cancels the attack and any block breaking that would have continued this tick. - `EventResult.pass()` - Allows the attack to proceed normally. ### Example ```java InteractionEvent.CLIENT_PRE_ATTACK.register((player, clickCount) -> { if (shouldSuppressAttack()) { return EventResult.interruptFalse(); } return EventResult.pass(); }); ``` ### Notes - Only fires on the client; the player is always the `LocalPlayer`. - Only register from client-side code. ``` -------------------------------- ### ParticleProviderRegistry.register Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/client-registries/particles.mdx Code examples for registering particle providers using the ParticleProviderRegistry. ```APIDOC ## ParticleProviderRegistry.register(RegistrySupplier>, ParticleProvider) ### Description Registers a `ParticleProvider` for a custom particle type using a `RegistrySupplier`. This overload handles the timing for you and is the safe option, as it listens for registration at the right time. ### Method register ### Parameters - **particleType** (`RegistrySupplier>`) - Required - The `RegistrySupplier` for your particle type. - **provider** (`ParticleProvider`) - Required - The `ParticleProvider` that renders the particle. This form does not need the sprite set. ### Request Example ```java ParticleProviderRegistry.register(MyMod.MY_PARTICLE, MyParticle.Provider::new); ``` ### Notes - Register particle providers **before** `ClientLifecycleEvent.CLIENT_SETUP`. Registering them later can fail to wire up correctly on NeoForge. ``` ```APIDOC ## ParticleProviderRegistry.register(RegistrySupplier>, DeferredParticleProvider) ### Description Registers a `ParticleProvider` for a custom particle type using a `RegistrySupplier` and a `DeferredParticleProvider`. This overload provides the sprite set to build your provider. ### Method register ### Parameters - **particleType** (`RegistrySupplier>`) - Required - The `RegistrySupplier` for your particle type. - **provider** (`DeferredParticleProvider`) - Required - A `DeferredParticleProvider` whose `create(ExtendedSpriteSet)` gives you the sprite set (and, through it, the atlas and sprite list) to build your provider. ### Request Example ```java ParticleProviderRegistry.register(MyMod.MY_PARTICLE, spriteSet -> new MyParticle.Provider(spriteSet)); ``` ### Notes - Register particle providers **before** `ClientLifecycleEvent.CLIENT_SETUP`. Registering them later can fail to wire up correctly on NeoForge. ``` ```APIDOC ## ParticleProviderRegistry.register(ParticleType, ParticleProvider) ### Description Registers a `ParticleProvider` for a custom particle type using a resolved `ParticleType` directly. Use this overload if you are listening for your particle type's registration yourself. ### Method register ### Parameters - **particleType** (`ParticleType`) - Required - The resolved `ParticleType` for your particle type. - **provider** (`ParticleProvider`) - Required - The `ParticleProvider` that renders the particle. ### Notes - Register particle providers **before** `ClientLifecycleEvent.CLIENT_SETUP`. Registering them later can fail to wire up correctly on NeoForge. ``` ```APIDOC ## ParticleProviderRegistry.register(ParticleType, DeferredParticleProvider) ### Description Registers a `ParticleProvider` for a custom particle type using a resolved `ParticleType` and a `DeferredParticleProvider`. Use this overload if you are listening for your particle type's registration yourself and need the sprite set. ### Method register ### Parameters - **particleType** (`ParticleType`) - Required - The resolved `ParticleType` for your particle type. - **provider** (`DeferredParticleProvider`) - Required - A `DeferredParticleProvider` whose `create(ExtendedSpriteSet)` gives you the sprite set (and, through it, the atlas and sprite list) to build your provider. ### Notes - Register particle providers **before** `ClientLifecycleEvent.CLIENT_SETUP`. Registering them later can fail to wire up correctly on NeoForge. ``` -------------------------------- ### Create DeferredRegister instances for items and blocks Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/deferred-register.mdx Create one DeferredRegister per registry, passing your mod id and the vanilla registry key from net.minecraft.core.registries.Registries. This example declares registers for items and blocks. ```java public final class MyMod { public static final String MOD_ID = "mymod"; public static final DeferredRegister ITEMS = DeferredRegister.create(MOD_ID, Registries.ITEM); public static final DeferredRegister BLOCKS = DeferredRegister.create(MOD_ID, Registries.BLOCK); } ``` -------------------------------- ### Register entry into custom registry Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/registrar.mdx Registers an entry into the custom registry created in the previous example, returning a RegistrySupplier. ```java public static final RegistrySupplier FIREBALL = SPELLS.register(Identifier.fromNamespaceAndPath(MyMod.MOD_ID, "fireball"), () -> new MySpell(...)); ``` -------------------------------- ### Access server with GameInstance.getServer() Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/platform-class.mdx Gets the currently running MinecraftServer, or null when none is running (e.g., on the client title screen). This is the cross-platform way to reach the server from anywhere. ```java MinecraftServer server = GameInstance.getServer(); ``` -------------------------------- ### Create a FluidStack with create() and empty() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Create a FluidStack using FluidStack.create() with a fluid and amount, or get the shared empty stack with FluidStack.empty(). The create method has overloads for Fluid, Supplier, or Holder, optionally with a DataComponentPatch. Creating with an EMPTY fluid or amount <= 0 returns the shared empty stack. ```java FluidStack stack = FluidStack.create(Fluids.WATER, FluidStack.bucketAmount()); FluidStack empty = FluidStack.empty(); ``` -------------------------------- ### ClientLevelRenderEvent Events Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/client/client-level-render-events.mdx Documentation for the ClientLevelRenderEvent events, including their listener methods, contexts, and usage examples. ```APIDOC ## ClientLevelRenderEvent.END_EXTRACTION ### Description Fires after every vanilla render state has been extracted, before anything is drawn. Use this to gather per-frame data needed for drawing. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.END_EXTRACTION` ### Listener Method `extract(ExtractionContext)` ### Context `ExtractionContext` extends `RenderContext` and provides: - `level()` - Returns the `ClientLevel`. - `camera()` - Returns the `Camera`. - `deltaTracker()` - Returns the delta tracker. ### Example ```java ClientLevelRenderEvent.END_EXTRACTION.register(context -> { ClientLevel level = context.level(); Camera camera = context.camera(); // work out what you want to draw this frame and stash it }); ``` ``` ```APIDOC ## ClientLevelRenderEvent.AFTER_OPAQUE_BLOCKS ### Description Fires after solid and cutout chunk geometry has been drawn. This event provides a `RenderContext` without a pose stack; set up your own `PoseStack` if needed. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.AFTER_OPAQUE_BLOCKS` ### Listener Method `render(RenderContext)` ### Context `RenderContext` provides: - `levelRenderer()` - Returns the level renderer. - `levelRenderState()` - Returns the level render state. ### Example ```java ClientLevelRenderEvent.AFTER_OPAQUE_BLOCKS.register(context -> { // draw here, setting up your own PoseStack if needed }); ``` ``` ```APIDOC ## ClientLevelRenderEvent.COLLECT_SUBMITS ### Description Fires after entities, block entities, and particles have added their submit nodes, before any of it is drawn. Add your geometry to the submit node collector to have it batched and sorted with the rest. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.COLLECT_SUBMITS` ### Listener Method `collectSubmits(SubmitContext)` ### Context `SubmitContext` extends `StageContext` and provides: - `submitNodeCollector()` - Returns the `SubmitNodeCollector` to add geometry to. ### Example ```java ClientLevelRenderEvent.COLLECT_SUBMITS.register(context -> { SubmitNodeCollector collector = context.submitNodeCollector(); // add your nodes to `collector` }); ``` ``` ```APIDOC ## ClientLevelRenderEvent.AFTER_OPAQUE_FEATURES ### Description Fires after the solid geometry submitted by entities, block entities, and particles has been drawn. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.AFTER_OPAQUE_FEATURES` ### Listener Method `render(StageContext)` ### Context `StageContext` extends `RenderContext` and provides: - `poseStack()` - Returns the `PoseStack`. ### Example ```java ClientLevelRenderEvent.AFTER_OPAQUE_FEATURES.register(context -> { PoseStack poseStack = context.poseStack(); // draw here }); ``` ``` ```APIDOC ## ClientLevelRenderEvent.AFTER_TRANSLUCENT_FEATURES ### Description Fires after the translucent geometry submitted by entities and block entities has been drawn. This does not include translucent particles, which are drawn much later. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.AFTER_TRANSLUCENT_FEATURES` ### Listener Method `render(StageContext)` ### Context `StageContext` extends `RenderContext` and provides: - `poseStack()` - Returns the `PoseStack`. ### Example ```java ClientLevelRenderEvent.AFTER_TRANSLUCENT_FEATURES.register(context -> { PoseStack poseStack = context.poseStack(); // draw here }); ``` ``` ```APIDOC ## ClientLevelRenderEvent.AFTER_TRANSLUCENT_BLOCKS ### Description Fires after translucent chunk geometry has been drawn. Use this to draw your own translucent world geometry. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.AFTER_TRANSLUCENT_BLOCKS` ### Listener Method `render(StageContext)` ### Context `StageContext` extends `RenderContext` and provides: - `poseStack()` - Returns the `PoseStack`. ### Example ```java ClientLevelRenderEvent.AFTER_TRANSLUCENT_BLOCKS.register(context -> { PoseStack poseStack = context.poseStack(); // draw your translucent world geometry here }); ``` ``` ```APIDOC ## ClientLevelRenderEvent.AFTER_TRANSLUCENT_PARTICLES ### Description Fires after translucent particles have been drawn, at the very end of the main pass. This is the last hook in the main pass before clouds, weather, and late debug are drawn. ### Event `dev.architectury.event.events.client.ClientLevelRenderEvent.AFTER_TRANSLUCENT_PARTICLES` ### Listener Method `render(StageContext)` ### Context `StageContext` extends `RenderContext` and provides: - `poseStack()` - Returns the `PoseStack`. ### Example ```java ClientLevelRenderEvent.AFTER_TRANSLUCENT_PARTICLES.register(context -> { PoseStack poseStack = context.poseStack(); // draw here }); ``` ``` -------------------------------- ### Register a command with CommandRegistrationEvent Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/command-events.mdx Registers a command using the CommandRegistrationEvent.EVENT listener. The listener receives a Brigadier dispatcher, a command build context, and a command selection. The example registers a literal 'greet' command that sends a success message. ```java CommandRegistrationEvent.EVENT.register((dispatcher, registry, selection) -> { dispatcher.register(Commands.literal("greet") .executes(context -> { context.getSource().sendSuccess(() -> Component.literal("Hello!"), false); return 1; })); }); ``` -------------------------------- ### LightningEvent.STRIKE Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/lightning-events.mdx Documentation for the LightningEvent.STRIKE event, including its listener method signature and an example of registering a listener. ```APIDOC ## LightningEvent.STRIKE ### Description Registers a listener for the `STRIKE` event, which is fired after a lightning bolt has gathered the entities it will affect. The listener can inspect or modify the list of entities that will be struck. ### Event `LightningEvent.STRIKE` ### Listener Method `onStrike(LightningBolt bolt, Level level, Vec3 pos, List toStrike)` ### Parameters - **bolt** (LightningBolt) - The lightning bolt entity. - **level** (Level) - The level where the strike occurs. - **pos** (Vec3) - The position of the strike. - **toStrike** (List) - The list of entities that will be affected by the lightning. This list can be modified. ### Example ```java LightningEvent.STRIKE.register((bolt, level, pos, toStrike) -> { // e.g. stop the lightning from hitting tamed animals toStrike.removeIf(entity -> entity instanceof TamableAnimal animal && animal.isTame()); }); ``` ``` -------------------------------- ### Look up entries and ids with Registrar Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/registrar.mdx Shows how to look up entries by id and get the id of an entry using a Registrar. The comment indicates the expected output for the diamond id. ```java Registrar items = RegistrarManager.get(MyMod.MOD_ID).get(Registries.ITEM); Item dirt = items.get(Identifier.withDefaultNamespace("dirt")); Identifier id = items.getId(Items.DIAMOND); // minecraft:diamond ``` -------------------------------- ### Register ArchitecturyBucketItem with craftRemainder and setId Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-base-classes.mdx Constructor signature for ArchitecturyBucketItem and a registration example for a bucket item. The registration uses craftRemainder(Items.BUCKET) and setId(...) which is required for every item/block registration. The block, bucket, and fluids behave identically on Fabric and NeoForge. ```java ArchitecturyBucketItem(Supplier fluid, Item.Properties properties) ``` ```java public static final RegistrySupplier OIL_BUCKET = ITEMS.register("oil_bucket", () -> { ResourceKey key = ResourceKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(MOD_ID, "oil_bucket")); return new ArchitecturyBucketItem(OIL_STILL, new Item.Properties().craftRemainder(Items.BUCKET).setId(key)); }); ``` -------------------------------- ### Migrate MCP mappings to Yarn Source: https://github.com/architectury/architectury-docs/blob/main/loom/using_mcp.mdx Run this Gradle command to migrate your MCP-mapped project to Yarn mappings. The version '1.16.5+build.3' is just an example; replace it with the Yarn build you want to use. ```bash gradlew migrateMappings --mappings "1.16.5+build.3" ``` -------------------------------- ### Access widener example in architectury.common.json Source: https://github.com/architectury/architectury-docs/blob/main/loom/architectury_common_json.mdx Specifies an access widener file using the accessWidener key. This is mainly useful for libraries that declare transitive access wideners. The access widener file should be written in your project's mappings (e.g., Yarn or Mojang mappings). ```json { "accessWidener": "my_mod.accesswidener" } ``` -------------------------------- ### Interface injection example in architectury.common.json Source: https://github.com/architectury/architectury-docs/blob/main/loom/architectury_common_json.mdx Adds an injected_interfaces object to architectury.common.json. The keys are Minecraft class names in Intermediary mappings, and the values are arrays of interfaces to inject. All type names must be in JVM internal format. ```json { "injected_interfaces": { "net/minecraft/class_1234": ["com/example/MyInterface"] } } ``` -------------------------------- ### Get holder with arch$holder() Source: https://github.com/architectury/architectury-docs/blob/main/docs/other/injected-interfaces.mdx Retrieves the Holder for an entry, for example when reconstructing a value from a stored identifier. ```java Holder holder = BuiltInRegistries.FLUID.getValue(savedId).arch$holder(); ``` -------------------------------- ### Gradle build and run commands Source: https://github.com/architectury/architectury-docs/blob/main/docs/getting-started/project-structure.mdx Commands to build all platform jars and launch clients/servers for each loader. ```bash # Build every platform jar (outputs to fabric/build/libs and neoforge/build/libs) ./gradlew build # Launch a development client for a specific loader ./gradlew :fabric:runClient ./gradlew :neoforge:runClient # Launch a dedicated server ./gradlew :fabric:runServer ./gradlew :neoforge:runServer ``` -------------------------------- ### NeoForge entrypoint (MyModNeoForge.java) Source: https://github.com/architectury/architectury-docs/blob/main/docs/getting-started/project-structure.mdx Uses @Mod annotation and constructor to call MyMod.init(). ```java @Mod(MyMod.MOD_ID) public final class MyModNeoForge { public MyModNeoForge() { MyMod.init(); } } ``` -------------------------------- ### Fabric entrypoint (MyModFabric.java) Source: https://github.com/architectury/architectury-docs/blob/main/docs/getting-started/project-structure.mdx Implements ModInitializer and calls MyMod.init() from onInitialize(). ```java public final class MyModFabric implements ModInitializer { @Override public void onInitialize() { MyMod.init(); } } ``` -------------------------------- ### Get registry name with arch$registryName() Source: https://github.com/architectury/architectury-docs/blob/main/docs/other/injected-interfaces.mdx Shows the basic usage of an injected method: calling arch$registryName() on an item instance to get its Identifier. No registration or import is required. ```java Identifier id = MyMod.RUBY.get().arch$registryName(); ``` -------------------------------- ### Get bucket amount using FluidStack.bucketAmount() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Use FluidStack.bucketAmount() to get the platform-specific amount for one bucket. The unit differs by loader: 1000 on NeoForge, 81000 on Fabric. Never hard-code 1000. ```java long oneBucket = FluidStack.bucketAmount(); long halfBucket = FluidStack.bucketAmount() / 2; ``` -------------------------------- ### ItemEntityHooks.lifespan Source: https://github.com/architectury/architectury-docs/blob/main/docs/hooks/block-and-entity-hooks.mdx Gets the lifespan of an item entity. ```APIDOC ## ItemEntityHooks.lifespan ### Description Returns the item entity's lifespan in ticks as an `IntValue` you can read and modify. The default is `6000`. ### Method lifespan ### Signature `IntValue lifespan(ItemEntity itemEntity)` ### Parameters - **itemEntity** (ItemEntity) - Required - The item entity whose lifespan to retrieve. ### Return Value - **IntValue** - The lifespan in ticks, modifiable. ### Usage Example ```java IntValue lifespan = ItemEntityHooks.lifespan(itemEntity); ``` ### Notes - **Changed in 22.0**: On Fabric this was a read-only value of `6000` before Architectury API **22.0**; writes were silently discarded. It is now backed by a persistent entity attachment, so setting it works on both loaders. ``` -------------------------------- ### Convert template to FluidStack with create() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack-template.mdx Resolves the holder and builds a usable FluidStack with the same amount and components. ```java FluidStack stack = template.create(); ``` -------------------------------- ### MenuRegistry.openMenu Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/menus.mdx Opens a plain menu for a server player with no extra data. ```APIDOC ## MenuRegistry.openMenu ### Description Opens a plain menu for a server player with no extra data. ### Method `openMenu(ServerPlayer, MenuProvider)` ### Parameters - `player` (ServerPlayer) - Required - The server player to open the menu for. - `provider` (MenuProvider) - Required - Provides the menu and display name. ### Example ```java MenuRegistry.openMenu(serverPlayer, myProvider); ``` ``` -------------------------------- ### FluidStack.getFluid() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Instance method to get the fluid in the stack. ```APIDOC ## FluidStack.getFluid() ### Description Returns the fluid contained in this stack, or Fluids.EMPTY if empty. ### Method Instance method ### Endpoint `FluidStack.getFluid()` ### Parameters None ### Returns - **Fluid** - The fluid in the stack. ### Example ```java Fluid fluid = stack.getFluid(); ``` ``` -------------------------------- ### Get environment, dev flag, and Minecraft version Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/platform-class.mdx Gets the current environment (client or server), whether running in a development environment, and the Minecraft version. getEnvironment() returns Architectury's Env; use EnvExecutor to run code only on one side. ```java Env env = Platform.getEnvironment(); // Env.CLIENT or Env.SERVER boolean dev = Platform.isDevelopmentEnvironment(); String mcVersion = Platform.getMinecraftVersion(); ``` -------------------------------- ### Add configurations to neoforge build.gradle Source: https://github.com/architectury/architectury-docs/blob/main/loom/neoforge_migration.mdx Defines the common, forgeLike, and shadowCommon configurations and extends compile/runtime classpaths and development configurations accordingly. ```groovy configurations { common forgeLike shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. compileClasspath.extendsFrom common, forgeLike runtimeClasspath.extendsFrom common, forgeLike developmentNeoForge.extendsFrom common developmentForgeLike.extendsFrom forgeLike } ``` -------------------------------- ### FluidStack.empty() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Static method to get the shared empty FluidStack. ```APIDOC ## FluidStack.empty() ### Description Returns the shared empty FluidStack. ### Method Static factory method ### Endpoint `FluidStack.empty()` ### Parameters None ### Returns - **FluidStack** - The shared empty stack. ### Example ```java FluidStack empty = FluidStack.empty(); ``` ``` -------------------------------- ### Build static site with yarn build Source: https://github.com/architectury/architectury-docs/blob/main/README.md Generates static content into the `build` directory, which can be served using any static content hosting service. ```bash yarn build ``` -------------------------------- ### FluidStackTemplate.create() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack-template.mdx Resolves the holder and builds a usable FluidStack with the same amount and components. ```APIDOC ## FluidStackTemplate.create() ### Description Resolves the holder and builds a usable FluidStack with the same amount and components. ### Method INSTANCE ### Endpoint FluidStackTemplate.create() ### Parameters None ### Request Example ```java FluidStack stack = template.create(); ``` ### Response #### Success Response - **stack** (FluidStack) - The created FluidStack. #### Response Example ```java FluidStack stack = template.create(); ``` ``` -------------------------------- ### Configure forgeLike() with platformPackage Source: https://github.com/architectury/architectury-docs/blob/main/loom/neoforge_migration.mdx Sets up the forgelike subproject to target both forge and neoforge, and applies platformPackage to share packages between them. ```groovy architectury { forgeLike(["forge", "neoforge"]) { it.platformPackage "neoforge", "forge" } } ``` -------------------------------- ### Call EventFactory.create* methods with no arguments Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/creating-events.mdx Warns that the create* methods must be called with no arguments; passing an argument throws at startup. An overload taking the listener Class is available for explicit typing. ```java Event EVENT = EventFactory.createLoop(); // correct Event EVENT = EventFactory.createLoop(myThing); // throws at startup ``` -------------------------------- ### FluidStack.getName() / getTranslationKey() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Instance methods to get the display name or translation key. ```APIDOC ## FluidStack.getName() / getTranslationKey() ### Description Returns the display name or translation key of the fluid. ### Method Instance methods ### Endpoint `FluidStack.getName()` `FluidStack.getTranslationKey()` ### Parameters None ### Returns - **Component** - The display name (for getName). - **String** - The translation key (for getTranslationKey). ### Example ```java Component name = stack.getName(); String key = stack.getTranslationKey(); ``` ``` -------------------------------- ### Register server and level lifecycle events Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/lifecycle-events.mdx Registers listeners for SERVER_STARTED and SERVER_LEVEL_LOAD. SERVER_STARTED fires when the server is ready to accept players, and SERVER_LEVEL_LOAD fires when a level is loaded. Use these to initialize server-side state and per-level data. ```java LifecycleEvent.SERVER_STARTED.register(server -> { System.out.println("Server is up with " + server.getPlayerCount() + " players"); }); LifecycleEvent.SERVER_LEVEL_LOAD.register(level -> { // initialize per-level data }); ``` -------------------------------- ### FluidStack.getAmount() / setAmount(long) Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Instance methods to get or set the fluid amount. ```APIDOC ## FluidStack.getAmount() / setAmount(long) ### Description Gets or sets the amount of fluid in the stack. ### Method Instance methods ### Endpoint `FluidStack.getAmount()` `FluidStack.setAmount(long amount)` ### Parameters - **amount** (long) - Required - The new amount. ### Returns - **long** - The current amount (for getAmount). ### Example ```java long amount = stack.getAmount(); stack.setAmount(1000); ``` ``` -------------------------------- ### FluidStack.bucketAmount() Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Static method to get the platform-specific amount for one bucket of fluid. ```APIDOC ## FluidStack.bucketAmount() ### Description Returns the amount of fluid in one bucket for the current platform. Use this instead of hard-coding a value, as the unit differs between loaders (1000 on NeoForge, 81000 on Fabric). ### Method Static method ### Endpoint `FluidStack.bucketAmount()` ### Parameters None ### Returns - **long** - The amount of fluid in one bucket for the current platform. ### Example ```java long oneBucket = FluidStack.bucketAmount(); long halfBucket = FluidStack.bucketAmount() / 2; ``` ``` -------------------------------- ### EntityEvent.START_TRACKING Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/entity-events.mdx Fires when an entity enters a player's tracking range, the right moment to send that player custom data for the entity. ```APIDOC ## EntityEvent.START_TRACKING ### Description Fires when an entity enters a player's tracking range, which is the right moment to send that player any custom data you keep for the entity. ### Method Register ### Endpoint EntityEvent.START_TRACKING ### Parameters - **entity** (Entity) - The entity that started being tracked. - **player** (Player) - The player who started tracking the entity. ### Request Example ```java EntityEvent.START_TRACKING.register((entity, player) -> { // send `player` your custom data for `entity` }); ``` ### Response #### Success Response - **EventResult** - The result of the event. Use `EventResult.pass()` to allow. ``` -------------------------------- ### Get Registrar for a registry key Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/registrar.mdx Retrieves a Registrar for a specific registry by its key, here the item registry. ```java Registrar items = registries.get(Registries.ITEM); ``` -------------------------------- ### EntityEvent.MOUNT Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/entity-events.mdx Fires when an entity starts or stops riding another entity. Use to cancel mounting or dismounting. ```APIDOC ## EntityEvent.MOUNT ### Description Fires when an entity starts or stops riding another entity. `mounting` is `true` when mounting and `false` when dismounting; when dismounting, `vehicle` is the vehicle being left. Interrupting with a false result stops the entity from mounting, or keeps it on its vehicle when dismounting. ### Method Register ### Endpoint EntityEvent.MOUNT ### Parameters - **entity** (Entity) - The entity that is mounting or dismounting. - **vehicle** (Entity) - The vehicle being mounted or dismounted. - **mounting** (boolean) - `true` if mounting, `false` if dismounting. ### Request Example ```java EntityEvent.MOUNT.register((entity, vehicle, mounting) -> { if (mounting && vehicle instanceof Boat && entity instanceof Creeper) { return EventResult.interruptFalse(); // creepers may not ride boats } return EventResult.pass(); }); ``` ### Response #### Success Response - **EventResult** - The result of the event. Use `EventResult.interruptFalse()` to cancel, or `EventResult.pass()` to allow. ``` -------------------------------- ### FluidStack.isFluidStackEqual(...) / isFluidEqual(...) / isComponentEqual(...) Source: https://github.com/architectury/architectury-docs/blob/main/docs/fluids/fluid-stack.mdx Instance methods to compare FluidStacks. ```APIDOC ## FluidStack.isFluidStackEqual(FluidStack) / isFluidEqual(FluidStack) / isComponentEqual(FluidStack) ### Description Comparison methods: check if two stacks are equal in fluid, amount, and components; only fluid; or only components. ### Method Instance methods ### Endpoint `FluidStack.isFluidStackEqual(FluidStack other)` `FluidStack.isFluidEqual(FluidStack other)` `FluidStack.isComponentEqual(FluidStack other)` ### Parameters - **other** (FluidStack) - Required - The stack to compare with. ### Returns - **boolean** - True if the stacks match the comparison criteria. ### Example ```java boolean equal = stack.isFluidStackEqual(other); ``` ``` -------------------------------- ### Project structure after adding modules Source: https://github.com/architectury/architectury-docs/blob/main/docs/getting-started/setup.mdx The expected project structure after creating the common, fabric, and neoforge modules. The common module holds shared code and resources, while each platform module contains its entrypoint. ```text my-mod/ ├── common/ -> shared code + shared resources ├── fabric/ -> Fabric entrypoint (fabric.mod.json + initializer) ├── neoforge/ -> NeoForge entrypoint (neoforge.mods.toml + initializer) ├── gradle.properties ├── settings.gradle └── build.gradle ``` -------------------------------- ### EventResult Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/event-results.mdx Documentation for the EventResult class, including factory methods, inspection methods, and an example of cancelling a block break. ```APIDOC ## EventResult ### Description Represents the result of an event listener, indicating whether to interrupt further evaluation and an optional outcome (true/false/no outcome). ### Factory Methods | Method | Interrupts? | Outcome | Description | |---|---|---|---| | `EventResult.pass()` | no | none | Continue without affecting the event outcome. | | `EventResult.interruptDefault()` | yes | none | Stop other listeners and use the default/vanilla outcome. | | `EventResult.interruptTrue()` | yes | `true` | Stop and force a success/allow outcome. | | `EventResult.interruptFalse()` | yes | `false` | Stop and force a fail/deny outcome (commonly cancel). | | `EventResult.interrupt(Boolean)` | yes | value | Programmatic form; `null` means no outcome. | | `EventResult.fromMinecraft(InteractionResult)` | depends | depends | Convert a vanilla `InteractionResult` into an `EventResult`. | ### Inspection Methods - `interruptsFurtherEvaluation()` - Returns whether the chain was interrupted. - `isPresent()` - Returns whether the result carries an outcome. - `isEmpty()` - Returns whether the result has no outcome. - `isTrue()` - Returns whether the outcome is `true`. - `isFalse()` - Returns whether the outcome is `false`. - `value()` - Returns the Boolean outcome, or `null` if none. - `asMinecraft()` - Converts the result back to a vanilla `InteractionResult`. ### Example: Cancelling a block break ```java BlockEvent.BREAK.register((level, pos, state, player) -> { if (state.is(Blocks.BEDROCK) && !player.hasPermissions(2)) { // Stop here and deny the break - vanilla won't destroy the block. return EventResult.interruptFalse(); } // Not our concern; let other listeners and vanilla decide. return EventResult.pass(); }); ``` ``` -------------------------------- ### Send welcome message on player join with PlayerEvent.PLAYER_JOIN Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/player-events.mdx Registers a listener for the PLAYER_JOIN event to send a welcome message to the player when they join the server. ```java PlayerEvent.PLAYER_JOIN.register(player -> { player.sendSystemMessage(Component.literal("Welcome, " + player.getName().getString() + "!")); }); ``` -------------------------------- ### Get Biome Properties with BiomeHooks Source: https://github.com/architectury/architectury-docs/blob/main/docs/hooks/biome-hooks.mdx Retrieves a cross-platform view of a biome's properties using the BiomeHooks class. ```java BiomeProperties properties = BiomeHooks.getBiomeProperties(biome); ``` -------------------------------- ### KeyMappingRegistry.register(KeyMapping) Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/client-registries/key-mappings.mdx Registers a key mapping so it appears in the vanilla Controls screen. ```APIDOC ## KeyMappingRegistry.register(KeyMapping) ### Description Registers a configurable hotkey (a `KeyMapping`) that appears in the vanilla Controls screen. Must be called from client-side code. ### Method register ### Parameters - **mapping** (KeyMapping) - Required - The key mapping to register. ### Request Example ```java KeyMappingRegistry.register(MY_KEY); ``` ### Response No return value. ``` -------------------------------- ### Register a ClientTooltipComponent factory Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/client-registries/tooltip-components.mdx Registers a factory that maps a TooltipComponent data class to a ClientTooltipComponent for drawing. The first argument is the data class, the second is a factory constructor reference. Must be called from client-side code. ```java ClientTooltipComponentRegistry.register(MyTooltipData.class, MyClientTooltipComponent::new); ``` -------------------------------- ### PackRepositoryHooks.addSource Source: https://github.com/architectury/architectury-docs/blob/main/docs/hooks/other-hooks.mdx Registers an extra pack source into a pack repository, for example to ship a built-in resource or data pack with your mod. ```APIDOC ## PackRepositoryHooks.addSource ### Description Registers an extra pack source into a pack repository, for example to ship a built-in resource or data pack with your mod. ### Method addSource ### Signature `PackRepositoryHooks.addSource(PackRepository, RepositorySource)` ### Parameters - **packRepository** (PackRepository) - Required - The pack repository to add the source to. - **myRepositorySource** (RepositorySource) - Required - The repository source to register. ### Example ```java PackRepositoryHooks.addSource(packRepository, myRepositorySource); ``` ``` -------------------------------- ### Return a value with EnvExecutor.getInEnv Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/environment.mdx Returns an Optional from the given side, empty on the other side. Use this to get a value that is only available on one side. ```java Optional screen = EnvExecutor.getInEnv(Env.CLIENT, () -> () -> new MyScreen()); ``` -------------------------------- ### Register item with arch$tab() Source: https://github.com/architectury/architectury-docs/blob/main/docs/other/injected-interfaces.mdx Registers an item and assigns it to a creative tab using arch$tab() on Item.Properties. Requires setId() with a ResourceKey and a RegistrySupplier for the tab. ```java public static final RegistrySupplier RUBY = ITEMS.register("ruby", () -> { ResourceKey key = ResourceKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(MyMod.MOD_ID, "ruby")); return new Item(new Item.Properties().arch$tab(MyMod.MY_TAB).setId(key)); }); ``` -------------------------------- ### Get RegistrarManager with mod id Source: https://github.com/architectury/architectury-docs/blob/main/docs/registries/common-registries/registrar.mdx Obtains the per-mod entry point to registries using the mod id. This is the first step before accessing any registrar. ```java RegistrarManager registries = RegistrarManager.get(MyMod.MOD_ID); ``` -------------------------------- ### Register CLIENT_STARTED event listener Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/client/client-lifecycle-events.mdx Registers a listener for the CLIENT_STARTED event, which fires after the client has initialized. The listener receives the Minecraft instance. This event is client-only and should be registered from client-side code. ```java ClientLifecycleEvent.CLIENT_STARTED.register(minecraft -> { // the client is ready }); ``` -------------------------------- ### Add a pack source with PackRepositoryHooks.addSource Source: https://github.com/architectury/architectury-docs/blob/main/docs/hooks/other-hooks.mdx Registers an extra pack source into a pack repository, for example to ship a built-in resource or data pack with your mod. ```java PackRepositoryHooks.addSource(packRepository, myRepositorySource); ``` -------------------------------- ### Get the mod's event bus directly with EventBusesHooks.getModEventBus Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/neoforge-event-bus.mdx Retrieves the mod's IEventBus directly, returning an empty Optional if the mod has no container. ```java Optional bus = EventBusesHooks.getModEventBus("modid"); ``` -------------------------------- ### Add Architectury Maven repository and include subprojects in settings.gradle Source: https://github.com/architectury/architectury-docs/blob/main/docs/getting-started/setup.mdx Adds the Architectury Maven repository to settings.gradle and includes the common, fabric, and neoforge subprojects. ```groovy pluginManagement { repositories { maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } maven { url "https://maven.neoforged.net/releases" } gradlePluginPortal() } } rootProject.name = 'modid' include 'common' include 'fabric' include 'neoforge' ``` -------------------------------- ### Create a cancellable event with EventFactory.createEventResult() Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/creating-events.mdx Example of a cancellable event using createEventResult(). The firing code checks the returned EventResult and stops if a listener cancelled the cast. ```java public interface SpellCastEvent { Event EVENT = EventFactory.createEventResult(); EventResult onCast(Player player, Spell spell); } ``` ```java // Firing it - respect a listener that cancelled the cast. EventResult result = SpellCastEvent.EVENT.invoker().onCast(player, spell); if (result.isFalse()) { return; // a listener denied the cast } // ...otherwise proceed ``` -------------------------------- ### Add Architectury Loom plugin to root build.gradle Source: https://github.com/architectury/architectury-docs/blob/main/docs/getting-started/setup.mdx Adds the Architectury Loom plugin to the root build.gradle. Use loom-no-remap because starting with Minecraft 26.1, Minecraft is no longer obfuscated. ```groovy plugins { id "dev.architectury.loom-no-remap" version "1.17-SNAPSHOT" apply false } ``` -------------------------------- ### Register EQUIPMENT_CHANGE and START_TRACKING events Source: https://github.com/architectury/architectury-docs/blob/main/docs/events/common/entity-events.mdx Registers handlers for EQUIPMENT_CHANGE and START_TRACKING. EQUIPMENT_CHANGE fires on equipment changes, START_TRACKING fires when an entity enters a player's tracking range. ```java EntityEvent.EQUIPMENT_CHANGE.register((entity, slot, previousStack, currentStack) -> { if (slot == EquipmentSlot.HEAD) { // the entity changed its helmet } }); ``` ```java EntityEvent.START_TRACKING.register((entity, player) -> { // send `player` your custom data for `entity` }); ``` -------------------------------- ### Get fluid from bucket with arch$getFluid() Source: https://github.com/architectury/architectury-docs/blob/main/docs/other/injected-interfaces.mdx Checks if an item is a BucketItem and retrieves the fluid it contains using arch$getFluid(). Works for vanilla buckets and custom fluid buckets. ```java if (stack.getItem() instanceof BucketItem bucket) { Fluid fluid = bucket.arch$getFluid(); } ``` -------------------------------- ### Mod.getLogoFile(int preferredSize) Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/mod.mdx Returns an Optional containing the path to the logo, if present. The size hint is only used on Fabric. ```APIDOC ## Mod.getLogoFile(int preferredSize) ### Description Returns an Optional containing the path to the logo. The size hint is only used on Fabric. ### Method GET ### Endpoint Mod.getLogoFile(int preferredSize) ### Parameters #### Path Parameters - **preferredSize** (int) - Required - The preferred size of the logo. ### Response #### Success Response (200) - **Optional** - The path to the logo, if present. #### Response Example ```java Optional logo = mod.getLogoFile(128); ``` ``` -------------------------------- ### Resolve config file with Platform.getConfigFolder() Source: https://github.com/architectury/architectury-docs/blob/main/docs/platform/platform-class.mdx Resolves a file inside the config folder. All folder methods return an absolute, normalized java.nio.file.Path. ```java Path config = Platform.getConfigFolder().resolve("mymod.json"); ```