Skip to content

Platform and integrations

PlatformInfo answers which mods are loaded and whether the game runs from a development launch, the same on every loader. RecipeViewers reaches JEI, EMI, and REI without a dependency on any of them, so a mod can hide items and explain them in whichever viewer the player has.

Type Summary Status Since Side Thread
PlatformInfo Which mods are loaded, their versions, and whether this is a development launch. Experimental 2.0.0 both any
RecipeViewers Hides stacks from, and adds information pages to, the installed JEI, EMI, and REI viewers. Experimental 2.4.0 both setup

With MAPLE_SAPLING, the sapling’s Registered handle, in your mod’s common initializer:

Explain a sapling in whichever recipe viewer the player has
RecipeViewers.info(MAPLE_SAPLING,
Component.translatable("info.mymod.maple_sapling"),
Component.translatable("info.mymod.maple_sapling.giant"));

Experimental · Since 2.0.0 · Side: both · Thread: any

Check for another mod before touching its classes. With SeasonCompat, a class of your mod’s that calls Serene Seasons, and LOGGER, the mod’s SLF4J logger:

Turn on an integration only when its mod is loaded
if (PlatformInfo.isModLoaded("sereneseasons")) {
// A class of its own, so Serene Seasons' types load only when that mod is installed.
SeasonCompat.register();
String version = PlatformInfo.modVersion("sereneseasons").orElseThrow();
LOGGER.info("Maple leaves follow Serene Seasons {}", version);
}

Experimental · Since 2.4.0 · Side: both · Thread: setup

With MAPLE_SAPLING as in the quick start, and mapleEnabled, a BooleanSupplier that reads the mod’s settings:

Hide the sapling while maples are switched off
RecipeViewers.hide(() -> mapleEnabled.getAsBoolean()
? List.of()
: List.of(new ItemStack(MAPLE_SAPLING.get())));
  • REI titles an information page with the item’s name.
  • JEI and EMI list only items that are in a creative tab, so an item in no tab gets no page there; REI lists it.
  • Checked with JEI 15.74.0.234, EMI 1.1.24, and REI 12.1.785 on Minecraft 1.20.1. Their builds for Minecraft 1.20 are not checked.