描述
TerraMath 是一款适用于 Minecraft 1.20 - 1.21.x 的模组,允许你使用数学函数自定义世界生成。通过定义地形高度的数学公式,创造独特的地貌景观!
你也可以加入我的 Discord 以获取更多公式或分享你自己的公式。
功能
- 通过数学公式自定义世界生成
- 可调整的基础生成参数(缩放、高度、变化幅度、平滑度)
- 支持在基础公式之上配置噪声叠加层
- 公式中支持使用数学常数
客户端使用方法
参数配置
- 在世界创建界面的“World”选项卡中
- 打开地形设置界面
- 在字段中输入你想要的公式
- 调整其他参数(可选):
- Scale(缩放比例)
- Base Height(基础高度,决定平均地表水平面)
- Height Variation(高度变化,变化的振幅)
- Smoothing(平滑度,地形过渡的平滑程度)
- 选择噪声类型和设置(可选):
- 噪声类型:Perlin、Simplex、Blended、Normal
- X, Y, Z 坐标乘数
- 通用噪声高度乘数
服务器端使用方法
- 安装 TerraMath 模组后启动服务器
- 检查 config 文件夹,其中会包含一个
terramath.json 文件
- 手动在文件中设置必要的参数,或者...
- ...在你的客户端上配置该模组
- 设置参数并保存配置文件
- 将配置文件传输到服务器的 config 文件夹中
重要服务器注意事项:
- 要使配置对新世界生效,请确保配置文件中的
useDefaultFormula 参数设置为 true
- 更改配置设置后,你需要删除现有世界并重启服务器,新的地形公式才会生效
- 或者,你可以将整个世界文件夹从客户端传输到服务器——世界将继续按照相同的公式生成,无需更改配置
公式示例
-
基本波浪地形:sin(x)

-
带有陡峭坡度的尖刺状火山地形:abs(sin(x/10))*exp(cos(z/15))*8 + tanh(sqrt(x^2 + z^2)/20)*15

-
起伏的山脉:sin(x/8)*cos(z/8)*10 + abs(sin(x/20))*15 + sqrt(abs(x/10))*5

-
一些疯狂且复杂的计算:round(sin(x/15))*10 + round(cos(z/15))*10 + sqrt(abs(sin((x+z)/20)))*15

-
带有高原的梯田地形:floor(sin(x/20) * cos(z/20) * 5) * 4 + sqrt(x^2 + z^2)/10

-
布满陨石坑的地形:10 * (1 - exp(-((x/30)^2 + (z/30)^2) / 2)) + 5 * perlin(x/50, 0, z/50)

