Tags
Creators
Details
0.24.0
Compatibility
Changes
Ornithe Standard Libraries 0.24.0
OSL 0.24.0 supports Minecraft versions between Alpha 1.0.1_01 and Release 1.14.4.
Core 0.13.0
Added MinecraftVersion::friendlyGameVersion, which returns a nicer looking version string as opposed to the version ID. See below for some comparisons
gameVersion |
friendlyGameVersion |
|---|---|
| b1.7.3 | Beta 1.7.3 |
| a1.2.6 | Alpha v1.2.6 |
| inf-20100629 | Infdev 0.31.20100629 |
| c0.29 | Classic 0.29 |
Crash Reports 0.1.0
Version agnostic API for throwing crash exceptions and populating crash reports. Also adds a mods list to crash reports.
Throwing Crash Exceptions
The CrashExceptions utility class provides a few methods for creating crash exceptions.
CrashExceptions {
// creates a crash report from the given error and title and returns a new crash exception with that report
RuntimeException from(String title, Throwable error);
// creates a new crash report from the given error and title, then passing it to the given builder to populate it,
// and returns a new crash exception with that report
RuntimeException from(String title, Throwable error, Consumer<CrashReport> builder);
}
example usage:
try {
cookieMonster.eatCookie(cookie);
} catch (Throwable error) {
throw CrashExceptions.from("Cookie monster encountered an error while eating a cookie", error, report -> {
CrashReportSection section = report.addSection("Cookie Monster");
section.addDetail("Name", () -> cookieMonster.getName());
section.addDetail("Cookie Recipe", () -> cookie.getRecipe());
})
}
Populating Crash Reports
Several classes (Minecraft, MinecraftServer, World, WorldData) implement the new CrashReportPopulator interface, which allows modders to add crash listeners to objects of these types. When a crash happens these listeners are notified and given the opportunity to add more details to the given crash report section or add a new section to the crash report.
MinecraftClientEvents.START.register(minecraft -> {
World world = minecraft.world;
minecraft.addCrashListener((report, section) -> {
CrashReportSection section = report.addSection("Cookie Management");
section.addDetail("Cookies made", "Not enough!");
section.addDetail("Cookies eaten", "All of them!");
});
world.addCrashListener((report, section) -> {
section.addDetail("Cookie monsters", () -> world.cookieMonsters.size());
});
});
Commands 0.1.0 (for 1.8+)
API for registering both server-side and client-side commands, including a Brigadier-based command framework in 1.12.2 and below.
Registering Commands
Command registration should be done in a listener to the REGISTER_COMMANDS event. The ServerCommands class provides utility methods for creating commands.
An example is shown below.
ServerCommandEvents.REGISTER_COMMANDS.register((commands, selection, context) -> {
ExampleCommand.register(commands);
});
public final class ExampleCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(ServerCommands
.literal("example")
.executes(context -> {
context.getSource().sendSuccess(TextComponents.literal("Successfully ran example command!"), false);
return SINGLE_SUCCESS
}));
}
}
Registering Client Commands
The Commands API provides its own framework for client commands, using Brigadier, though no custom argument types are provided in the API. Command registration should be done in a listener to the REGISTER_COMMANDS event. The ClientCommands class provides utility methods for creating commands.
An example is shown below.
ClientCommandEvents.REGISTER_COMMANDS.register((commands, selection, context) -> {
ExampleClientCommand.register(commands);
});
public final class ExampleCommand {
public static void register(CommandDispatcher<ClientCommandSource> dispatcher) {
dispatcher.register(ClientCommands
.literal("example")
.executes(context -> {
context.getSource().sendSuccess(TextComponents.literal("Successfully ran example command!"));
return SINGLE_SUCCESS
}));
}
}
Registering Legacy Commands
In 1.12.2 and below, Minecraft used its own framework for commands. This framework is still usable if you prefer it over Brigadier. Command registration should be done in a listener to the REGISTER_LEGACY_COMMANDS event.
An example is shown below.
ServerCommandEvents.REGISTER_LEGACY_COMMANDS.register((commands, selection, context) -> {
commands.accept(new ExampleCommand());
});
public class ExampleCommand extends AbstractCommand {
@Override
public String getName() {
return "example";
}
@Override
public String getUsage(CommandSource source) {
return "/example";
}
@Override
public void run(MinecraftServer server, CommandSource source, String[] args) throws CommandException {
source.sendMessage(TextComponents.literal("Successfully ran example command!"));
}
}
Datagen 0.1.0 (for 1.13+)
API for generating resource and data files, including integration with Loom's datagen features.
Registering Data Generators
Data generators are registered through the datagen entrypoint in your fabric.mod.json. The entrypoint class must implement DataGeneratorInitializer.
fabric.mod.json
{
...
"entrypoints": {
...
"datagen": [
"com.example.ExampleDataGenerator"
]
},
...
}
package com.example;
import net.ornithemc.osl.datagen.api.DataGeneratorInitializer;
import net.ornithemc.osl.datagen.api.ModDataGenerator;
import net.ornithemc.osl.datagen.api.PackGenerator;
public class ExampleDataGenerator implements DataGeneratorInitializer {
@Override
public void onDatagenInit(ModDataGenerator dataGenerator) {
PackGenerator pack = dataGenerator.createPack();
pack.addProvider(ExampleModelsProvider::new);
pack.addProvider(ExampleLanguageProvider::new);
}
}
Packs
Generated files are grouped into packs. A ModDataGenerator can create two kinds of packs:
createPack()creates a pack that is written directly to the output directory. This is the pack that ends up in your mod's resources.createBundledResourcePack(NamespacedIdentifier id)creates a pack that is written toresourcepacks/<namespace>/<path>/inside the output directory. Use this to generate bundled mod resource packs (see Resource Loader API).
PackGenerator pack = dataGenerator.createPack();
PackGenerator cookiePack = dataGenerator.createBundledResourcePack(NamespacedIdentifiers.from("example", "cookies"));
A pack.mcmeta file is generated for each pack automatically. The main pack uses your mod's description, bundled packs use their identifier.
Providers are added to a pack with PackGenerator.addProvider. It accepts both providers whose constructor takes only a PackGenerator, and providers whose constructor takes a PackGenerator and a ModContainer, so a constructor reference can be passed directly.
Builtin Providers
The API provides the following data providers. Extend them and implement their abstract method to generate data.
| Provider | Generates | Package | Availability |
|---|---|---|---|
ModModelsProvider |
Block states, block and item models | net.ornithemc.osl.datagen.api.provider |
All versions |
ModLanguageProvider |
Translations | net.ornithemc.osl.datagen.api.provider |
All versions |
ModRecipesProvider |
Recipes and recipe advancements | net.ornithemc.osl.datagen.api.provider |
All versions |
ModAdvancementsProvider |
Advancements | net.ornithemc.osl.datagen.api.provider |
All versions |
ModLootTablesProvider |
Loot tables | net.ornithemc.osl.datagen.api.provider |
18w43a - 1.14.4 |
ModBlockTagsProvider |
Block tags | net.ornithemc.osl.datagen.api.provider.tag |
All versions |
ModItemTagsProvider |
Item tags | net.ornithemc.osl.datagen.api.provider.tag |
All versions |
ModFluidTagsProvider |
Fluid tags | net.ornithemc.osl.datagen.api.provider.tag |
All versions |
ModEntityTypeTagsProvider |
Entity type tags | net.ornithemc.osl.datagen.api.provider.tag |
18w43a - 1.14.4 |
Block States 0.3.0
- Added
StateDefinition::getPropertywhich returns the property with the given name. - Added
Property::getValuewhich returns an optional value for the given name.
Property<?> property = stateDefinition.getProperty("facing");
Direction facing = property.getValue("west");
Registries 0.4.0
Events
- Added
INIT_REGISTRIESevent. Registries should be created and registered in listeners to this event (in previous versions this would be done directly in your mod's entrypoint).
package com.example;
import net.ornithemc.osl.entrypoints.api.ModInitializer;
import net.ornithemc.osl.registries.api.RegistryEvents;
public class ExampleInitializer implements ModInitializer {
@Override
public void init() {
-- ExampleRegistries.init();
++ RegistryEvents.INIT_REGISTRIES.register(ExampleRegistries::init);
}
}
- Added
REGISTRIES_FROZENevent, which is invoked after registries have been frozen.
Fixes
- Crashes in 1.14 when registering content have been fixed.
- Fixed
Registry::iteratorreturning an iterator with unreliable ordering. The ordering is now based on the numerical ID.
Branding 0.4.4
Updated to use Core's MinecraftVersion::friendlyGameVersion internally.
Biomes 0.1.1, Block Entities 0.1.1, Blocks 0.3.1, Entities 0.1.3, Items 0.3.2
Updated to use Registries' INIT_REGISTRIES event internally.
Resource Loader 0.10.0
Pack Compatibility
Added PackCompatibility::isCompatible, which is shorthand for packCompatibility == PackCompatibility.COMPATIBLE.
Crash Reports
Improved resource pack information in crash reports. It now properly lists all selected packs, including the Vanilla pack, the mod resources pack, and any other virtual pack added through the API. In 1.6 and below it replaces the "skin" section that only lists a single selected texture pack.
Localization 0.2.1
Fixes
- Fixed incorrect last update time for
Locale. - Fixed translations not being read as UTF-8.
- Fixed reloads using previous language code.
- Fixed mod translations not loading in b1.0-b1.3.
- Fixed translations loading twice in 1.10- if the language code is already lowercase.
Text Components 0.2.0
TextComponentnow implements Brigadier'sMessageinterface.TextComponent::getStringreturns the same result asTextComponent::buildString.Formattings now have names. You can query the name throuhFormatting::getNameor get the formatting for a given name throughFormatting::byName. The names match those of equivalent VanillaFormattings.
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle. To learn more about the Modrinth Maven API, click here.
Note: When available, you should use the creator's maven repo instead as it will have transitive dependency information that the Modrinth Maven API does not. You may also end up with duplicate dependencies if you use a mix of Modrinth and non-Modrinth Maven repositories for your dependencies, because the group identifier will be different when served through the Modrinth Maven API.
Maven coordinates:
Version ID:
build.gradle:
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
// forRepositories(fg.repository) // Uncomment when using ForgeGradle
filter {
includeGroup "maven.modrinth"
}
}
}
// Standard Gradle dependency
dependencies {
implementation "maven.modrinth:EHGtwpJv:TzBDamVN"
}
// Legacy Loom dependency
dependencies {
modImplementation "maven.modrinth:EHGtwpJv:TzBDamVN"
}

