Register a Custom Block with StationAPI
Setting Up Your Block Class
To create a custom block in StationAPI, you'll need to extend the appropriate block class and override key methods. StationAPI provides hooks into the block registration system that work with Fabric Loader's initialization pipeline.
Create a new class that extends the base block type, then define your block's properties such as material, hardness, and blast resistance. Override methods like getRenderType() if you need custom rendering behavior, or onBlockPlaced() for placement logic.
Registering During Mod Initialization
Use StationAPI's event system to register your block at the correct time. Listen for the block registration event (fired early in game startup) and call the registration method with your block instance and a unique identifier string.
Make sure your block is registered before the world loads. StationAPI handles the timing automatically if you hook into the proper initialization event. Once registered, your block will appear in the creative inventory and can be placed in worlds just like vanilla blocks.
Test by creating a new world and verifying your block appears and behaves as expected.