可用函数与运算符
数学函数:
三角函数:
- sin(x) - 正弦
- cos(x) - 余弦
- tan(x) - 正切
- csc(x) - 余割
- sec(x) - 正割
- cot(x) - 余切
- asin(x) - 反正弦
- acos(x) - 反余弦
- atan(x) - 反正切
- atan2(x,y) - 双变量反正切
- acsc(x) - 反余割
- asec(x) - 反正割
- acot(x) - 反余切
双曲函数:
- sinh(x) - 双曲正弦
- cosh(x) - 双曲余弦
- tanh(x) - 双曲正切
- asinh(x) - 反双曲正弦
- acosh(x) - 反双曲余弦
- atanh(x) - 反双曲正切
- csch(x) - 双曲余割
- sech(x) - 双曲正割
- coth(x) - 双曲余切
- acsch(x) - 反双曲余割
- asech(x) - 反双曲正割
- acoth(x) - 反双曲余切
根式与幂运算:
- sqrt(x) - 平方根
- cbrt(x) - 立方根
- root(x,n) - x 的 n 次方根
- pow(x,y) - x 的 y 次幂
- exp(x) - 指数函数 (e^x)
对数函数:
- ln(x) - 自然对数
- lg(x) - 以 10 为底的对数
四舍五入与数值函数:
- abs(x) - 绝对值
- floor(x) - 小于 x 的最大整数
- ceil(x) - 大于 x 的最小整数
- round(x) - 四舍五入到最近的整数
- sign(x) - 返回 x 的符号(-1、0 或 1)
- mod(x,y) - x 除以 y 的余数
- gcd(x,y) - 最大公约数
- lcm(x,y) - 最小公倍数
- modi(x,y) - 模逆元
特殊函数:
- gamma(x) - Gamma 函数
- erf(x) - 误差函数
- beta(x,y) - Beta 函数
随机数生成:
- rand() - 0 到 1 之间的随机数
- randnormal(mean,stdev) - 符合正态分布的随机数
- randrange(min,max) - min 到 max 之间的随机数
噪声函数:
- perlin(x,y,z) - Perlin 噪声
- simplex(x,y,z) - Simplex 噪声
- normal(x,y,z) - 高斯噪声(Normal noise)
- blended(x,y,z) - 混合噪声
- octaved(x,z,octaves,persistence) - 分形噪声(Octaved noise)
实用函数:
- max(x,y) - x 和 y 中的最大值
- min(x,y) - x 和 y 中的最小值
- sigmoid(x) - Sigmoid 函数 (1/(1+e^-x))
- clamp(x,min,max) - 将 x 限制在 min 和 max 之间
常量:
- pi, π - 3.14159... (π 常数)
- e - 2.71828... (自然常数)
- phi, φ - 1.61803... (黄金分割率)
- zeta3, ζ3 - 1.20205... (阿佩里常数)
- catalan, K - 0.91596... (卡特兰常数)
- alpha, α, feigenbaum - 2.50290... (费根鲍姆常数)
- delta, δ, feigenbaumdelta - 4.66920... (费根鲍姆 δ)
- omega, Ω - 0.6889 (宇宙学常数)
变量:
x, y, z - 世界中的方块坐标
运算符:
+, -, *, /, ^, (), !
已知问题
- 生成 XXL 级地形的极端公式可能会影响性能(这可能是一个无法完全解决的问题)
- 如果广泛使用随机数生成函数,会显著影响世界生成的性能。建议谨慎使用这些函数,特别是在复杂的地形公式中,因为它们可能导致帧率下降或区块加载时间增加
贡献
欢迎通过 Issue Tracker 报告错误或提出功能建议!
Description
TerraMath is a Minecraft 1.20 - 1.21.x mod that allows you to customize world generation using mathematical functions. Create unique landscapes by defining terrain height through mathematical formulas!
You can also join my Discord to find more formulas or share yours.
Features
- Custom world generation through mathematical formulas
- Adjustable basic generation parameters (scale, height, variation, smoothing)
- Configurable noise overlay on top of your base formula
- Support for mathematical constants in formulas
How to Use on Client
- World generation settings interface
Parameter Configuration
- Go to "World" tab in world creation screen
- Open the terrain settings screen
- Enter your desired formula in the field
- Adjust additional parameters (optional):
- Scale
- Base Height (determines average surface level)
- Height Variation (amplitude of changes)
- Smoothing (terrain transition smoothness)
- Choose noise type and settings (optional):
- Noise type: Perlin, Simplex, Blended, Normal
- X, Y, Z coordinate multipliers
- General noise height multiplier
How to Use on Server
- Start the server with TerraMath mod installed
- Check the config folder, there will be a
terramath.json file
- Set the necessary parameters manually in the file, or...
- ...configure the mod on your client
- Set the parameters and save the config
- Transfer the config file to the server's config folder
Important Server Notes:
- For the config to apply to a new world, make sure the
useDefaultFormula parameter in the config is set to true
- After changing config settings, you'll need to delete the existing world and restart the server for the new terrain formula to take effect
- Alternatively, you can transfer your entire world folder from a client to the server - the world will continue to generate according to the same formula without requiring config changes
Formula Examples
-
Basic wavy landscape: sin(x)

-
Spiky volcanic-like terrain with steep slopes: abs(sin(x/10))*exp(cos(z/15))*8 + tanh(sqrt(x^2 + z^2)/20)*15

-
Rolling mountains: sin(x/8)*cos(z/8)*10 + abs(sin(x/20))*15 + sqrt(abs(x/10))*5

