BlanketUtils
Note: If you encounter this modification in another mod's dependency list, simply install it — detailed documentation is not required in this context.
BlanketUtils is a library of tools specifically developed for creating modifications on the Fabric platform. It includes ready-made solutions for frequently used functions, significantly simplifying developers' workflows:
Main Features
Configuration File Management
- Support for JSONC format with comments
- Automatic backup creation and configuration migration
- File change tracking and settings reloading without game restart
- Type-safe configuration handling through Kotlin data classes
data class MyConfig(
override val version: String = "1.0.0",
override val configId: String = "mymod"
// Your configuration parameters go here
) : ConfigData
val configManager = ConfigManager(
currentVersion = "1.0.0",
defaultConfig = MyConfig(),
configClass = MyConfig::class
)
Enhanced Command System
- Intuitive API for command building
- Built-in permission verification system
- Support for subcommands and their alternative names
commandManager.command("mycommand", permission = "mymod.command") {
executes { context ->
// Main command logic
1
}
subcommand("subcommand") {
executes { context ->
// Subcommand logic
1
}
}
}
Graphical Interface Framework
Module for rapid creation of inventory graphical interfaces includes:
- Basic elements and buttons
- Slot interaction handling
- Dynamic content updates
CustomGui.openGui(
player = player,
title = "My GUI",
layout = listOf(/ Interface elements /),
onInteract = { context ->
// Interaction handling
}
)
Dependencies
Required installations for operation:
- Kotlin
- Fabric API
- Fabric Language Kotlin
Project Setup
Add the following line to the build.gradle.kts file:
dependencies {
modImplementation("com.username:blanketutils:1.0.0")
}
Practical Examples
Working with Settings
// Configuration creation
data class MyConfig(
override val version: String = "1.0.0",
override val configId: String = "mymod",
var debugMode: Boolean = false
) : ConfigData
// Configuration manager initialization
val configManager = ConfigManager(
currentVersion = "1.0.0",
defaultConfig = MyConfig(),
configClass = MyConfig::class,
metadata = ConfigMetadata(
headerComments = listOf("My mod configuration")
)
)
// Getting current settings
val currentConfig = configManager.getCurrentConfig()
Command Registration
val commandManager = CommandManager("mymod")
commandManager.command("hello", permission = "mymod.hello") {
executes { context ->
val source = context.source
CommandManager.sendSuccess(source, "Hello, World!")
1
}
}
Interface Creation
CustomGui.openGui(
player = player,
title = "My GUI",
layout = listOf(
CustomGui.createNormalButton(
ItemStack(Items.DIAMOND),
"Click Me!",
listOf("Button description")
)
),
onInteract = { context ->
// Button click handling
}
)
The most current version of the source code is available on the GitHub platform in the developers' corresponding repository.
Adding to Project
Add these lines to the build.gradle.kts file:
dependencies {
modCompileOnly(files("libs/blanketutils-1.0.0.jar"))
}
For proper operation, ensure the BlanketUtils JAR file is located in your project's libs directory.