Skip to content

Outcrop API

Outcrop’s API lets another mod change or replace the signs Outcrop sets over ore while a world generates. Most changes need no code: indication rules, background pebble lists, and tags live in data packs, as the player guide lists. Use the API when a data pack cannot say what you need.

The API is experimental: it may change in a minor release.

Outcrop is in the KillenCraft Maven repository at https://maven.someguy.us, one artifact per loader: us.someguy:outcrop-fabric and us.someguy:outcrop-forge. A version is Outcrop’s version, then +, then the first and last Minecraft version the jar runs on. The repository’s Fabric version list and Forge version list name each.

repositories {
exclusiveContent {
forRepository { maven { url = "https://maven.someguy.us/" } }
filter { includeGroup "us.someguy" }
}
}
dependencies {
// In a Forge project: us.someguy:outcrop-forge and us.someguy:stope-forge
modImplementation "us.someguy:outcrop-fabric:<version from the list>"
modImplementation "us.someguy:stope-fabric:<Stope version>"
}

Outcrop’s entry in the repository lists no dependencies. It needs Stope at runtime, in the version the Outcrop overview names, so add Stope’s artifact as well (Using Stope from a mod). Each release has a sources jar beside its jar, so an IDE shows the API’s Javadoc with no setup. The Javadoc states each type’s contract in full; this page summarizes it.

Register listeners during mod initialization, in common code. This one stops Outcrop from placing any sign over iron:

Cancel every iron indication
ResourceLocation iron = new ResourceLocation("outcrop", "iron");
IndicationEvent.EVENT.register(indication ->
indication.deposit().oreType().equals(iron) ? EventResult.CANCEL : EventResult.PASS);

For each chunk that generates, Outcrop finds the deposits of each ore type and rolls each deposit’s chance. For a deposit that wins:

  1. Outcrop plans a scatter of pebbles and plants, unless the rule has a ScatterPlacer. A planned scatter with no indicator pebble or no ordinary pebble is dropped here, and no event fires for it.
  2. IndicationEvent fires with the Deposit and the planned pieces. Listeners run in registration order.
  3. A listener that returns EventResult#CANCEL ends the event: nothing is placed, and later listeners do not run.
  4. Otherwise, if the rule has a ScatterPlacer, Outcrop calls it and places nothing of its own. With no placer, Outcrop places the pieces as the listeners left them.

Listeners and placers run on world generation worker threads, several chunks at a time. Each may touch only the deposit’s chunk, through the level it is given, and draws its random choices from the given RandomSource, so one seed gives the same world every time.

Use IndicationEvent to adjust Outcrop’s own scatters: drop a piece, swap a pebble for a block of your mod’s, or cancel the sign in places it should not appear. Here MyBlocks.GOLD_FERN is your mod’s plant:

Swap horsetail for your own plant
ResourceLocation horsetail = new ResourceLocation("outcrop", "horsetail");
IndicationEvent.EVENT.register(indication -> {
indication.pieces().replaceAll(piece ->
BuiltInRegistries.BLOCK.getKey(piece.state().getBlock()).equals(horsetail)
? new Indication.Piece(piece.pos(), MyBlocks.GOLD_FERN.defaultBlockState())
: piece);
return EventResult.PASS;
});

A pebble’s block ID is its name with _pebble, as in outcrop:gossan_pebble; a plant’s is its name alone, as in outcrop:copper_flower.

  • Pieces you add or change skip Outcrop’s placement checks, so keep them on air or a water source over solid ground.
  • Outcrop writes at most 12 pieces, and only those inside the deposit’s chunk.
  • A listener that throws is logged once and its changes are undone; the listeners after it still run.
  • For a rule with a ScatterPlacer, the piece list is empty, and pieces added to it are ignored.

Use a ScatterPlacer when a rule’s sign is not a scatter of pebbles at all, such as a mossy stone or a stained patch of ground. Register it with OutcropApi#registerScatterPlacer for one rule ID. For an ore no rule covers, the ID is the ore block’s own ID, as here:

Place a mossy stone over your ore
OutcropApi.registerScatterPlacer(new ResourceLocation("mymod", "tin_ore"), (level, deposit, random) -> {
BlockPos at = deposit.center();
BlockPos ground = at.below();
if (level.getBlockState(at).isAir()
&& level.getBlockState(ground).isFaceSturdy(level, ground, Direction.UP)) {
level.setBlock(at, Blocks.MOSSY_COBBLESTONE.defaultBlockState(), Block.UPDATE_CLIENTS);
}
});

Deposit#center is already at the surface, inside the chunk. The placer writes the sign itself, and Outcrop checks none of its writes. A placer that throws is logged once, and that sign is skipped.