-
Some crazy and heavy thing: round(sin(x/15))*10 + round(cos(z/15))*10 + sqrt(abs(sin((x+z)/20)))*15

-
Terraced landscape with plateaus: floor(sin(x/20) * cos(z/20) * 5) * 4 + sqrt(x^2 + z^2)/10

-
Crater-filled terrain: 10 * (1 - exp(-((x/30)^2 + (z/30)^2) / 2)) + 5 * perlin(x/50, 0, z/50)

Available Functions and Operators
Mathematical Functions:
Trigonometric:
- sin(x) - sine
- cos(x) - cosine
- tan(x) - tangent
- csc(x) - cosecant
- sec(x) - secant
- cot(x) - cotangent
- asin(x) - inverse sine
- acos(x) - inverse cosine
- atan(x) - inverse tangent
- atan2(x,y) - two-argument inverse tangent
- acsc(x) - inverse cosecant
- asec(x) - inverse secant
- acot(x) - inverse cotangent
Hyperbolic:
- sinh(x) - hyperbolic sine
- cosh(x) - hyperbolic cosine
- tanh(x) - hyperbolic tangent
- asinh(x) - inverse hyperbolic sine
- acosh(x) - inverse hyperbolic cosine
- atanh(x) - inverse hyperbolic tangent
- csch(x) - hyperbolic cosecant
- sech(x) - hyperbolic secant
- coth(x) - hyperbolic cotangent
- acsch(x) - inverse hyperbolic cosecant
- asech(x) - inverse hyperbolic secant
- acoth(x) - inverse hyperbolic cotangent
Root and Power:
- sqrt(x) - square root
- cbrt(x) - cube root
- root(x,n) - nth root of x
- pow(x,y) - x raised to power y
- exp(x) - exponential (e^x)
Logarithmic:
- ln(x) - natural logarithm
- lg(x) - base-10 logarithm
Rounding and Numbers:
- abs(x) - absolute value
- floor(x) - largest integer less than x
- ceil(x) - smallest integer greater than x
- round(x) - rounds to nearest integer
- sign(x) - returns sign of x (-1, 0, or 1)
- mod(x,y) - remainder of x divided by y
- gcd(x,y) - greatest common divisor
- lcm(x,y) - least common multiple
- modi(x,y) - modular inverse
Special Functions:
- gamma(x) - gamma function
- erf(x) - error function
- beta(x,y) - beta function
Random Number Generation:
- rand() - random number between 0 and 1
- randnormal(mean,stdev) - random number from normal distribution
- randrange(min,max) - random number between min and max
Noise Functions:
- perlin(x,y,z) - perlin noise
- simplex(x,y,z) - simplex noise
- normal(x,y,z) - normal noise
- blended(x,y,z) - blended noise
- octaved(x,z,octaves,persistence) - octaved noise
Utility Functions:
- max(x,y) - maximum of x and y
- min(x,y) - minimum of x and y
- sigmoid(x) - sigmoid function (1/(1+e^-x))
- clamp(x,min,max) - constrains x between min and max
Constants:
- pi, π - 3.14159... (π constant)
- e - 2.71828... (Euler's number)
- phi, φ - 1.61803... (Golden ratio)
- zeta3, ζ3 - 1.20205... (Apéry's constant)
- catalan, K - 0.91596... (Catalan's constant)
- alpha, α, feigenbaum - 2.50290... (Feigenbaum constant)
- delta, δ, feigenbaumdelta - 4.66920... (Feigenbaum delta)
- omega, Ω - 0.6889 (Cosmological constant)
Variables:
x, y, z - block coordinates in world
Operators:
+, -, *, /, ^, (), !
Known Issues
- Extreme formulas that produce XXL landscapes may impact performance (probably not a completely solvable problem)
- Random number generation functions can significantly impact world generation performance when used extensively. Consider using these functions sparingly, especially in complex terrain formulas, as they may cause frame rate drops or increased chunk loading time
Contributing
Feel free to report bugs or suggest features through the issue tracker!
评论 0
登录后参与评分
还没有评论,来抢沙发吧