Development
Mods
Charmony consists of a number of smaller mods that provide features. Each feature adds some unique functionality to Minecraft. For example, the mooblooms charmony mod has a single feature that registers the moobloom entity, its behavior, some logic to spawn the moobloom, a resource pack with moobloom graphical assets and a data pack that defines the biomes that moobloom entities should spawn in.
The rationale here:
For players
They are free to install only the mods that they want from this set, or they can install one of the collections that includes a pre-defined set of charmony mods.
For developers
- Working on smaller mods is simpler than working on a monolithic codebase with side-effects.
- If some charmony mods are not ready for a new version of Minecraft, the impact is much less than having to upgrade all the features of a monolithic mod.
A note about the Charmony library mod:
Each individual mod depend on a library mod, called Charmony. Charmony helps with sequencing how things are grouped and loaded, provides reusable code for common operations, some additional Fabric events beyond those offered by the Fabric API and helper methods to make registration and event registrations less time consuming.
Charmony also comes with a copy of the Charmony API which is a small set of interfaces that may be used to integrate your own mod with features found in all Charmony mods.
Collections
Collections are mods that don't provide any functionality themselves. Instead, they come bundled with one or more
smaller Charmony mods. This replaces the monolithic mods such as the older Charm, Strange and
Charmonium mods. The local.build.gradle
inside the collection defines the mods that should be bundled. This build file
uses a helper method called embedMod
to download pre-built mod jar files from charmony.work,
a trusted server that holds build files and metadata.
The Charmony library mod is automatically bundled with a collection mod.
Features
A charmony mod implements one or more related features. An individual feature sets up its own registrations, game event handling and any other functionality.
By default a feature can be enabled and disabled by the player via a configuration file or by the control panel feature of the Charmony library mod.
Features consist of one or more sides. Each side is launched independently as the game starts, so the common side (e.g. the logical server) will start first, register some items and blocks, then the client side will be able to use the registered things. To keep this all together, a feature consists of SidedFeatures that share the same name as one another, with a FeatureDefinition attribute to provide metadata about the SidedFeature such as the side it targets.
// modname/client/features/extreme_gunpower/ExtremeGunpower.java:
@FeatureDefinition(side = Side.Client)
class ExtremeGunpower extends SidedFeature() {
// client registrations and setup
}
// modname/common/features/extreme_gunpower/ExtremeGunpower.java:
@FeatureDefinition(side = Side.Common, description = "Gunpowder that explodes when you look at it")
class ExtremeGunpower extends SidedFeature() {
// common registrations and setup
}
SidedFeatures are loaded into the Mod instance in the relevant Fabric initializer. The Mod object then instantiates the features at the correct time when booting the game.
class ClientInitializer implements ClientModInitializer {
public void onClientInitialize() {
var mod = new ExtremeMod();
mod.addSidedFeature(ExtremeGunpowder.class);
mod.run(Side.Client);
}
}
charmony.work
This is a server that holds pre-built charmony mods and collections. It also holds some graphical assets, documentation and website code. This server is owned and managed by the same team responsible for developing the game mods. Builds available on this server are the same as those uploaded to modrinth and the latter is where most players will download mods for their game launcher.
For developers, cloning and building any charmony source
from github will automatically fetch requisite mods from charmony.work - for example the Charmony library mod
and the Charmony API. This auto-fetching behavior is ignored if you put the required jar file(s) in a libs
folder
in the root of the project.
charmony.dev
This website points to the webroot inside the charmony.work server (see above) and serves the pages and assets responsible for the public website.