Back to mods
Algernon's Terrain Sampler Lib project artwork

Vintage Story Mod DB · Vintage Story mod

Algernon's Terrain Sampler Lib

A simple tool for efficiently getting the generated terrain's height anywhere in the world. Even if the chunk hasn't been created or even loaded yet, this still works. You could sample 2 billion blocks away as long as it's within the world boundary. Use /ter

Choose a version Pick your version below, then grab the matching file.

Quick answer

Which Algernon's Terrain Sampler Lib release should I use?

Updated 15 days ago
Latest stable file 1.3.0
Game version 1.22.0, 1.22.1, 1.22.2
Loader Built-in Vintage Story mod system

Algernon's Terrain Sampler Lib 1.3.0 targets 1.22.0, 1.22.1, 1.22.2. It must be installed on the client. Installation on the dedicated server is optional. No extra mods listed for this file.

Where it goes

Is Algernon's Terrain Sampler Lib required on the client, server, or both?

It must be installed on the client. Installation on the dedicated server is optional.

Client Required
Dedicated server Optional
Loader for this release Built-in Vintage Story mod system
Required install it here Optional supported, not mandatory Not supported do not install here Source doesn’t say do not assume

This release supports both sides, but the source does not require it on the server.

What else does Algernon's Terrain Sampler Lib 1.3.0 need?

1.3.0. Change the file and its required mods may change too.

No extra mods listed for this file

This file does not list any required mods. Do not add a library just because a different file uses it.

This file does not list any required or optional mods.

Before you install it

Add Algernon's Terrain Sampler Lib without breaking your instance.

Built for Algernon's Terrain Sampler Lib 1.3.0. Pick another file and the loader, install side or required mods may change.

  1. 01

    Stick to this file

    Use 1.3.0. It targets 1.22.0, 1.22.1, 1.22.2; another release may have different loader, side or dependency requirements.

  2. 02

    Bring the mods it needs

    This file does not list any required mods. Do not add a library just because a different file uses it.

  3. 03

    Put it on the correct side

    It must be installed on the client. Installation on the dedicated server is optional.

  4. 04

    Pick the file you checked

    Use the “Get this file” button beside 1.3.0. It opens that exact file at the source.

About this project

What does Algernon's Terrain Sampler Lib add?

A simple tool for efficiently getting the generated terrain's height anywhere in the world.

Even if the chunk hasn't been created or even loaded yet, this still works. You could sample 2 billion blocks away as long as it's within the world boundary.

 

Use /terrainsampler columnheight ingame to test it out.

To get this function working in your mod, reflect this mod's assembly, then reflect sampleHeight as shown here:

foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
    Type modType = assembly.GetType("AlgernonsTerrainSampler.TerrainSamplerMod");
    if (modType == null)
        continue;

    PropertyInfo instanceProperty = modType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
    MethodInfo getHeightMethod = modType.GetMethod("GetBlockColumnHeight", BindingFlags.Public | BindingFlags.Instance, null, [typeof(int), typeof(int)], null);
    if (instanceProperty == null || getHeightMethod == null)
        break;

    object instance = instanceProperty.GetValue(null);
    int sampleHeight(int blockX, int blockZ) => (int)getHeightMethod.Invoke(instance, [blockX, blockZ]);

Then give the height sampler delegate (sampleHeight) to your code that uses terrain height samples.

 

1.3.0 Update: new sample types courtesy of Chrisunfocused from Fast Map
You can now sample for rainfall, temperature, geologic activity, forest density, and shrub density, as well as height.

Use /terrainsampler samplecolumn ingame to test it out.

To get these detailed samples working in your mod, reflect this mod's assembly, then reflect SampleColumn similar to how FastMap did it here:

https://gist.github.com/Algernon733/d0c4301197ad98adb9753c496cbd579a

 

The terrain generation usually changes every major update, so don't use this on a different major version than the one it's made for.

 

This tool was made to help Farseer and the other two LOD mods in development, but you could use it for a lot of different things.

Originally, this came from the Watersheds mod. Terrain sampling is the core foundation of what enabled me to create terrain-respecting streams.

Here are some mod ideas you could make from terrain sampling:

  • Terrain erosion effects
  • Rain shadows
  • Realistic wind flows
  • Very long roads that respect the terrain, maybe between story structures
  • Very long pathfinding routes, maybe for animal herds or trader routes
  • Rivers and streams
  • Realistic pond, lake, and spring placement
  • Realistic snow depths (unsheltered areas have less snow, sheltered has more snow)
  • Realistic fog areas (in sheltered areas)
  • Groundwater and aquifers (a basic groundwater system is in Watersheds)
  • Strategic/believable placement of ruins/structures/villages

 

Mods using this sampler:

 

Looking for help:

Compatability with Conquest Landform Overhaul's configurable landforms 

Project description from Vintage Story Mod DB.

Pick your setup

Algernon's Terrain Sampler Lib releases for each Vintage Story version.

Choose the version and loader you play, then open the matching release.

22 available setups

Showing the newest 12 of 22 game versions. Older files are in the list below.

Check the dependencies, then try the file in a copied instance before changing a world you care about.

Recent files

Algernon's Terrain Sampler Lib versions and loaders

4 of 4 releases match

Looking for an older file? The official Vintage Story Mod DB project page is in Resources.