🏗️ Generation#
#bs.generation:help
Generate diverse terrains and landscapes, incorporating natural features.
“Nature’s beauty is a reflection of the harmony of numbers and patterns.”
—Anonymous
🔧 Functions#
You can find below all functions available in this module.
Shape 2D#
- #bs.generation:gen_shape_2d
Generate a shape in 2D space at the specified origin, with the callback executed at each step, allowing the user to handle the X and Y coordinates directly.
- Inputs:
Execution
at <entity>orpositioned <x> <y> <z> rotated <rot>: Origin of the shape.Function macro:
Arguments
run: Callback to run at each step. For each step, the following scores can be used:
$generation.x bs.lambda: The X coordinate of the current step.$generation.y bs.lambda: The Y coordinate of the current step.
width: Width of the shape to generate.
height: Height of the shape to generate.
with: Shape settings.
direction: Plane used to generate the shape (
xz,xy, orzy, default:xz).spacing: Distance between blocks in the generated shape (default: 1).
limit: Limit how many steps are executed in a single tick (default: 256).
- Outputs:
State: The callback gets executed at the appropriate coordinates in the world.
- #bs.generation:gen_simplex_shape_2d
Generate a shape in 2D space using a Simplex noise algorithm. The shape is generated at the specified origin, with the callback executed at each step to facilitate custom behavior during the generation process.
- Inputs:
Execution
at <entity>orpositioned <x> <y> <z> rotated <rot>: Origin of the shape.Function macro:
Arguments
run: Callback to run at each step. For each step, the following scores can be used:
$generation.noise bs.lambda: The noise value in the range [-1000, 1000].$generation.x bs.lambda: The X coordinate of the current step.$generation.y bs.lambda: The Y coordinate of the current step.
width: Width of the shape to generate.
height: Height of the shape to generate.
with: Shape settings.
direction: Plane used to generate the shape (
xz,xy, orzy, default:xz).spacing: Distance between blocks in the generated shape (default: 1).
limit: Limit how many steps are executed in a single tick (default: 256).
size: Granularity of the noise. Lower values increase detail (default: 32).
seed: Seed for the noise generation, allowing for reproducibility (default: random).
- Outputs:
State: The callback gets executed at the appropriate coordinates in the world.
- #bs.generation:gen_fractal_shape_2d
Generate a shape in 2D space using a Fractal noise algorithm. The shape is generated at the specified origin, with the callback executed at each step to facilitate custom behavior during the generation process.
- Inputs:
Execution
at <entity>orpositioned <x> <y> <z> rotated <rot>: Origin of the shape.Function macro:
Arguments
run: Callback to run at each step. For each step, the following scores can be used:
$generation.noise bs.lambda: The noise value in the range [-1000, 1000].$generation.x bs.lambda: The X coordinate of the current step.$generation.y bs.lambda: The Y coordinate of the current step.
width: Width of the shape to generate.
height: Height of the shape to generate.
with: Shape settings.
direction: Plane used to generate the shape (
xz,xy, orzy, default:xz).spacing: Distance between blocks in the generated shape (default: 1).
limit: Limit how many steps are executed in a single tick (default: 256).
size: Granularity of the noise. Lower values increase detail (default: 32).
seed: Seed for the noise generation, allowing for reproducibility (default: random).
octaves: Number of noise layers; more octaves enhance detail (default: 2).
persistence: Contribution of each octave. Higher means more detail (default: 0.5).
lacunarity: Frequency increase for each octave. Higher means more rapid frequency increase (default: 2.0).
- Outputs:
State: The callback gets executed at the appropriate coordinates in the world.
Example: Generate a 3D terrain using a heightmap. This function employs a linear approach; for more interesting terrain, consider scaling the noise values differently according to various ranges. Check out this video for more insights on terrain generation:
# Once
function #bs.generation:gen_fractal_shape_2d {width:64,height:64,run:"function mypack:generate",with:{}}
# mypack:generate
execute store result storage bs:ctx y int .01 run scoreboard players add $random.fractal_noise_2d bs.out 1000
function mypack:fill with storage bs:ctx
# mypack:fill
$fill ~ ~ ~ ~ ~$(y) ~ stone
Credits: Aksiome
💬 Did it help you?
Feel free to leave your questions and feedback below!
