Skip to content

Platform Helpers

MehVahdJukaar edited this page Jul 25, 2026 · 1 revision

Platform Helpers

Everything that differs between Fabric and (Neo)Forge, wrapped so your common code doesn't care.

This is the part that replaces Architectury and similar. Three classes:

  • PlatHelper for common stuff: setup callbacks, side and mod queries, and factories for the vanilla classes whose constructors differ between loaders (spawn eggs, flower pots, particle types, block entity types, entity types). Also the Forge-only block and item hooks (burn time, flammability, food properties) emulated on Fabric.
  • ClientHelper for the client: registration callbacks for renderers, colors, particles, models, keybinds, shaders, item decorators, tooltip components, reload listeners.
  • ForgeHelper for Forge hooks with no Fabric equivalent. Safe to call anywhere, it does the vanilla thing when there's no Forge.

Getting Started

public static void init() {
    // Forge/NeoForge only, must come first
    // RegHelper.startRegisteringFor(modEventBus);

    PlatHelper.addCommonSetup(MyMod::setup);
    PlatHelper.addCommonSetupAsync(() -> { /* expensive, runs off thread */ });

    if (PlatHelper.getPhysicalSide().isClient()) {
        MyModClient.init();
    }
}

private static void setup() {
    // after registration is done
    if (PlatHelper.isModLoaded("jei") && !PlatHelper.isDev()) {
        RegHelper.registerItemBurnTime(Items.SKELETON_SKULL, 2);
    }
}

Tip

On Fabric you don't need separate client and server entry points with this. One init, one getPhysicalSide() check, done.

Client side is the same shape, registration goes through small event objects:

public static void init() {
    ClientHelper.addItemColorsRegistration(event -> event.register((stack, tint) -> 0, Items.POTION));
    ClientHelper.addClientSetup(() -> ClientHelper.registerRenderType(Blocks.CYAN_STAINED_GLASS, RenderType.solid()));
}

Examples: PlatHelperExample, ClientHelperExample

Worth knowing

PlatHelper.openCustomMenu(player, provider, buf -> ...) opens a menu with extra data, which is otherwise completely different on each loader.

ClientHelper.registerOptionalTexturePack(folder, name, defaultEnabled) gives you a built in resource pack the player can toggle in the pack screen.

Clone this wiki locally