

Algernon's Terrain Sampler Lib
Library that lets you quickly see what terrain looks like anywhere in the world
Description
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:
<pre class="language-csharp">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]);
</pre> 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
Ratings & reviews
Sign in to leave a rating or comment.
