AnvilLib is a NeoForge mod library developed by Anvil Dev, providing Minecraft mod developers with a series of practical tools and frameworks.
AnvilLib adopts a modular design and includes the following functional modules:
| Module | Description |
|---|---|
| Config | Annotation-based configuration system |
| Integration | Mod compatibility integration framework |
| Network | Networking API with automatic packet registration |
| Recipe | In-world recipe system |
| Moveable Entity Block | Support for block entities movable by pistons |
| Registrum | Simplified registration system |
| Main | Aggregated module that bundles all submodules |
Provides an annotation-based configuration management system to simplify the definition and management of mod configurations.
Key Features:
@Config annotation@Comment@BoundedDiscrete@CollapsibleObjectUsage Example:
@Config(name = "my_mod", type = ModConfig.Type.COMMON)
public class MyModConfig {
@Comment("Enable debug mode")
public boolean debugMode = false;
@Comment("Maximum count")
@BoundedDiscrete(min = 1, max = 100)
public int maxCount = 10;
}
// Register configuration
MyModConfig config = ConfigManager.register("my_mod", MyModConfig::new);
Provides a framework for mod integrations, supporting automatic loading of integration code based on the presence of other mods.
Key Features:
@Integration annotationUsage Example:
@Integration(value = "jei", version = "19.0,)")
public class JEIIntegration {
public void init() {
// JEI integration logic
}
}
Provides a NeoForge networking abstraction with package-based packet auto-registration.
Key Features:
IClientboundPacket / IServerboundPacket / IInsensitiveBiPacketNetworkRegistrar.register(...)PLAY, CONFIGURATION, and COMMON protocolsUsage Example:
@SubscribeEvent
public static void onRegisterPayload(RegisterPayloadHandlersEvent event) {
PayloadRegistrar registrar = event.registrar("1");
NetworkRegistrar.register(registrar, "my_mod");
}
Provides an in-world recipe system, allowing recipes to be executed in the world (rather than in crafting tables).
Key Features:
Recipe Components:
Allows blocks with block entities to be pushed by pistons while preserving their data.
Usage Example:
public class MyBlock extends Block implements IMoveableEntityBlock {
@Override
public CompoundTag clearData(Level level, BlockPos pos) {
// Return block entity data to preserve
BlockEntity be = level.getBlockEntity(pos);
return be != null ? be.saveWithoutMetadata(level.registryAccess()) : new CompoundTag();
}
@Override
public void setData(Level level, BlockPos pos, CompoundTag nbt) {
// Restore block entity data at new position
BlockEntity be = level.getBlockEntity(pos);
if (be != null) {
be.loadAdditional(nbt, level.registryAccess());
}
}
}
A registration system based on [Registrate, simplifying the registration process for items, blocks, entities, etc.
Key Features:
Usage Example:
public static final Registrum REGISTRUM = Registrum.create("my_mod");
public static final RegistryEntry<Item> MY_ITEM = REGISTRUM
.item("my_item", Item::new)
.properties(p -> p.stacksTo(16))
.register();
anvillib-neoforge-1.21.1 is the aggregate artifact. It bundles and re-exports:
configintegrationnetworkrecipemoveable-entity-blockregistrumrepositories {
mavenCentral() // This project is already uploaded to Maven Central
}
dependencies {
// Full library
implementation "dev.anvilcraft.lib:anvillib-neoforge-1.21.1:2.0.0"
// Or import individual modules as needed
implementation "dev.anvilcraft.lib:anvillib-config-neoforge-1.21.1:2.0.0"
implementation "dev.anvilcraft.lib:anvillib-integration-neoforge-1.21.1:2.0.0"
implementation "dev.anvilcraft.lib:anvillib-network-neoforge-1.21.1:2.0.0"
implementation "dev.anvilcraft.lib:anvillib-recipe-neoforge-1.21.1:2.0.0"
implementation "dev.anvilcraft.lib:anvillib-moveable-entity-block-neoforge-1.21.1:2.0.0"
implementation "dev.anvilcraft.lib:anvillib-registrum-neoforge-1.21.1:2.0.0"
}
repositories {
mavenCentral() // This project is already uploaded to Maven Central
}
dependencies {
implementation("dev.anvilcraft.lib:anvillib-neoforge-1.21.1:2.0.0")
// Optional single-module example
implementation("dev.anvilcraft.lib:anvillib-network-neoforge-1.21.1:2.0.0")
}
Keep the dependency version aligned with release tags (current project property is
mod_version=2.0.0).
# Clone repository
git clone https://github.com/Anvil-Dev/AnvilLib.git
cd AnvilLib
# Build on macOS / Linux
./gradlew build
# Build on Windows (PowerShell / CMD)
gradlew.bat build
This project is licensed under the MIT License.
Part of the Registrum module code is based on Registrate and follows the Mozilla Public License 2.0.

AnvilLib is a NeoForge mod library developed by Anvil-Dev, providing Minecraft mod developers with a series of practical tools and frameworks.