NeoTerrain Diffusion
本项目是原版 Fabric
Terrain Diffusion Minecraft 模组
的 NeoForge 移植版,
它将
Terrain Diffusion 世界生成模型
整合进了 Minecraft。
当前状态
此移植版目前仅支持服务端使用。
它专为 NeoForge 专用服务器设计。目前尚无法完全替代 Fabric 模组的客户端侧世界创建流程、客户端界面或单人游戏设置。
对于此服务器,世界设置通过 server.properties 完成,而非 Minecraft 客户端的“创建世界”屏幕。
已验证的本机服务器
此实现已在以下环境中构建并验证:
- Minecraft
1.21.1
- NeoForge
21.1.233
- Java
21
- Windows 10/11
- DirectML GPU 推理
- 专用服务器运行时
已验证的 jar 文件:
terrain-diffusion-mc-neoforge-2.2.0-neoforge.1-windows+1.21.1.jar
使用此模组运行的本机服务器位于:
C:\Users\Collin\Desktop\Server 1.21.1
要求
- 一个 NeoForge
1.21.1 专用服务器
- 同一
21.1.x 系列中 NeoForge 21.1.233 或更高版本
- Java 21
- 带有 DirectML 兼容 GPU 的 Windows 系统(用于已验证的构建)
- 至少约 1.5 GB 可用显存 (VRAM)
- 加载模型时额外需要约 2.5 GB 系统内存 (RAM)
- 首次启动时需要联网,以便下载模型文件
此本机服务器的启动器使用的是以下 Java 21 运行时:
C:\Users\Collin\AppData\Roaming\ModrinthApp\meta\java_versions\zulu21.48.17-ca-jre21.0.10-win_x64\bin\java.exe
GPU 行为
Windows 构建版使用 DirectML 进行 GPU 推理。
正确的启动日志应包含以下内容:
Terrain diffusion inference: DirectML
ONNX model 'coarse' loaded on GPU
ONNX model 'base' loaded on GPU
ONNX model 'decoder' loaded on GPU
此移植版的 Windows 构建优先使用 DirectML,正常启动期间不应警告缺少 CUDA。此 Windows 服务器构建不需要 CUDA。
服务器安装
将 NeoForge jar 文件放入专用服务器的 mods 文件夹中。
对于此本机服务器,jar 文件保留在链接的 Modrinth 配置文件的 mods 文件夹中,以便服务器同步步骤能将其复制到:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\mods
同步脚本还使用以下文件从服务器运行时中排除已知的客户端/渲染专用模组:
C:\Users\Collin\Desktop\Server 1.21.1\server-mod-exclusions.txt
本地服务器
运行:
C:\Users\Collin\Desktop\Server 1.21.1\Start-Server.bat
该启动器执行以下操作:
- 从 Modrinth 配置文件同步兼容服务器的模组。
- 确保被排除的客户端/渲染 jar 文件不会出现在
server-runtime\mods 中。
- 使用 Java 21 启动 NeoForge 专用服务器。
创建 Terrain Diffusion 服务器世界
由于目前这是服务端移植版,请在
server.properties 中配置世界。
当前本机服务器配置如下:
level-name=terrain-diffusion-world
level-type=terrain-diffusion-mc\:terrain_diffusion
正在使用的文件位于:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\server.properties
首次启动时,模组会在以下位置下载并准备模型文件:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\terrain-diffusion-models
配置
服务器配置文件创建于:
config\terrain-diffusion-mc.properties
对于此本机服务器,完整路径为:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\config\terrain-diffusion-mc.properties
当前的调整值:
# 推理设备:"cpu"、"gpu" 或 "auto"。
# 在 Windows 构建中,"gpu" 意味着 DirectML。
inference.device=gpu
# 保持所有三个模型加载在 GPU 上,而不是在管道阶段之间重建 DirectML 会话。当有足够的显存时,这速度更快。
inference.offload_models=false
# 验证磁盘上已有模型文件的 SHA-256。
validate_model=true
# /td-explore 的本地 Web UI 端口。
explorer.port=19801
# 地形生成区域边长(以方块为单位)。必须是 2 的幂。
tile_size=256
# 出生点陆地搜索粗略像素区域大小。
spawn_search.initial_size=16
spawn_search.max_size=128
如果显存变得紧张,请设置:
inference.offload_models=true
这会降低峰值显存占用,但可能会减缓生成速度。
地形探索器
此移植版包含了服务端的地形探索器命令:
/td-explore
在游戏中运行它。服务器会打印出一个本地 Web UI 链接,通常是:
http://localhost:19801
使用探索器在游戏内旅行之前,先侦察大陆、山脉、岛屿、气候和有用的坐标。
世界规模
服务端移植版支持世界规模值 1..6。
默认规模为 2。
对于专用服务器世界,所选规模存储在世界存档中:
terrain-diffusion-world\data\terrain_diffusion_world_settings.dat
规模行为说明:
scale=1 更紧凑,且会更频繁地运行 Terrain Diffusion。
scale=2 是可玩性和性能的默认平衡值。
- 更高的规模值会使每个生成的地形样本覆盖更多的方块,并将更多工作转移到 Minecraft 的 CPU 侧世界生成上。
由于此移植版目前仅支持服务端,在此设置中没有受支持的客户端世界创建自定义屏幕来更改规模。请将规模视为服务器世界存档的一部分。
常见问题
CUDA not available
此 Windows DirectML 构建不应发出该警告。如果出现,则服务器可能正在运行旧的 jar 文件或错误的构建变体。请重新安装 Windows DirectML jar 并重新运行服务器模组同步。
DirectML not available
更新 GPU 驱动程序并确认机器拥有 DirectML 兼容的 GPU。为了在没有 GPU 加速的情况下启动以进行故障排除,请设置:
inference.device=cpu
CPU 推理速度慢得多,不建议用于常规服务器使用。
A dynamic link library (DLL) initialization routine failed
使用当前的 Java 21 运行时环境。经过验证的本地服务器通过 Start-Server.bat 使用 Modrinth 提供的 Zulu Java 21 运行时。
java.lang.IllegalStateException: Failed to load terrain-diffusion models
这通常意味着发生了以下情况之一:
- 模型下载失败。
- 某个模型文件验证失败。
- 服务器在加载模型时内存或显存不足。
请检查最新的服务器日志以及以下目录中的文件:
server-runtime\terrain-diffusion-models
服务器生成了普通世界
请检查 server.properties 并确认:
level-type=terrain-diffusion-mc\:terrain_diffusion
同时请确认 Terrain Diffusion jar 文件存在于 server-runtime\mods 中。
构建此移植版本
请使用 Java 21 JDK 进行 Gradle 构建。
在本机上,以下 JDK 可用:
C:\Program Files\Android\openjdk\jdk-21.0.8
构建 Windows DirectML 版本的 jar:
$env:JAVA_HOME='C:\Program Files\Android\openjdk\jdk-21.0.8'
$env:Path="$env:JAVA_HOME\bin;$env:Path"
.\gradlew.bat build -PuseDml=true
构建好的 jar 将写入:
build\libs\terrain-diffusion-mc-neoforge-2.2.0-neoforge.1-windows+1.21.1.jar
对于本地服务器,请将重新构建的 jar 复制到以下两个位置:
C:\Users\Collin\Desktop\Server 1.21.1\mods
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\mods
然后进行验证:
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Users\Collin\Desktop\Server 1.21.1\Sync-ServerMods.ps1"
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Users\Collin\Desktop\Server 1.21.1\Validate-ServerBoot.ps1" -TimeoutSeconds 900
预期结果:
Result: done
Terrain diffusion inference: DirectML
生成搜索:用于在 (0, 0) 附近寻找陆地出生点的粗像素区域大小。
从 initial_size x initial_size 开始,每步扩大 8,直到 max_size x max_size。
每个粗像素覆盖很大的区域(数百个方块),因此 16–128 通常已足够。
spawn_search.initial_size=16
spawn_search.max_size=128
### 按世界设置
对于 Terrain Diffusion 世界,在世界创建界面点击 **Customize** 并设置:
- `World Scale`(整数 `1..6`)
该值会随世界存档保存,并影响:
- 每个方块代表的实际米数(`scale=1` => `30m/block`,`scale=2` => `15m/block`,依此类推)
- 新创建世界的最大高度(假设最高点为 10000 实际米)
- 推荐值为 2,可在规模和可玩性之间取得良好平衡。若希望更小、更紧凑的世界,请使用 1。
- 较低的值会给 GPU 带来更大压力(Terrain Diffusion 运行更频繁),而较高的值会给 CPU 带来更大压力(世界高度更大)。大多数现代 GPU 在 scale 2 或 3 左右时会受限于 CPU。
## 常见问题
**动态链接库 (DLL) 初始化例程失败**
这可能发生在某些较旧的 Java 版本上。请更新到最新版本的 Java 21 或更高版本。[最新版 Microsoft OpenJDK 21](https://learn.microsoft.com/en-us/java/openjdk/download) 已知可以正常工作。
**LoadLibrary failed with error 126** *(仅限 CUDA 构建版)*
这通常是由于 CUDA 或 cuDNN 安装不当所致。请参阅 [CUDA_INSTALL.md](CUDA_INSTALL.md) 获取故障排除步骤。
**java.lang.IllegalStateException: Failed to load terrain-diffusion models**
这通常表示“内存不足”错误(日志中也应显示此信息)。
Terrain Diffusion 的模型占用约 2.5GB 内存,因此请确保分配足够的内存以容纳这些模型。
**如果您的问题仍未解决,请在此处 [提出 Issue](https://github.com/xandergos/terrain-diffusion-mc/issues/new)。**
## 从源码构建
构建过程中需要网络连接,以便从 Hugging Face 获取固定的模型清单元数据。
`-windows` 构建版依赖 `libs/onnxruntime-dml.jar`,该文件作为仓库的一部分提供。参见 [使用 DirectML 构建 onnxruntime](#building-onnxruntime-with-directml) 了解如何从源码构建。
构建 Windows (DirectML) 版本:
./gradlew build -PuseDml=true
构建 CUDA 版本:
./gradlew build -PuseCuda=true
构建 CPU 版本(同时也自动处理 macOS/CoreML):
./gradlew build -PuseCpu=true
构建所有版本:
./gradlew buildAll
### 使用 DirectML 构建 onnxruntime
**要求**
- [Windows 10 SDK (10.0.17134.0)](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/index-legacy) — 适用于 Windows 10 版本 1803 或更高版本
- Visual Studio 2017 工具链 — 从 VS Installer 安装 *Desktop development with C++*
- Visual Studio 2022 工具链 — 同上
- Python 3.10+: [https://python.org/](https://python.org/)
- CMake 3.28 或更高版本
请保持两个 VS 工具链均为最新版本。详细信息见 [ONNX Runtime 构建文档](https://onnxruntime.ai/docs/build/inferencing.html) 和 [DirectML EP 要求](https://onnxruntime.ai/docs/execution-providers/DirectML-ExecutionProvider.html#build)。
**步骤**
请在 **VS 2022 Developer Command Prompt** 中运行所有命令。
git clone --recursive
cd onnxruntime
.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --use_dml --build_java --build
构建好的 jar 出现在 `java/build/` 中。将其重命名为 `onnxruntime-dml.jar` 并放入本仓库的 `libs/` 目录中。
## 给模组开发者的说明
虽然修改 AI 地形本身相当复杂,但与 Minecraft 生物群系的集成却极其简单。模型输出高程 + 4 个气候变量,并通过手写规则转换为 Minecraft 生物群系。这是提升地形质量最直接的方式,相对容易实现,但需要时间才能达到逼真的效果。整个生物群系分类器 [仅 250 行代码](https://github.com/xandergos/terrain-diffusion-mc/blob/master/src/main/java/com/github/xandergos/terraindiffusionmc/pipeline/BiomeClassifier.java)。
地形多样性远远超过了生物群系多样性,目前存在缩小这一差距的巨大潜力。希望有人能在这方面深入挖掘。
explorer.port=19801
# 出生点搜索:在 (0, 0) 附近寻找陆地出生点时使用的粗像素区域大小。
# 从 initial_size x initial_size 开始,每步增加 8,直到 max_size x max_size。
# 每个粗像素覆盖大片区域(数百个方块),因此 16–128 通常已足够。
spawn_search.initial_size=16
spawn_search.max_size=128
世界级设置
对于 Terrain Diffusion 世界,在世界创建界面点击 Customize 并设置:
该值会保存至世界存档中,并影响以下内容:
- 每个方块代表的现实世界米数(
scale=1 => 30m/block,scale=2 => 15m/block,依此类推)
- 新创建世界的最大高度(假设最高点为现实世界 10000 米)
- 推荐值为 2,可在比例尺与可玩性之间取得良好平衡。若希望更小、更紧凑的世界,请使用 1。
- 较低的值会给 GPU 带来更大压力(Terrain Diffusion 运行频率更高),而较高的值会给 CPU 带来更大压力(世界高度更大)。大多数现代 GPU 在 scale 2 或 3 时可能会受限于 CPU 性能。
常见问题
动态链接库 (DLL) 初始化例程失败
某些较旧的 Java 版本可能会出现此问题。请更新至最新的 Java 21 或更高版本。最新的 Microsoft OpenJDK 21 版本已被证实可用。
LoadLibrary failed with error 126 (仅限 CUDA 构建版)
这通常是由于 CUDA 或 cuDNN 安装不当所致。请参阅 CUDA_INSTALL.md 获取故障排除步骤。
java.lang.IllegalStateException: Failed to load terrain-diffusion models
这通常表明“内存不足”错误(日志中也应显示相关信息)。
Terrain Diffusion 的模型约占 2.5GB RAM,因此请确保分配足够的内存以容纳此部分开销。
如果您的问题仍未解决,请在此处 提交 Issue。
从源码构建
构建过程中需要联网,以便从 Hugging Face 获取固定的模型清单元数据。
-windows 构建版需要 libs/onnxruntime-dml.jar,该文件作为仓库的一部分提供。请参阅 Building onnxruntime with DirectML 了解如何从源码构建。
Windows (DirectML) 构建:
./gradlew build -PuseDml=true
CUDA 构建:
./gradlew build -PuseCuda=true
CPU 构建(同时也自动处理 macOS/CoreML):
./gradlew build -PuseCpu=true
全部构建:
./gradlew buildAll
使用 DirectML 构建 onnxruntime
要求
- Windows 10 SDK (10.0.17134.0) ——适用于 Windows 10 版本 1803 或更高版本
- Visual Studio 2017 工具链 —— 通过 VS Installer 安装 Desktop development with C++
- Visual Studio 2022 工具链 —— 同上
- Python 3.10+:
- CMake 3.28 或更高版本
请保持两个 VS 工具链均为最新版本。完整详情见 ONNX Runtime 构建文档 和 DirectML EP 要求。
步骤
所有命令请在 Developer Command Prompt for VS 2022 中运行。
git clone --recursive https://github.com/Microsoft/onnxruntime.git
cd onnxruntime
.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --use_dml --build_java --build
生成的 jar 文件位于 java/build/ 中。将其重命名为 onnxruntime-dml.jar 并放入本仓库的 libs/ 目录中。
致模组开发者提示
虽然修改 AI 地形本身相当复杂,但与 Minecraft 生物群系的集成却极其简单。模型输出海拔 + 4 个气候变量,并通过手工编写的规则转换为 Minecraft 生物群系。这是提升地形质量最直接的方式,相对容易实现,但要达到逼真的效果仍需耗时。整个生物群系分类器 仅包含 250 行代码。
地形多样性远远超过了生物群系多样性,目前存在缩小这一差距的巨大潜力。希望有人能在这方面深入挖掘。
NeoTerrain Diffusion
This project is a NeoForge port of the original Fabric
Terrain Diffusion Minecraft mod,
which integrates the
Terrain Diffusion world
generation model into Minecraft.
Current Status
This port currently supports server-side use only.
It is intended for a NeoForge dedicated server. It is not currently a complete
client-side replacement for the Fabric mod's world-creation flow, client UI, or
single-player setup.
For this server, world setup is done through server.properties instead of the
Minecraft client's Create World screen.
Validated Local Server
This implementation has been built and validated for:
- Minecraft
1.21.1
- NeoForge
21.1.233
- Java
21
- Windows 10/11
- DirectML GPU inference
- Dedicated server runtime
Validated jar:
terrain-diffusion-mc-neoforge-2.2.0-neoforge.1-windows+1.21.1.jar
The local server using this mod is:
C:\Users\Collin\Desktop\Server 1.21.1
Requirements
- A NeoForge
1.21.1 dedicated server
- NeoForge
21.1.233 or newer in the same 21.1.x line
- Java 21
- Windows with a DirectML-compatible GPU for the validated build
- About 1.5 GB free VRAM minimum
- About 2.5 GB additional system RAM for model loading
- Internet access on first launch so the model files can download
The validated local server launcher uses this Java 21 runtime:
C:\Users\Collin\AppData\Roaming\ModrinthApp\meta\java_versions\zulu21.48.17-ca-jre21.0.10-win_x64\bin\java.exe
GPU Behavior
The Windows build uses DirectML for GPU inference.
A correct startup should log:
Terrain diffusion inference: DirectML
ONNX model 'coarse' loaded on GPU
ONNX model 'base' loaded on GPU
ONNX model 'decoder' loaded on GPU
This port's Windows build is DirectML-first and should not warn about missing
CUDA during normal startup. CUDA is not required for this Windows server build.
Server Installation
Place the NeoForge jar in the dedicated server's mods folder.
For this local server, the jar is kept in the linked Modrinth profile mods
folder so the server sync step can copy it into:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\mods
The sync script also omits known client/render-only mods from the server runtime
using:
C:\Users\Collin\Desktop\Server 1.21.1\server-mod-exclusions.txt
Local Server
Run:
C:\Users\Collin\Desktop\Server 1.21.1\Start-Server.bat
That launcher:
- Syncs server-compatible mods from the Modrinth profile.
- Keeps excluded client/render jars out of
server-runtime\mods.
- Starts the NeoForge dedicated server with Java 21.
Creating A Terrain Diffusion Server World
Because this is currently a server-side port, configure the world in
server.properties.
Current local server configuration:
level-name=terrain-diffusion-world
level-type=terrain-diffusion-mc\:terrain_diffusion
The active file is:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\server.properties
On first launch, the mod downloads and prepares model files under:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\terrain-diffusion-models
Configuration
The server config is created at:
config\terrain-diffusion-mc.properties
For this local server, the full path is:
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\config\terrain-diffusion-mc.properties
Current tuned values:
# Inference device: "cpu", "gpu", or "auto".
# On the Windows build, "gpu" means DirectML.
inference.device=gpu
# Keep all three models loaded on GPU instead of recreating DirectML sessions
# between pipeline stages. This is faster when enough VRAM is available.
inference.offload_models=false
# Validate SHA-256 for model files already on disk.
validate_model=true
# Local web UI port for /td-explore.
explorer.port=19801
# Terrain generation region side length in blocks. Must be a power of 2.
tile_size=256
# Spawn land-search coarse-pixel region sizes.
spawn_search.initial_size=16
spawn_search.max_size=128
If GPU memory becomes tight, set:
inference.offload_models=true
That lowers peak VRAM use but may slow generation.
Terrain Explorer
The port includes the server-side terrain explorer command:
/td-explore
Run it in game. The server prints a local web UI link, usually:
http://localhost:19801
Use the explorer to scout continents, mountains, islands, climates, and useful
coordinates before traveling in game.
World Scale
The server-side port supports world scale values 1..6.
The default scale is 2.
For dedicated-server worlds, the selected scale is stored in the world save:
terrain-diffusion-world\data\terrain_diffusion_world_settings.dat
Scale behavior:
scale=1 is more compressed and runs Terrain Diffusion more often.
scale=2 is the default balance for playability and performance.
- Higher scale values cover more blocks per generated terrain sample and shift
more work toward Minecraft's CPU-side world generation.
Because this port is currently server-side only, there is no supported client
world-creation Customize screen for changing scale in this setup. Treat scale as
part of the server world save.
Common Issues
CUDA not available
This Windows DirectML build should not emit that warning. If it appears, the
server is probably running an old jar or the wrong build variant. Reinstall the
Windows DirectML jar and rerun the server mod sync.
DirectML not available
Update the GPU driver and confirm the machine has a DirectML-compatible GPU. To
start without GPU acceleration for troubleshooting, set:
inference.device=cpu
CPU inference is much slower and is not recommended for regular server use.
A dynamic link library (DLL) initialization routine failed
Use a current Java 21 runtime. The validated local server uses Modrinth's Zulu
Java 21 runtime through Start-Server.bat.
java.lang.IllegalStateException: Failed to load terrain-diffusion models
This usually means one of these happened:
- The model download failed.
- A model file failed validation.
- The server ran out of RAM or VRAM during model load.
Check the latest server log and the files under:
server-runtime\terrain-diffusion-models
Server Starts A Normal World
Check server.properties and confirm:
level-type=terrain-diffusion-mc\:terrain_diffusion
Also confirm the Terrain Diffusion jar is present in server-runtime\mods.
Building This Port
Use a Java 21 JDK for Gradle.
On this machine, this JDK worked:
C:\Program Files\Android\openjdk\jdk-21.0.8
Build the Windows DirectML jar:
$env:JAVA_HOME='C:\Program Files\Android\openjdk\jdk-21.0.8'
$env:Path="$env:JAVA_HOME\bin;$env:Path"
.\gradlew.bat build -PuseDml=true
The built jar is written to:
build\libs\terrain-diffusion-mc-neoforge-2.2.0-neoforge.1-windows+1.21.1.jar
For the local server, copy the rebuilt jar into both:
C:\Users\Collin\Desktop\Server 1.21.1\mods
C:\Users\Collin\Desktop\Server 1.21.1\server-runtime\mods
Then validate:
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Users\Collin\Desktop\Server 1.21.1\Sync-ServerMods.ps1"
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Users\Collin\Desktop\Server 1.21.1\Validate-ServerBoot.ps1" -TimeoutSeconds 900
Expected result:
Result: done
Terrain diffusion inference: DirectML
Spawn search: coarse-pixel region sizes for finding a land spawn near (0, 0).
Starts at initial_size x initial_size and expands by 8 each step up to max_size x max_size.
Each coarse pixel covers a large area (hundreds of blocks), so 16–128 is typically sufficient.
spawn_search.initial_size=16
spawn_search.max_size=128
### Per-world settings
For Terrain Diffusion worlds, click **Customize** in world creation and set:
- `World Scale` (integer `1..6`)
This value is saved with the world save and affects:
- how many real-world meters each block represents (`scale=1` => `30m/block`, `scale=2` => `15m/block`, etc.)
- world max height for newly created worlds (assumes tallest point is 10000 real-world meters)
- 2 is recommended for a good balance of scale and playability. Use 1 for smaller, more compressed worlds.
- Lower values put more stress on the GPU (Terrain Diffusion runs more often), while higher values put more stress on the CPU (larger world height). Most modern GPUs will be bottlenecked by the CPU around scale 2 or 3.
## Common Issues
**A dynamic link library (DLL) initialization routine failed**
This can happen for some older Java versions. Please update to the most recent version of Java 21 or higher. The [latest Microsoft OpenJDK 21](https://learn.microsoft.com/en-us/java/openjdk/download) version is known to work.
**LoadLibrary failed with error 126** *(CUDA build only)*
This is typically due to an improper CUDA or cuDNN installation. See [CUDA_INSTALL.md](CUDA_INSTALL.md) for troubleshooting steps.
**java.lang.IllegalStateException: Failed to load terrain-diffusion models**
This typically indicates an "out of memory" error (the logs should show this as well).
Terrain Diffusion's models take up about 2.5GB of RAM, so make sure to allocate enough RAM to account for this.
**If your issue is still not resolved, please [raise it here](https://github.com/xandergos/terrain-diffusion-mc/issues/new).**
## Building from Source
An internet connection is required during the build to fetch the pinned model manifest metadata from Hugging Face.
The `-windows` build requires `libs/onnxruntime-dml.jar`, which is provided as part of the repo. See [Building onnxruntime with DirectML](#building-onnxruntime-with-directml) to build from source.
Build for Windows (DirectML):
./gradlew build -PuseDml=true
Build for CUDA:
./gradlew build -PuseCuda=true
Build for CPU (also handles macOS/CoreML automatically):
./gradlew build -PuseCpu=true
Build all:
./gradlew buildAll
### Building onnxruntime with DirectML
**Requirements**
- [Windows 10 SDK (10.0.17134.0)](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/index-legacy) — for Windows 10 version 1803 or newer
- Visual Studio 2017 toolchain — install *Desktop development with C++* from the VS Installer
- Visual Studio 2022 toolchain — same as above
- Python 3.10+: [https://python.org/](https://python.org/)
- CMake 3.28 or higher
Keep both VS toolchains up to date. Full details at the [ONNX Runtime build docs](https://onnxruntime.ai/docs/build/inferencing.html) and the [DirectML EP requirements](https://onnxruntime.ai/docs/execution-providers/DirectML-ExecutionProvider.html#build).
**Steps**
Run all commands from the **Developer Command Prompt for VS 2022**.
git clone --recursive
cd onnxruntime
.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --use_dml --build_java --build
The built jar appears in `java/build/`. Rename it to `onnxruntime-dml.jar` and place it in `libs/` in this repository.
## Note For Mod Developers
While modifying the AI terrain itself is quite complex, the integration with Minecraft biomes is extremely simple. The model outputs elevation + 4 climate variables, and this is converted to Minecraft biomes with hand-written rules. This is the most immediate way to improve the quality of the terrain and is relatively easy, but takes time to get realistic. The entire biome classifier is [only 250 lines](https://github.com/xandergos/terrain-diffusion-mc/blob/master/src/main/java/com/github/xandergos/terraindiffusionmc/pipeline/BiomeClassifier.java).
The terrain diversity far outpaces the biome diversity and there's a real opportunity to close that gap. I'm hoping someone goes crazy with it.
explorer.port=19801
# Spawn search: coarse-pixel region sizes for finding a land spawn near (0, 0).
# Starts at initial_size x initial_size and expands by 8 each step up to max_size x max_size.
# Each coarse pixel covers a large area (hundreds of blocks), so 16–128 is typically sufficient.
spawn_search.initial_size=16
spawn_search.max_size=128
Per-world settings
For Terrain Diffusion worlds, click Customize in world creation and set:
World Scale (integer 1..6)
This value is saved with the world save and affects:
- how many real-world meters each block represents (
scale=1 => 30m/block, scale=2 => 15m/block, etc.)
- world max height for newly created worlds (assumes tallest point is 10000 real-world meters)
- 2 is recommended for a good balance of scale and playability. Use 1 for smaller, more compressed worlds.
- Lower values put more stress on the GPU (Terrain Diffusion runs more often), while higher values put more stress on the CPU (larger world height). Most modern GPUs will be bottlenecked by the CPU around scale 2 or 3.
Common Issues
A dynamic link library (DLL) initialization routine failed
This can happen for some older Java versions. Please update to the most recent version of Java 21 or higher. The latest Microsoft OpenJDK 21 version is known to work.
LoadLibrary failed with error 126 (CUDA build only)
This is typically due to an improper CUDA or cuDNN installation. See CUDA_INSTALL.md for troubleshooting steps.
java.lang.IllegalStateException: Failed to load terrain-diffusion models
This typically indicates an "out of memory" error (the logs should show this as well).
Terrain Diffusion's models take up about 2.5GB of RAM, so make sure to allocate enough RAM to account for this.
If your issue is still not resolved, please raise it here.
Building from Source
An internet connection is required during the build to fetch the pinned model manifest metadata from Hugging Face.
The -windows build requires libs/onnxruntime-dml.jar, which is provided as part of the repo. See Building onnxruntime with DirectML to build from source.
Build for Windows (DirectML):
./gradlew build -PuseDml=true
Build for CUDA:
./gradlew build -PuseCuda=true
Build for CPU (also handles macOS/CoreML automatically):
./gradlew build -PuseCpu=true
Build all:
./gradlew buildAll
Building onnxruntime with DirectML
Requirements
- Windows 10 SDK (10.0.17134.0) — for Windows 10 version 1803 or newer
- Visual Studio 2017 toolchain — install Desktop development with C++ from the VS Installer
- Visual Studio 2022 toolchain — same as above
- Python 3.10+:
- CMake 3.28 or higher
Keep both VS toolchains up to date. Full details at the ONNX Runtime build docs and the DirectML EP requirements.
Steps
Run all commands from the Developer Command Prompt for VS 2022.
git clone --recursive https://github.com/Microsoft/onnxruntime.git
cd onnxruntime
.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --use_dml --build_java --build
The built jar appears in java/build/. Rename it to onnxruntime-dml.jar and place it in libs/ in this repository.
Note For Mod Developers
While modifying the AI terrain itself is quite complex, the integration with Minecraft biomes is extremely simple. The model outputs elevation + 4 climate variables, and this is converted to Minecraft biomes with hand-written rules. This is the most immediate way to improve the quality of the terrain and is relatively easy, but takes time to get realistic. The entire biome classifier is only 250 lines.
The terrain diversity far outpaces the biome diversity and there's a real opportunity to close that gap. I'm hoping someone goes crazy with it.
评论 0
登录后参与评分
还没有评论,来抢沙发吧