Page last edited 1,633 days 3 hours ago
From COG Docs
Jump to: navigation, search

The Veins algorithm creates narrow spidery distributions that keep player moving while mining.

Veins Algorithm

Iron veins with 2-4 long branches per motherlode

The Veins algorithm creates a round central "motherlode" with branches radiating in all directions. The branches are composed of short straight "Segments" which are joined end-to-end in a chain extending away from the motherlode. Branches may fork, and the forks may themselves fork and so on, creating a tree structure rooted at the motherlode.

There are two distinct types of branches. For Ellipsoid branches the ore is placed in an ellipsoid (a 3D oval) along each segment. The segments are therefore thickest in the middle and thinest at the ends where they meet. These branches are faster to generate but are not very smooth. For Bezier branches, the ore is placed in a tube that curves smoothly from segment to segment. These branches are slower to generate but tend to be much easier to follow underground.

The <Veins> element creates a distribution using the veins algorithm. The <VeinsPreset> element creates a non-generating distribution that can be used as a source of default settings. <Veins> elements support all of the standard distribution features.


The Veins algorithm may have the following attributes:

Attribute Default Value Description
name procedurally generated A name used to identify the distribution. This is used by other distributions to inherit default parameter values, for log messages, and for debugging console commands. It is recommended (but not required) that distribution names be unique and contain no whitespace.
seed unique value based on order in config file A seed modifier for random numbers generated by this distribution. If two distributions have similar settings and the same seed, they will share the same geometry.
block none The blockID or internal name of the block to be placed (with weight 1.0). <OreBlock> elements can be used as well, or instead, but the block attribute is often shorter and easier to read.
inherits hard-coded defaults Another Veins distribution from which to inherit all default parameter values except the name and seed.
branchType Bezier This determines what kind of branches are created.
  • Ellipsoid branches are the older style branches made from independent elliptical segments strung end-to-end.
  • Bezier branches are a newer style in which the segments are curved to produce a smoothly continuous tube.
drawWireframe* false Whether or not to draw a wireframe model around the distribution.
wireframeColor* 0xFF169E09 The color of the debugging wireframe, if one is drawn. The format is ARGB, "packed" into an integer so that the highest byte is the alpha component and the lowest byte is the blue component.
drawBoundBox* false Whether or not to draw bounding boxes for the distribution.
boundBoxColor* 0x80000000 The color of the bound boxes, if they are drawn. The format is the same as for wireframeColor above.
* These attributes are only meaningful in debugging mode.


The Veins algorithm has the following settings:

Veins Settings
Setting Default Value Description
MotherlodeFrequency 0.025 A.K.A. "DistributionFrequency." The number of motherlodes per 16x16 chunk. Values greater than one can produce multiple motherlodes in a single chunk.
MotherlodeRangeLimit 32 ± 32 (normal) A.K.A. "ParentRangeLimit." The maximum horizontal distance a motherlode of this distribution may spawn from the center of the nearest motherlode/cloud/cluster of its parent distribution. Differences in height do not count - only distance in the XZ plane. If the distribution has no parent, this setting is ignored.
MotherlodeSize 2.5 ± 1.0 Size (radius) of motherlodes, in meters. The radius along each axis is an independent random value. Higher ranges will produce more irregular shapes.
MotherlodeHeight 32 ± 16 (normal) Height at which motherlodes generate, in meters.
BranchFrequency 3 ± 2 The number of branches per motherlode.
BranchInclination 0 ± 0.55 The angle from the horizontal XZ plane at which branches leave the motherlode, in radians. Note that branches may curve, so their direction can change after the first segment. Low values will create horizontal branches and high values create vertical branches.
BranchLength 120 ± 60 The length of each branch, in meters. Note that this is total length, not just distance from motherlode. Branches that twist and turn a lot may reach their final length without getting very far from the motherlode.
BranchHeightLimit 16 The maximum vertical distance a branch can extend from the motherlode, in meters. This sets a "ceiling" and a "floor" around the motherlode. Branches that would extend upwards through the ceiling or down through the floor are truncated. Use with a low BranchInclination to keep branches mostly horizontal.
SegmentForkFrequency 0.2 The probability that a branch will fork into two or more branches at the end of a segment. Values higher than 1.0 can cause the branch to split into more than two child branches.
SegmentForkLengthMult 0.75 ± 0.25 A multiplier to the remaining branch length applied to every fork. Values are forced into the range [0 - 1], so that forks cannot be longer than the main branch.
SegmentLength 15 ± 6 The length of each straight branch segment, in meters.
SegmentAngle 0.5 ± 0.5 The angle at which each segment diverges from the last segment in the branch, in radians. Low values form gentle curves, higher values form erratic zig-zags.
SegmentRadius 0.5 ± 0.3 The cross-sectional radius of each segment at it's thickest point, in meters. For Ellipsoid branches, values less than ~0.3 will produce a segment with no actual ore blocks. For Bezier branches, values less than ~0.25 will produce broken or intermittent branches.
OreDensity 1 A per-block density multiplier. This setting multiplies the weight of each ore block to determine the overall probability that that block will be placed. It can vary from 0 (no ore blocks placed) to 1 (all ore blocks placed).
OreRadiusMult 1.0 ± 0.1 A per-block multiplier to the maximum allowable radius for motherlodes and segments. An average of 1.0 is recommended. Increasing the range will make ore placement more "ragged" at the edges.

Ore Blocks

<OreBlock> elements can be used to specify a mixture of ore blocks to spawn with fractional weights. The total weight of all ore blocks must be less than 1.0.


<Replaces> elements can be used to change which blocks a Veins distribution will replace (the default is just smooth stone).


<Biome> elements can be used to customize which biomes a Veins distribution will spawn in (the default is all biomes).

Parents and Nesting

A <Veins> element may be placed inside another Veins, Cloud, or StandardGen element. The parent distribution will continue to spawn normally, but the child will only spawn near it's parent. More accurately, the child distribution Motherlodes will only spawn near the motherlodes, clouds, or clusters of the parent distribution. The exact range is determined by the MotherlodeRangeLimit setting.


<!-- A veins distribution named "SnowVeins" -->  
<!-- All defaults are inherited from "PresetLayeredVeins", which must be defined somewhere above -->  
<!-- The branch type is Bezier -->  
<Veins name='SnowVeins' inherits='PresetLayeredVeins' branchType='Bezier'>

    <!-- These veins will place a 50/50 mixture of snow and ice -->  
    <OreBlock block='snow' weight='0.5'/>
    <OreBlock block='ice' weight='0.5'/>

    <!-- The frequency is 0.025 motherlodes/chunk, scaled by the "oreFreq" option -->  
    <!-- The height ranges from 32.5 to 53.5, but is most like to be near y=43 --> 
    <Setting name='MotherlodeFrequency' avg=':= 0.025 * oreFreq'/>
    <Setting name='MotherlodeHeight' avg='43' range='10.5' type='normal' /> 
    <!-- These veins will only spawn in Taiga biomes --> 
    <Biome name='Taiga'/>  

    <!-- They will replace stone 100% of the time, 
         but dirt and gravel only 50% of the time --> 
    <Replaces name='stone'/>
    <Replaces name='dirt' weight='0.5'/>
    <Replaces name='gravel' weight='0.5'/>

    <!-- A child distribution.  It will only spawn near the parent. -->    
    <Veins name='ChildDistribution' block='ice'/>