ποΈ Mosberg API - Minecraft Fabric Library
A comprehensive Fabric API library for Minecraft 1.21.10 that eliminates boilerplate and accelerates mod development.
β‘ What is Mosberg API?
Mosberg API is a developer library mod that provides:
β
16+ Registry Classes - Register blocks, items, entities, enchantments, fluids, sounds, particles, and more with minimal code
β
25+ Utility Helpers - Production-ready helpers for inventory, entities, NBT, particles, world manipulation, and more
β
8 Built-in Commands - Block, item, entity, world, debug, config, registry, and help commands out of the box
β
Advanced Client Systems - Entity rendering, model management, screen handlers, and 1.21+ render state support
β
Fluent Data Generation - Auto-generate recipes, loot tables, and models with intuitive builders
β
Event System - Custom events for block mining, player joining, entity spawning
β
JSON Configuration - Built-in config management with automatic file generation
β
Modern Java 21 - Records, pattern matching, sealed classes, and null safety annotations
No gameplay content is added to Minecraft. Mosberg API is purely a developer library for mod creators.
π₯ Installation for Players
- Download Fabric Loader and install it
- Download Fabric API (required dependency)
- Download this mod from CurseForge
- Place all JARs in your
.minecraft/mods/ folder
- Launch Minecraft with the Fabric profile
π¨βπ» For Mod Developers
Quick Setup
Add to gradle.properties:
# Dependencies
mosberg_api_1412900_version=7375365
Add to build.gradle:
repositories {
maven {
name = "CurseMaven"
url = "https://cursemaven.com/"
content {
includeGroup "curse.maven"
}
}
}
dependencies {
// Mosberg API
modImplementation "curse.maven:mosberg-api-1412900:${project.mosberg_api_1412900_version}"
// Optional: bundle with your mod
include implementation("curse.maven:mosberg-api-1412900:${project.mosberg_api_1412900_version}")
}
Update fabric.mod.json:
{
"depends": {
"mosberg-api": "*"
}
}
Create your mod initializer:
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class YourMod implements ModInitializer {
public static final String MOD_ID = "yourmod";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override
public void onInitialize() {
LOGGER.info("YourMod initialized with Mosberg API!");
// Register your content
ModBlocks.initialize();
ModItems.initialize();
ModEntities.initialize();
// Register events
ModEvents.register();
// Load config
ModConfig.load();
}
}
π― Key Features
Registry System
Simplify registration with one-liners:
// Block registration (auto-creates item)
public static final Block RUBY_BLOCK = MosbergBlocks.register(
"ruby_block",
new Block(AbstractBlock.Settings.create().strength(2.0f))
);
// Entity registration
public static final EntityType<CustomMob> CUSTOM_MOB = MosbergEntities.register(
"custom_mob",
EntityType.Builder.create(CustomMob::new, SpawnGroup.CREATURE)
.dimensions(0.8f, 1.8f)
);
// Enchantment registration
public static final Enchantment CUSTOM_ENCH = MosbergEnchantments.register(
"custom_ench",
new Enchantment(...)
);
16 Registry Classes:
- MosbergBlocks, MosbergItems, MosbergEntities, MosbergItemGroups
- MosbergSounds, MosbergParticles, MosbergFluids, MosbergEnchantments
- MosbergStatusEffects, MosbergPotions, MosbergBlockEntities
- MosbergDataComponents, MosbergDamageTypes, MosbergGameEvents
- MosbergScreenHandlerTypes, MosbergVillagers, MosbergWorldGen
- MosbergTags, MosbergRegistries (master registry for 60+ types)
Utility Helpers
25+ helpers for common operations:
// Inventory operations
ItemStack leftovers = InventoryHelper.addItemToInventory(inv, stack);
int transferred = InventoryHelper.transferItems(source, dest, count);
boolean hasSpace = InventoryHelper.hasSpace(inv, stack);
// Entity manipulation
EntityHelper.teleportEntity(entity, world, pos);
EntityHelper.applyKnockback(entity, strength, direction);
EntityHelper.healEntity(entity, amount);
// World operations
WorldHelper.setRaining(world, duration);
WorldHelper.createExplosion(world, null, pos, power, true);
List<Entity> nearby = WorldHelper.getEntitiesInBox(world, box);
// NBT operations
NBTHelper.setString(nbt, "name", value);
NBTHelper.setInt(nbt, "level", 5);
String name = NBTHelper.getString(nbt, "name", "Default");
// Particle effects
ParticleHelper.spawnParticles(world, ParticleTypes.FLAME, pos, count, spread);
All 25 Helpers: AttributeHelper, BlockHelper, CommandHelper, DataComponentHelper, DamageTypeHelper, EnchantmentUtil, EntityHelper, FluidHelper, GameEventHelper, InventoryHelper, ItemGroupHelper, ItemHelper, MosbergEnchantmentHelper, MosbergHelper, NBTHelper, NetworkHelper, ParticleHelper, PotionHelper, RecipeHelper, SerializationHelper, SoundHelper, StatusEffectHelper, TagHelper, VillagerHelper, WorldHelper
Data Generation
Fluent builders for recipes and loot tables:
// Shaped crafting
createShaped(RecipeCategory.TOOLS, ModItems.SWORD)
.pattern(" I ")
.pattern(" I ")
.pattern(" S ")
.input('I', Items.IRON_INGOT)
.input('S', Items.STICK)
.criterion(hasItem(Items.IRON_INGOT), conditionsFromItem(Items.IRON_INGOT))
.offerTo(exporter);
// Smelting
offerSmelting(exporter, List.of(ModBlocks.ORE),
RecipeCategory.MISC, ModItems.INGOT, 1.0f, 200, "ingot");
// Stonecutting
createStonecutting(RecipeCategory.BUILDING_BLOCKS, ModBlocks.STAIRS, ModBlocks.BLOCK)
.criterion(hasItem(ModBlocks.BLOCK), conditionsFromItem(ModBlocks.BLOCK))
.offerTo(exporter);
// Loot tables
addBlockLootTable(ModBlocks.ORE,
LootTable.builder()
.pool(LootPool.builder()
.rolls(ConstantLootNumberProvider.create(1))
.with(ItemEntry.builder(ModItems.INGOT))));
Built-in Commands
8 production-ready commands:
/block - Inspect and modify block properties
/item - Manage items and NBT data
/entity - Spawn and manipulate entities
/world - Control weather, time, explosions
/debug - Performance profiling and analysis
/config - Manage configuration at runtime
/registry - Introspect registered content
/help - Command documentation
Client-Side Rendering
Easy entity and screen registration:
// Register entity renderer
MosbergRenderers.registerEntityRenderer(
ModEntities.CUSTOM_MOB,
CustomMobRenderer::new,
ModModelLayers.CUSTOM_MOB,
CustomMobModel::getTexturedModelData
);
// Register screen
ScreenRegistry.register(ModScreenHandlers.CUSTOM,
CustomScreen::new);
Client utilities:
- MosbergRenderers - Entity/block renderers
- MosbergModels - Model layer management
- MosbergModelLayers - Pre-defined layers
- MosbergRenderStates - 1.21+ render state API
- MosbergScreenHandlerTypes - Screen handler registration
- RenderHelper, ModelHelper, TextureHelper, ScreenHelper, ScreenHandlerHelper
Events
Custom event callbacks:
MosbergEvents.BLOCK_MINED.register((player, world, pos, state) -> {
if (state.isOf(Blocks.DIAMOND_ORE)) {
player.sendMessage(Text.literal("You mined diamonds!"), false);
}
});
MosbergEvents.PLAYER_JOINED.register((player) -> {
LOGGER.info("Player joined: {}", player.getName().getString());
});
MosbergEvents.ENTITY_SPAWNED.register((entity, world) -> {
LOGGER.debug("Entity spawned: {}", entity.getType());
});
Configuration
JSON-based config with defaults:
public class ModConfig {
public static final ConfigManager CONFIG = new ConfigManager("yourmod");
public static int SPAWN_RATE = 10;
public static boolean ENABLE_FEATURE = true;
public static double DAMAGE_MULTIPLIER = 1.5;
public static void load() {
SPAWN_RATE = CONFIG.getInt("spawn_rate", 10);
ENABLE_FEATURE = CONFIG.getBoolean("enable_feature", true);
DAMAGE_MULTIPLIER = CONFIG.getDouble("damage_multiplier", 1.5);
CONFIG.save();
}
}
π What's Included
Registries (16 classes)
Register blocks, items, entities, enchantments, fluids, sounds, particles, status effects, potions, block entities, data components, damage types, game events, screen handlers, villagers, world generation, and tags.
Utilities (25 classes)
Inventory, entities, NBT, particles, world state, blocks, attributes, commands, enchantments, fluids, game events, item groups, networking, potions, recipes, serialization, sounds, status effects, tags, and villagers.
Commands (8 templates)
Block, item, entity, world, debug, config, registry, and help commands ready to use or extend.
Client Systems (11 classes)
Entity renderers, model management, screen handlers, render states (1.21+), and rendering utilities.
Data Generation
Fluent builders for recipes, loot tables, and models with full Minecraft 1.21.10 support.
Events
BlockMined, PlayerJoined, EntitySpawned, and more with simple registration.
Configuration
JSON-based config system with auto-generation and reload support.
π§ System Requirements
- Minecraft: 1.21.10
- Fabric Loader: 0.18.3+
- Fabric API: 0.138.4+1.21.10
- Java: 21+
π Documentation
Full documentation available at:
π Getting Started
- Add dependency to your
build.gradle
- Update
fabric.mod.json with Mosberg API dependency
- Create mod class implementing
ModInitializer
- Register content using Mosberg API registry classes
- Use helpers to simplify common operations
- Build with
./gradlew build
Full examples and tutorials available on the GitHub Wiki.
π‘ Why Choose Mosberg API?
β
Zero Boilerplate - Register anything with one line
β
Type-Safe - Modern Java 21 with full null safety
β
Production-Ready - 25+ tested utility helpers
β
Fluent APIs - Intuitive builder patterns
β
Comprehensive - Covers 60+ Minecraft registry types
β
Well-Documented - Every method has clear Javadoc
β
Active Development - Regular updates and improvements
β
Community-Driven - Open to feedback and contributions
π License
MIT License - Use in commercial projects, modify, distribute, or use for educational purposes. Attribution appreciated but not required.
π Credits
- Author: Mosberg
- Framework: Fabric API & Fabric Loader
- Mappings: Yarn community mappings
- Game: Minecraft by Mojang Studios
π Support
Need help?
Want to contribute?
- Fork on GitHub
- Submit pull requests for improvements
- Report issues and suggest features
π― Perfect For
β¨ Mod developers who want to spend more time on gameplay and less on boilerplate
β¨ Library mods that need a solid foundation
β¨ Teams building content packs with custom mechanics
β¨ Anyone using Fabric API 1.21.10+
Mosberg API - Write less boilerplate. Build better mods. Faster.
Made with β€οΈ by Mosberg for the Minecraft modding community