### Color Registration Usage Example Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Demonstrates registering custom color providers for both blocks and items within a client-side setup class. ```java @Environment(EnvType.CLIENT) public class MyColorSetup { public static void setupColors() { // Register block color based on block state ColorHandlerRegistry.registerBlockColors( (state, level, pos, index) -> { // Example: vary color by position return index == 0 ? 0xFF0000 : 0xFFFFFF; // Red for layer 0, white for others }, MyBlocks.COLOR_CHANGING_BLOCK.get() ); // Register item color based on item stack ColorHandlerRegistry.registerItemColors( (stack, index) -> { // Example: use NBT data for color if (stack.hasTag()) { return stack.getTag().getInt("color"); } return 0xFFFFFF; }, MyItems.COLOR_ITEM.get() ); } } ``` -------------------------------- ### Registering Block Render Types Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Example showing how to register blocks with a specific render type, such as cutout, within a client setup class. ```java @Environment(EnvType.CLIENT) public class MyClientSetup { public static void setupRendering() { // Register blocks with cutout render type RenderTypeRegistry.register( RenderType.cutout(), MyContent.GLASS_BLOCK.get(), MyContent.LEAVES_BLOCK.get() ); } } ``` -------------------------------- ### FluidStack Usage Example Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/05-fluids-and-items.md Demonstrates creating, manipulating, and modifying NBT data for fluid stacks. ```java public class FluidHandling { public static void example() { // Create a water stack (1000 mB = 1 bucket) FluidStack water = FluidStack.create( Fluids.WATER, FluidStack.bucketAmount() ); // Create with NBT data CompoundTag tag = new CompoundTag(); tag.putString("color", "blue"); FluidStack customFluid = FluidStack.create( Fluids.WATER, 500, tag ); // Manipulate amount customFluid.grow(250); System.out.println("Amount: " + customFluid.getAmount() + " mB"); // Work with NBT CompoundTag fluidTag = customFluid.getOrCreateTag(); fluidTag.putInt("custom", 42); // Copy for independent manipulation FluidStack copy = customFluid.copy(); copy.setAmount(1000); } } ``` -------------------------------- ### Configure Client-Side Setup Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Registers renderers, key bindings, and lifecycle event listeners for the client environment. ```java @Environment(EnvType.CLIENT) public class ClientSetup { public static void init() { // Register custom renderers registerRenderers(); // Register key bindings registerKeybinds(); // Listen to client events ClientLifecycleEvent.CLIENT_STARTED.register(ClientSetup::onClientStarted); ClientTickEvent.CLIENT_PRE.register(ClientSetup::onClientTick); } private static void registerRenderers() { BlockEntityRendererRegistry.register( MyBlockEntities.MY_BE.get(), context -> new MyBlockEntityRenderer(context) ); EntityRendererRegistry.register( MyEntities.MY_ENTITY.get(), context -> new MyEntityRenderer(context) ); RenderTypeRegistry.register( RenderType.cutout(), MyBlocks.GLASS_PANE.get(), MyBlocks.LEAVES.get() ); } private static void registerKeybinds() { KeyMapping myKey = new KeyMapping( "key.mymod.ability", GLFW.GLFW_KEY_V, "key.categories.mymod" ); KeyMappingRegistry.register(myKey); } private static void onClientStarted() { // Client initialized } private static void onClientTick() { // Called every client tick } } ``` -------------------------------- ### DeferredRegister Usage Example Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Demonstrates creating a register, registering items and blocks, and triggering registration during mod initialization. ```java public class MyContent { public static final DeferredRegister ITEMS = DeferredRegister.create("mymod", Registries.ITEM); public static final RegistrySupplier CUSTOM_ITEM = ITEMS.register("custom_item", () -> new Item(new Item.Properties())); public static final RegistrySupplier CUSTOM_BLOCK = ITEMS.register("custom_block", () -> new Block(BlockBehaviour.Properties.of())); } // In your mod initialization public class MyMod { public static void init() { MyContent.ITEMS.register(); } } ``` -------------------------------- ### Mod Initialization Pattern Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Standard entry point structure for registering content, events, and client-specific setup. ```java public class MyMod { public static final String MOD_ID = "mymod"; public static void init() { MyContent.register(); EventListeners.register(); MyNetworking.init(); } @Environment(EnvType.CLIENT) public static void initClient() { ClientSetup.init(); } } ``` -------------------------------- ### Send Packets from Client Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Example of sending a packet from the client to the server. ```java @Environment(EnvType.CLIENT) public class ClientNetworking { public static void sendMessageToServer(String message) { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); buf.writeUtf(message); NetworkManager.sendToServer(MyNetworking.MESSAGE_PACKET, buf); } } ``` -------------------------------- ### Implement ExpectPlatform Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/03-platform-and-utility.md Example showing the declaration of an expected method and its corresponding implementations for Fabric and Forge. ```java public class MyApi { @ExpectPlatform public static void doSomethingPlatformSpecific() { throw new AssertionError(); } } // Fabric implementation: fabric/src/main/.../MyApi.java public class MyApi { public static void doSomethingPlatformSpecific() { // Fabric-specific code } } // Forge implementation: forge/src/main/.../MyApi.java public class MyApi { public static void doSomethingPlatformSpecific() { // Forge-specific code } } ``` -------------------------------- ### Initialize Mod Class Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md The entry point for mod initialization, including content, events, and networking setup. ```java public class MyMod { public static final String MOD_ID = "mymod"; public static void init() { registerContent(); registerEvents(); registerNetworking(); } private static void registerContent() { // Register items, blocks, etc. } private static void registerEvents() { // Listen to game events } private static void registerNetworking() { // Setup network packets } } ``` -------------------------------- ### Registering Creative Tabs Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Example of registering a new creative tab with a custom icon and display items. ```java public class MyCreativeTabs { public static void registerTabs() { CreativeTabRegistry.register( new ResourceLocation("mymod", "custom_tab"), () -> CreativeModeTab.builder(CreativeModeTab.Row.TOP, 0) .title(Component.literal("My Mod")) .icon(() -> new ItemStack(MyItems.CUSTOM_ITEM.get())) .displayItems((enabledFeatures, output) -> { output.accept(MyItems.CUSTOM_ITEM.get()); output.accept(MyBlocks.CUSTOM_BLOCK.get()); }) .build() ); } } ``` -------------------------------- ### Register custom fuels Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Example showing how to register specific items or item predicates as fuel with defined burn times. ```java public class MyFuels { public static void registerFuels() { // Register a single item as fuel (400 ticks = 20 seconds) FuelRegistry.register(Items.COAL, 1600); // Register items matching a predicate as fuel FuelRegistry.register( stack -> stack.is(ItemTags.LOGS), 300 ); } } ``` -------------------------------- ### Registering Item Properties Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Example of registering a custom property for an item, such as a bow pull animation. ```java @Environment(EnvType.CLIENT) public class MyItemProperties { public static void registerProperties() { ItemPropertiesRegistry.register( Items.BOW, new ResourceLocation("pull"), (itemStack, level, entity, seed) -> { if (entity == null || !(entity instanceof Player player)) { return 0.0F; } if (itemStack != player.getUseItem()) { return 0.0F; } return (float)(itemStack.getUseDuration() - player.getUseItemRemainingTicks()) / 20.0F; } ); } } ``` -------------------------------- ### Registering an Entity Renderer Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Example of registering a custom renderer for an entity type within an EntityRenderersEvent. ```java @Environment(EnvType.CLIENT) public class MyEntityRenderers { public static void registerRenderers(EntityRenderersEvent.RegisterRenderers event) { EntityRendererRegistry.register( MyEntities.CUSTOM_ENTITY.get(), context -> new MyEntityRenderer(context) ); } } ``` -------------------------------- ### Register Packet Receiver Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Example of registering a server-to-client packet receiver using NetworkManager. ```java public class MyNetworking { public static final ResourceLocation SYNC_PACKET = new ResourceLocation("mymod", "sync_data"); public static void init() { // Register a server-to-client packet NetworkManager.registerReceiver( NetworkManager.serverToClient(), SYNC_PACKET, (buf, context) -> { int value = buf.readInt(); String message = buf.readUtf(); context.queue(() -> { // Handle on main thread System.out.println("Received: " + value + " - " + message); }); } ); } } ``` -------------------------------- ### Subscribe to Block Break Event Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/01-event-system.md Example of registering a listener to a block break event and returning an interrupt result. ```java // Subscribing to a block break event BlockEvent.BREAK.register((level, pos, state, player, xp) -> { // Check if this is a specific block if (state.getBlock() == Blocks.DIAMOND_BLOCK) { // Cancel the break event return EventResult.interruptFalse(); } // Let the event continue to other listeners return EventResult.pass(); }); ``` -------------------------------- ### Custom Entity Spawn Packet Implementation Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Example of overriding getAddEntityPacket within a custom entity class. ```java public class MyCustomEntity extends Entity { @Override public Packet getAddEntityPacket() { return NetworkManager.createAddEntityPacket(this); } } ``` -------------------------------- ### Registering a Block Entity Renderer Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Example of registering a custom renderer for a block entity type using the BlockEntityRendererRegistry. ```java @Environment(EnvType.CLIENT) public class ClientSetup { public static void setupBlockEntityRenderers() { BlockEntityRendererRegistry.register( MyBlockEntities.CUSTOM_BE.get(), context -> new MyBlockEntityRenderer(context.getBlockRenderDispatcher()) ); } } ``` -------------------------------- ### Value Interface Definition Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Generic interface for getting and setting values. ```java public interface Value { T get(); void set(T value); } ``` -------------------------------- ### Registering Client Renderers with Events Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Use the CLIENT_SETUP event to register renderers, ensuring code is only executed on the client side. ```java @Environment(EnvType.CLIENT) public class ClientSetup { public static void setupClient() { // Listen for entity render registration ClientLifecycleEvent.CLIENT_SETUP.register(() -> { BlockEntityRendererRegistry.register(/* ... */); EntityRendererRegistry.register(/* ... */); RenderTypeRegistry.register(/* ... */); }); } } ``` -------------------------------- ### Accessing and Using Registries Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Demonstrates how to retrieve a registry instance, register items, and use callbacks for deferred registration. ```java // Get a registries instance Registries registries = Registries.get("mymod"); // Register to a specific registry Registrar itemRegistrar = registries.get(Registries.ITEM); RegistrySupplier myItem = itemRegistrar.register( new ResourceLocation("mymod", "my_item"), () -> new Item(new Item.Properties()) ); // Use a callback for deferred registration registries.forRegistry(Registries.ITEM, itemRegistrar -> { itemRegistrar.register( new ResourceLocation("mymod", "another_item"), () -> new Item(new Item.Properties()) ); }); ``` -------------------------------- ### Platform Detection and Utility Usage Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/03-platform-and-utility.md Demonstrates checking the current platform, verifying mod presence, and retrieving configuration paths. ```java public class MyModUtils { public static void init() { if (Platform.isFabric()) { System.out.println("Running on Fabric!"); } if (Platform.isModLoaded("jei")) { System.out.println("JEI is installed"); } Path configPath = Platform.getConfigFolder(); Path myConfigFile = configPath.resolve("mymod.json"); } } ``` -------------------------------- ### Register Custom Items and Blocks Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Demonstrates how to use Registries and Registrar to register game objects and handle registry callbacks. ```java public class CustomRegistries { public static void example() { Registries registries = Registries.get(MyMod.MOD_ID); // Register to a specific registry Registrar itemRegistrar = registries.get(Registries.ITEM); RegistrySupplier myItem = itemRegistrar.register( new ResourceLocation(MyMod.MOD_ID, "custom"), () -> new Item(new Item.Properties()) ); // Use callback registries.forRegistry(Registries.BLOCK, blockRegistrar -> { blockRegistrar.register( new ResourceLocation(MyMod.MOD_ID, "custom_block"), () -> new Block(BlockBehaviour.Properties.of()) ); }); } } ``` -------------------------------- ### Recommended Project Structure Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Standard directory layout for organizing mod content, events, networking, and client-side logic. ```text src/main/java/com/yourname/mymod/ ├── MyMod.java (main entry point) ├── content/ │ ├── MyBlocks.java │ ├── MyItems.java │ ├── MyFluids.java │ └── MyEntities.java ├── event/ │ ├── CommonEvents.java │ └── ClientEvents.java ├── network/ │ └── MyNetworking.java ├── client/ │ ├── ClientSetup.java │ ├── renderer/ │ │ ├── MyBlockEntityRenderer.java │ │ └── MyEntityRenderer.java │ └── keybind/ │ └── MyKeybinds.java └── util/ ├── PlatformUtils.java └── BiomeUtils.java ``` -------------------------------- ### Documentation Reading Pattern Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/README.md Recommended workflow for navigating and utilizing the documentation effectively. ```text 1. Read INDEX.md for overview 2. Pick a topic from "Quick Navigation" 3. Read the full document 4. Check examples in Quick Start Guide 5. Reference method signatures as needed ``` -------------------------------- ### Registering a custom tooltip component Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Demonstrates the registration of a custom tooltip component using a data class and a factory implementation. ```java @Environment(EnvType.CLIENT) public class MyTooltips { public static void registerTooltips() { ClientTooltipComponentRegistry.register( MyTooltipData.class, MyTooltipComponent::new ); } } // Custom tooltip data (can be returned from Item.getTooltipImage()) public class MyTooltipData extends TooltipComponent { // Implementation } @Environment(EnvType.CLIENT) public class MyTooltipComponent implements ClientTooltipComponent { private final MyTooltipData data; public MyTooltipComponent(MyTooltipData data) { this.data = data; } @Override public int getHeight() { return 20; } @Override public int getWidth(Font font) { return 100; } @Override public void renderImage(Font font, int x, int y, GuiGraphics graphics) { // Render custom tooltip } } ``` -------------------------------- ### Create and Register a Custom Event Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/01-event-system.md Demonstrates how to define a custom event using EventFactory.createLoop and register a listener to it. ```java // Create a custom loop event public class MyModEvents { public static final Event MY_EVENT = EventFactory.createLoop(MyListener.class); public interface MyListener { void onMyEvent(String message); } } // Register a listener MyModEvents.MY_EVENT.register(message -> { System.out.println("Event fired: " + message); }); ``` -------------------------------- ### Platform Detection Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Utility methods for identifying the current platform, environment, and mod loading status. ```java public final class Platform { public static boolean isFabric(); public static boolean isForge(); public static String getMinecraftVersion(); public static Path getGameFolder(); public static Path getConfigFolder(); public static Path getModsFolder(); public static Env getEnvironment(); public static EnvType getEnv(); public static boolean isModLoaded(String id); public static Mod getMod(String id); public static Optional getOptionalMod(String id); } ``` -------------------------------- ### Perform Platform Detection Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Check the current mod loader environment and retrieve system paths. ```java public class PlatformUtils { public static void checkPlatform() { if (Platform.isFabric()) { System.out.println("Running on Fabric"); } else if (Platform.isForge()) { System.out.println("Running on Forge"); } System.out.println("Minecraft: " + Platform.getMinecraftVersion()); // Check if mod is loaded if (Platform.isModLoaded("jei")) { System.out.println("JEI is installed!"); } // Get file paths Path configDir = Platform.getConfigFolder(); Path modsDir = Platform.getModsFolder(); } } ``` -------------------------------- ### Implement Fluids and Fluid Stacks Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Defines a custom fluid using DeferredRegister and demonstrates manipulation of FluidStack objects. ```java public class MyFluids { public static final DeferredRegister FLUIDS = DeferredRegister.create(MyMod.MOD_ID, Registries.FLUID); public static final RegistrySupplier MY_FLUID = FLUIDS.register("my_fluid", () -> new ArchitecturyFlowingFluid.Source( new Fluid.Properties() .viscosity(1000) .density(1000) .temperature(300) ) ); public static void example() { // Create fluid stack FluidStack stack = FluidStack.create( MY_FLUID.get(), FluidStack.bucketAmount() ); // Manipulate stack.grow(250); stack.setAmount(1000); // With NBT CompoundTag tag = stack.getOrCreateTag(); tag.putString("color", "red"); } } ``` -------------------------------- ### Platform Utility Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/03-platform-and-utility.md The Platform class provides static methods to query the current runtime environment, including platform detection, file system paths, and mod availability. ```APIDOC ## Platform Utility Methods ### Description Provides methods to detect the current platform (Fabric or Forge) and retrieve platform-specific information such as game directories and mod status. ### Class `dev.architectury.platform.Platform` ### Methods - **isFabric()** (boolean) - Returns true if running on Fabric. - **isForge()** (boolean) - Returns true if running on Forge. - **getMinecraftVersion()** (String) - Returns the current Minecraft version. - **getGameFolder()** (Path) - Gets the absolute path to the Minecraft game directory. - **getConfigFolder()** (Path) - Gets the absolute path to the config folder. - **getModsFolder()** (Path) - Gets the absolute path to the mods folder. - **getEnvironment()** (Env) - Gets the current environment (CLIENT or SERVER). - **getEnv()** (EnvType) - Gets the current environment as EnvType. - **isModLoaded(String id)** (boolean) - Checks if a mod with the given ID is loaded. - **getMod(String id)** (Mod) - Gets a Mod container by ID, throws NoSuchElementException if not found. - **getOptionalMod(String id)** (Optional) - Optionally gets a Mod container by ID. ### Usage Example ```java if (Platform.isFabric()) { System.out.println("Running on Fabric!"); } if (Platform.isModLoaded("jei")) { System.out.println("JEI is installed"); } Path configPath = Platform.getConfigFolder(); ``` ``` -------------------------------- ### SpawnProperties Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/06-hooks-reference.md Methods to access biome entity spawn settings. ```APIDOC ## SpawnProperties Methods ### Methods - **getCreatureProbability()** (float) - Gets the creature spawn probability. - **getSpawnCost(EntityType)** (SpawnCosts) - Gets spawn costs for an entity type. ``` -------------------------------- ### ClientTooltipComponentRegistry.register Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Registers a factory for a specific tooltip data class to enable custom tooltip rendering. ```APIDOC ## ClientTooltipComponentRegistry.register ### Description Registers a custom tooltip component factory for a given tooltip data class. This allows the game to use the provided factory to instantiate and render custom tooltip components when the associated data is encountered. ### Signature `public static void register(Class type, ClientTooltipComponentFactory factory)` ### Parameters - **type** (Class) - The class of the tooltip data that triggers this component. - **factory** (ClientTooltipComponentFactory) - The factory responsible for creating the tooltip component instance. ### Usage Example ```java ClientTooltipComponentRegistry.register( MyTooltipData.class, MyTooltipComponent::new ); ``` ``` -------------------------------- ### GameInstance Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Accessors for the current Minecraft server or client instance. ```APIDOC ## GameInstance ### Description Provides access to the current Minecraft server or client instances. ### Methods - `getServer()`: Returns the `MinecraftServer` instance. - `getServerNullable()`: Returns the `MinecraftServer` instance or null. - `getClient()`: Returns the `Minecraft` client instance. - `getClientNullable()`: Returns the `Minecraft` client instance or null. ``` -------------------------------- ### Implement ExpectPlatform Method Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/03-platform-and-utility.md Shows the standard pattern for defining a platform-specific method that is replaced at compile time. ```java public class MyClass { @ExpectPlatform public static void platformSpecificMethod() { throw new AssertionError(); // Will be replaced at compile time } } ``` -------------------------------- ### Check Environment and Execute Platform-Specific Code Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Uses Platform and EnvExecutor to safely run code based on the current environment (Client vs Server). ```java public class EnvironmentUtils { public static void handleEnvironment() { Env env = Platform.getEnvironment(); if (env == Env.CLIENT) { // Client-only code } else if (env == Env.SERVER) { // Server-only code } // Safer: use EnvExecutor EnvExecutor.runWhenOn(Env.CLIENT, () -> { // This only runs on client }); Optional data = EnvExecutor.callWhenOn( Env.CLIENT, () -> new ClientData() ); } } ``` -------------------------------- ### Platform Detection Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Methods for detecting the current platform, environment, and accessing game directories. ```APIDOC ## Platform ### Description Utility class for detecting the current platform (Fabric/Forge), environment, and accessing game-related folders. ### Methods - `isFabric()`: Returns true if running on Fabric. - `isForge()`: Returns true if running on Forge. - `getMinecraftVersion()`: Returns the current Minecraft version string. - `getGameFolder()`: Returns the path to the game folder. - `getConfigFolder()`: Returns the path to the configuration folder. - `getModsFolder()`: Returns the path to the mods folder. - `getEnvironment()`: Returns the current `Env`. - `isModLoaded(String id)`: Checks if a mod with the given ID is loaded. - `getMod(String id)`: Retrieves a `Mod` object by ID. - `getOptionalMod(String id)`: Retrieves an `Optional` by ID. ``` -------------------------------- ### ClientTooltipComponentRegistry Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Registers factories for custom tooltip components. ```java @Environment(EnvType.CLIENT) public final class ClientTooltipComponentRegistry { public static void register(Class type, ClientTooltipComponentFactory factory); } ``` -------------------------------- ### GameInstance Accessor Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Methods for retrieving the current Minecraft server or client instances. ```java public final class GameInstance { public static MinecraftServer getServer(); public static MinecraftServer getServerNullable(); public static Minecraft getClient(); public static Minecraft getClientNullable(); } ``` -------------------------------- ### View Architectury Module Layout Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/INDEX.md Visual representation of the project directory structure for common, Fabric, and Forge modules. ```text common/ ├── src/main/java/dev/architectury/ │ ├── event/ # Event system │ ├── networking/ # Networking │ ├── platform/ # Platform detection │ ├── registry/ # Registry system │ ├── hooks/ # Game hooks │ ├── extensions/ # Extension interfaces │ ├── utils/ # Utilities │ ├── core/ # Core items/blocks/fluids │ └── annotations/ # Annotations fabric/ ├── src/main/java/dev/architectury/ │ └── (platform-specific implementations) forge/ ├── src/main/java/dev/architectury/ │ └── (platform-specific implementations) ``` -------------------------------- ### Register Event Listeners Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/08-comprehensive-events.md Demonstrates registering common, cancellable, and client-only event listeners. ```java public class MyEventListeners { public static void registerEvents() { // Register a common event PlayerEvent.LOGGED_IN.register((player) -> { System.out.println(player.getName() + " logged in!"); }); // Register an event that can be cancelled BlockEvent.BREAK.register((level, pos, state, player, xp) -> { if (state.getBlock() == Blocks.OBSIDIAN) { // Cancel breaking obsidian return EventResult.interruptFalse(); } return EventResult.pass(); }); // Register client-only event EnvExecutor.runWhenOn(Env.CLIENT, () -> { ClientTickEvent.CLIENT_PRE.register(() -> { // Client tick code }); }); } } ``` -------------------------------- ### Vanilla Registry Pattern Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Standard vanilla Minecraft item registration pattern before migrating to Architectury. ```java public class VanillaItem extends Item { public VanillaItem() { super(new Item.Properties()); } } Registry.register( BuiltinRegistries.ITEM, new ResourceLocation("mymod", "my_item"), new VanillaItem() ); ``` -------------------------------- ### EntitySpawnExtension Implementation Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Implementation of EntitySpawnExtension to synchronize custom data during entity spawning. ```java public class MyCustomEntity extends Entity implements EntitySpawnExtension { @Override public void writeSpawnData(FriendlyByteBuf buf) { buf.writeInt(customData); } @Override public void readSpawnData(FriendlyByteBuf buf) { customData = buf.readInt(); } } ``` -------------------------------- ### KeyMappingRegistry.register Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Registers a custom key binding. ```APIDOC ## KeyMappingRegistry.register ### Description Registers a custom key mapping for the client. ### Signature `public static void register(KeyMapping keyMapping)` ### Parameters - **keyMapping** (KeyMapping) - The key mapping to register. ``` -------------------------------- ### ArchitecturyBucketItem Class Definition Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/05-fluids-and-items.md Base class for custom bucket items that work across platforms. ```java public abstract class ArchitecturyBucketItem extends BucketItem ``` -------------------------------- ### Implementing and Registering a Custom Fluid Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/05-fluids-and-items.md Extend ArchitecturyFlowingFluid to create custom fluids and use DeferredRegister for registration. ```java public class MyFluid extends ArchitecturyFlowingFluid { private MyFluid(Properties properties) { super(properties); } @Override public Fluid getFlowing() { return FLOWING.get(); } @Override public Fluid getSource() { return SOURCE.get(); } } // Registration public class MyContent { public static final DeferredRegister FLUIDS = DeferredRegister.create("mymod", Registries.FLUID); public static final RegistrySupplier CUSTOM_FLUID = FLUIDS.register("custom_fluid", () -> new MyFluid( new Fluid.Properties() .viscosity(1000) .density(1000) .temperature(300) )); } ``` -------------------------------- ### DeferredRegister Class Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Provides methods for creating and managing deferred registries for game objects. ```java public class DeferredRegister implements Iterable> { public static DeferredRegister create(String modId, ResourceKey> key); public RegistrySupplier register(String id, Supplier supplier); public RegistrySupplier register(ResourceLocation id, Supplier supplier); public void register(); public Registries getRegistries(); public Registrar getRegistrar(); @Override public Iterator> iterator(); } ``` -------------------------------- ### Register Items and Blocks Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Use DeferredRegister to manage mod content registration for items and blocks. ```java public class MyContent { public static final DeferredRegister ITEMS = DeferredRegister.create(MyMod.MOD_ID, Registries.ITEM); public static final DeferredRegister BLOCKS = DeferredRegister.create(MyMod.MOD_ID, Registries.BLOCK); // Register items public static final RegistrySupplier MY_ITEM = ITEMS.register("my_item", () -> new Item(new Item.Properties() .rarity(Rarity.COMMON) ) ); // Register blocks public static final RegistrySupplier MY_BLOCK = BLOCKS.register("my_block", () -> new Block(BlockBehaviour.Properties .of(Material.STONE) .strength(2.0f, 10.0f) ) ); public static void init() { ITEMS.register(); BLOCKS.register(); } } ``` -------------------------------- ### Registering a Resource Reload Listener Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/07-client-registries.md Implements a PreparableReloadListener to handle resource loading and applies the registration via ReloadListenerRegistry. ```java public class MyResourceReloadListener implements PreparableReloadListener { @Override public CompletableFuture reload(PreparationBarrier barrier, ResourceManager manager, ProfilerFiller profiler1, ProfilerFiller profiler2, Executor executor, Executor executor2) { return CompletableFuture.runAsync(() -> { // Load resources in parallel var resources = manager.listResources("mymod/custom", name -> name.getPath().endsWith(".json")); return barrier.wait(Unit.INSTANCE); }, executor).thenCompose(unit -> CompletableFuture.runAsync(() -> { // Apply resources on main thread }, executor2) ); } } // Registration public class MyModClient { public static void init() { ReloadListenerRegistry.register( new ResourceLocation("mymod", "resources"), new MyResourceReloadListener() ); } } ``` -------------------------------- ### Registrar Interface Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Provides direct registration methods for registry entries. ```java public interface Registrar { RegistrySupplier register(ResourceLocation id, T entry); RegistrySupplier register(ResourceLocation id, Supplier supplier); } ``` -------------------------------- ### FluidStackHooks Utility Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Provides static utility methods for interacting with FluidStack instances. ```java public final class FluidStackHooks { public static Component getName(FluidStack stack); public static String getTranslationKey(FluidStack stack); public static long bucketAmount(); } ``` -------------------------------- ### KeyMappingRegistry Class Definition Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md The base class for registering custom key bindings. ```java public final class KeyMappingRegistry ``` -------------------------------- ### Define MenuRegistry class Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Class definition for registering custom container or menu screen factories. ```java public final class MenuRegistry ``` -------------------------------- ### Define SpawnPlacementsRegistry class Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Class definition for registering entity spawn placement conditions. ```java public final class SpawnPlacementsRegistry ``` -------------------------------- ### MenuRegistry.registerScreenFactory Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Registers a screen factory for a specific menu type to handle GUI rendering. ```APIDOC ## MenuRegistry.registerScreenFactory ### Description Registers a screen factory for a given menu type, allowing the game to associate a GUI screen with a container menu. ### Parameters - **menuType** (MenuType) - Required - The menu type to register the screen for. - **factory** (ScreenConstructor) - Required - The constructor/factory for the screen. ``` -------------------------------- ### Define RegistrarOption interface Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Interface used to define options for customizing registrar behavior. ```java public interface RegistrarOption ``` -------------------------------- ### NetworkManager Class Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Provides static methods for registering packet receivers, sending packets to players or the server, and checking packet reception capabilities. ```java public final class NetworkManager { public static void registerReceiver(Side side, ResourceLocation id, NetworkReceiver receiver); public static void registerReceiver(Side side, ResourceLocation id, List transformers, NetworkReceiver receiver); public static void sendToPlayer(ServerPlayer player, ResourceLocation id, FriendlyByteBuf buf); public static void sendToPlayers(Iterable players, ResourceLocation id, FriendlyByteBuf buf); public static void sendToServer(ResourceLocation id, FriendlyByteBuf buf); public static boolean canServerReceive(ResourceLocation id); public static boolean canPlayerReceive(ServerPlayer player, ResourceLocation id); public static Packet createAddEntityPacket(Entity entity); public static Side s2c(); public static Side c2s(); public static Side serverToClient(); public static Side clientToServer(); @Deprecated public static Packet toPacket(Side side, ResourceLocation id, FriendlyByteBuf buf); @Deprecated public static List> toPackets(Side side, ResourceLocation id, FriendlyByteBuf buf); @Deprecated public static void collectPackets(PacketSink sink, Side side, ResourceLocation id, FriendlyByteBuf buf); } ``` -------------------------------- ### KeyMappingRegistry Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Registers custom key mappings for client input. ```java @Environment(EnvType.CLIENT) public final class KeyMappingRegistry { public static void register(KeyMapping keyMapping); } ``` -------------------------------- ### Amount Utility Constants Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Utility class providing standard bucket, millibucket, and droplet constants. ```java public final class Amount { public static long bucket(); // 1000 public static long millibucket(); // 1 public static long droplet(); // ~12.35 } ``` -------------------------------- ### SpawnProperties Interface Definition Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/06-hooks-reference.md Interface for accessing biome entity spawn settings. ```java public interface SpawnProperties extends BiomeProperties ``` -------------------------------- ### EntitySpawnExtension Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md An interface for custom entities to implement if they need to send additional data during the entity spawn process. ```APIDOC ## EntitySpawnExtension ### Description Custom entities can implement EntitySpawnExtension to send and receive additional data during the spawn process. ### Methods - **writeSpawnData(FriendlyByteBuf buf)**: Writes custom entity data to the buffer. - **readSpawnData(FriendlyByteBuf buf)**: Reads custom entity data from the buffer. ### Usage Example ```java public class MyCustomEntity extends Entity implements EntitySpawnExtension { @Override public void writeSpawnData(FriendlyByteBuf buf) { buf.writeInt(customData); } @Override public void readSpawnData(FriendlyByteBuf buf) { customData = buf.readInt(); } } ``` ``` -------------------------------- ### ClimateProperties Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/06-hooks-reference.md Methods to access biome climate settings like temperature and rainfall. ```APIDOC ## ClimateProperties Methods ### Methods - **getTemperature()** (float) - Gets the biome temperature. - **getDownfall()** (float) - Gets the rainfall amount. ``` -------------------------------- ### Specialized Registry Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Registry helpers for specific game features like creative tabs, fuel, menus, entities, and biomes. ```java public final class CreativeTabRegistry { public static void register(ResourceLocation id, Supplier tab); } public final class FuelRegistry { public static void register(Item item, int burnTime); public static void register(Predicate predicate, int burnTime); } public final class MenuRegistry { public static void registerScreenFactory(MenuType menuType, ScreenConstructor factory); } public final class SpawnPlacementsRegistry { public static void register(EntityType type, SpawnPlacements.Type placement, Heightmap.Types heightmap, SpawnPlacements.SpawnPredicate predicate); } public final class EntityAttributeRegistry { public static void register(EntityType type, Attribute attribute, double baseValue); } public final class BiomeModifications { public static void addFeatures(Predicate predicate, List> features); public static void addStructures(Predicate predicate, List> structures); } ``` -------------------------------- ### RegistrarBuilder Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Methods for configuring and building a registrar. ```APIDOC ## RegistrarBuilder.option(RegistrarOption option) ### Description Adds an option to the registrar. ### Parameters - **option** (RegistrarOption) - Required - The option to add. ## RegistrarBuilder.build() ### Description Builds and returns the configured registrar. ``` -------------------------------- ### EventFactory Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Provides static factory methods for creating new event instances with various loop and result configurations. ```java public final class EventFactory { public static Event of(Function, T> function); public static Event createLoop(Class clazz); public static Event createEventResult(Class clazz); public static Event createLoop(T... typeGetter); public static Event createEventResult(T... typeGetter); } ``` -------------------------------- ### SpawnPlacementsRegistry.register Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/04-registry-system.md Registers spawn placement conditions for entities. ```APIDOC ## SpawnPlacementsRegistry.register ### Description Defines the conditions under which an entity type can spawn in the world. ### Parameters - **type** (EntityType) - Required - The entity type. - **type** (SpawnPlacements.Type) - Required - The spawn placement type. - **heightmap** (Heightmap.Types) - Required - The heightmap type for placement. - **predicate** (SpawnPlacements.SpawnPredicate) - Required - The predicate defining spawn conditions. ``` -------------------------------- ### createAddEntityPacket Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Creates a packet for spawning a custom entity on the client. This method should be utilized within the getAddEntityPacket override of an entity class. ```APIDOC ## createAddEntityPacket ### Description Creates a packet for spawning a custom entity on the client. This should be returned from Entity.getAddEntityPacket(). ### Signature public static Packet createAddEntityPacket(Entity entity) ### Parameters - **entity** (Entity) - The entity instance to create a spawn packet for. ### Usage Example ```java public class MyCustomEntity extends Entity { @Override public Packet getAddEntityPacket() { return NetworkManager.createAddEntityPacket(this); } } ``` ``` -------------------------------- ### Verify Mod Registration Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Use these assertions to confirm that mod IDs, items, blocks, and event listeners are correctly registered. ```java public class VerifySetup { public static void verify() { // Check items registered assert Platform.isModLoaded(MyMod.MOD_ID); assert MyContent.MY_ITEM.isPresent(); assert MyContent.MY_BLOCK.isPresent(); // Check event listeners assert BlockEvent.BREAK.isRegistered(listener); System.out.println("✓ All registrations successful!"); } } ``` -------------------------------- ### Handle Compound Results with Data Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/08-comprehensive-events.md Patterns for returning both a result and associated data from an event listener. ```java // For events that need to return both a result and data return CompoundEventResult.pass(); return CompoundEventResult.interrupt(true, dataObject); return CompoundEventResult.interruptTrue(dataObject); ``` -------------------------------- ### Registry Supplier Usage Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Pattern for safely accessing items from a RegistrySupplier by checking presence before retrieval. ```java public class ItemUsage { public static void example(RegistrySupplier supplier) { if (supplier.isPresent()) { Item item = supplier.get(); System.out.println("Item ID: " + supplier.getId()); } } } ``` -------------------------------- ### Access GameInstance Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/03-platform-and-utility.md Defines the GameInstance class for accessing Minecraft server or client instances. ```java public final class GameInstance ``` -------------------------------- ### Create Add Entity Packet Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Method signature for generating a spawn packet for custom entities. ```java @ExpectPlatform public static Packet createAddEntityPacket(Entity entity) ``` -------------------------------- ### RegistrySupplier Interface Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Defines methods for accessing registered objects and their metadata. ```java public interface RegistrySupplier extends Supplier { @Override T get(); boolean isPresent(); ResourceLocation getId(); ResourceLocation getRegistryId(); Registries getRegistries(); Registrar getRegistrar(); } ``` -------------------------------- ### BiomeHooks Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/06-hooks-reference.md Methods for retrieving various properties of a biome, such as climate, effects, generation, and spawn settings. ```APIDOC ## BiomeHooks Methods ### Description Provides access to biome properties and enables biome modification. ### Methods - **getClimateProperties(Biome)** (ClimateProperties) - Gets climate properties (temperature, humidity, etc.). - **getEffectsProperties(Biome)** (EffectsProperties) - Gets effects properties (fog color, water color, etc.). - **getGenerationProperties(Biome)** (GenerationProperties) - Gets generation properties (features, structures, etc.). - **getSpawnProperties(Biome)** (SpawnProperties) - Gets spawn properties (spawn weights, etc.). ``` -------------------------------- ### Platform Class Definition Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/03-platform-and-utility.md The primary class for platform detection and utility methods. ```java public final class Platform ``` -------------------------------- ### Listen to Game Events Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Register listeners for block interactions, player events, and server ticks. ```java public class EventListeners { public static void register() { // Block break event BlockEvent.BREAK.register((level, pos, state, player, xp) -> { if (shouldPreventBreak(state)) { return EventResult.interruptFalse(); } return EventResult.pass(); }); // Player join event PlayerEvent.LOGGED_IN.register((player) -> { if (!player.level().isClientSide) { // Server-side: send welcome message sendWelcomePacket(player); } }); // Tick event TickEvent.SERVER_POST.register(() -> { // Update every server tick }); } private static boolean shouldPreventBreak(BlockState state) { return state.is(BlockTags.NEEDS_DIAMOND_TOOL); } private static void sendWelcomePacket(Player player) { if (player instanceof ServerPlayer sp) { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); buf.writeUtf("Welcome!"); NetworkManager.sendToPlayer(sp, new ResourceLocation(MyMod.MOD_ID, "welcome"), buf ); } } } ``` -------------------------------- ### BiomeHooks Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Accessors for biome properties including climate, effects, generation, and spawning data. ```java public final class BiomeHooks { public static ClimateProperties getClimateProperties(Biome biome); public static EffectsProperties getEffectsProperties(Biome biome); public static GenerationProperties getGenerationProperties(Biome biome); public static SpawnProperties getSpawnProperties(Biome biome); } public interface ClimateProperties { float getTemperature(); float getDownfall(); } public interface EffectsProperties { int getFogColor(); int getWaterColor(); int getWaterFogColor(); int getSkyColor(); } public interface GenerationProperties { // Feature and structure access } public interface SpawnProperties { float getCreatureProbability(); SpawnCosts getSpawnCost(EntityType type); } ``` -------------------------------- ### ScreenAccess Interface and Usage Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/06-hooks-reference.md Interface for accessing screen internals, typically used within client-side environments. ```java public interface ScreenAccess ``` ```java @Environment(EnvType.CLIENT) public class MyScreenUtils { public static void example(Screen screen) { if (screen instanceof ScreenAccess access) { // Access screen internals } } } ``` -------------------------------- ### ArchitecturyRecordItem Class Definition Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/05-fluids-and-items.md Base class for custom music record items. ```java public abstract class ArchitecturyRecordItem extends RecordItem ``` -------------------------------- ### Define PacketContext Interface Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/02-networking.md Interface providing access to player, environment, and task queuing for received packets. ```java public interface PacketContext { Player getPlayer(); void queue(Runnable runnable); Env getEnvironment(); default EnvType getEnv() } ``` -------------------------------- ### Event Interface Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/11-api-method-reference.md Defines the core contract for event handling, including listener registration and invoker retrieval. ```java public interface Event { T invoker(); // Get invoker instance void register(T listener); // Register listener void unregister(T listener); // Unregister listener boolean isRegistered(T listener); // Check if registered void clearListeners(); // Remove all listeners } ``` -------------------------------- ### FluidStack static factory methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/09-types-and-data-structures.md Common static methods used to instantiate or interact with FluidStack objects. ```java FluidStack.empty() FluidStack.create(Fluid, long) FluidStack.create(Fluid, long, CompoundTag) FluidStack.create(Supplier, long) FluidStack.create(Supplier, long, CompoundTag) FluidStack.create(FluidStack, long) FluidStack.bucketAmount() // 1000 ``` -------------------------------- ### EffectsProperties Methods Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/06-hooks-reference.md Methods to access biome visual effects such as fog and water colors. ```APIDOC ## EffectsProperties Methods ### Methods - **getFogColor()** (int) - Gets the fog color as RGB. - **getWaterColor()** (int) - Gets the water color as RGB. - **getWaterFogColor()** (int) - Gets the water fog color as RGB. - **getSkyColor()** (int) - Gets the sky color as RGB. ``` -------------------------------- ### Configure Tool Behaviors Source: https://github.com/architectury/architectury-api/blob/1.19.2/_autodocs/10-quick-start-guide.md Registers custom tool interactions like strippable logs, tillable blocks, and fuel values. ```java public class ToolSetup { public static void registerToolBehaviors() { // Make logs strippable AxeItemHooks.addStrippable( MyBlocks.CUSTOM_LOG.get(), MyBlocks.CUSTOM_STRIPPED_LOG.get() ); // Make grass tillable HoeItemHooks.addTillable( MyBlocks.GRASS_LIKE.get(), MyBlocks.DIRT_LIKE.get() ); // Register fuel FuelRegistry.register(MyItems.COAL.get(), 1600); } } ```