For mod developers

What other mods can do with BuildPrint, and how to call it without making it a requirement.

BuildPrint has these public APIs, all in the package com.buildprint.api and all on the client. The examples use the Mojang names of Minecraft 26.x.

APIWhat it is forSince
BuildprintBlueprintsKeep a blueprint for your mod: builds your mod makes show up in BuildPrint as a build to follow.0.1.12
BuildprintPlacementsRead the loaded builds: where they are, what they want at a block, progress and materials.0.1.17
BuildprintPreviewsShow a changed copy of a build as a ghost before anything is saved.0.1.19
BuildprintLibrarySave a loaded build to the player's schematics folder.0.1.19
BuildprintSelectionRead and change the player's selection, and capture part of the world.0.1.19
BuildprintRulesRead what the server allows and the printer's limits.0.1.19
BuildprintHudHide BuildPrint's panels while your own screen-filling tool is open.0.1.17
BuildprintActionsList and run BuildPrint's switches and screens, for a wheel or a menu.0.1.27
Editor APIAdd tools, buttons and drawings to the editor, and open or close it.0.1.17
Format APITeach BuildPrint another schematic file format.0.1.17

Only that package is kept stable. Everything else in BuildPrint can change in any release, so a mixin into those classes will break sooner or later.

Every call has a @since with the version it arrived in. Look each method up on its own and treat a missing one as an older BuildPrint. When BuildPrint is not ready, for example before a world is loaded, a call does nothing and returns empty, false, -1 or null. It does not throw.

Keep BuildPrint optional #

BuildPrint is client-side, and most players of your mod will not have it. Two ways to call it without making it a requirement:

  • Check FabricLoader.getInstance().isModLoaded("buildprint") on Fabric, or ModList.get().isLoaded("buildprint") on NeoForge, and keep the calls in a class of their own, so BuildPrint's classes only load when it is there.
  • Or call it by reflection. BuildprintBlueprints, BuildprintPlacements, BuildprintPreviews, BuildprintLibrary, BuildprintSelection, BuildprintRules, BuildprintHud and BuildprintActions take only Java types (String, int, arrays, Map, java.util.function), so there is nothing to compile against. See the example.

The editor and format APIs have you implement BuildPrint's interfaces, so they need the jar to compile. An editor add-on is declared, not called: a Fabric entrypoint, an annotation on NeoForge, or a services file. BuildPrint only loads it when it is installed, so your mod still runs without it.

Client initializerJava
public final class MyModClient implements ClientModInitializer {
    @Override
    public void onInitializeClient() {
        if (FabricLoader.getInstance().isModLoaded("buildprint")) {
            BuildprintCompat.init();
        }
    }
}

// A class of its own: BuildPrint's classes only load when it is there.
final class BuildprintCompat {
    static void init() {
        BuildprintHud.hideWhile("mymod", MyTool::isOpen);
    }
}

Compiling against it #

BuildPrint is on Modrinth, so the Modrinth Maven works. Modrinth has one file per Minecraft version and loader. Use the version number Modrinth shows for the one you build against, such as 0.1.34+26.3, or that version's id from its page, which points at exactly one file. On Fabric use modCompileOnly, on NeoForge compileOnly.

build.gradleGradle
repositories {
    maven {
        url = "https://api.modrinth.com/maven"
        content { includeGroup "maven.modrinth" }
    }
}

dependencies {
    // The version for your Minecraft version and loader, as Modrinth lists it.
    modCompileOnly "maven.modrinth:buildprint:0.1.34+26.3"
}

BuildPrint runs on Fabric on 1.21.1 to 26.3, and on NeoForge on 1.21.1, 1.21.3, 1.21.4, 1.21.5, 1.21.8, 1.21.10 and 1.21.11 and 26.1.2 to 26.3, with the same API everywhere. It is client-side only, so call it from client code, on the client thread.

Questions #

Something the API should do, or something that does not work: ask on Discord.

Something missing or wrong on this page? Say so on Discord.