minecraft-world-generation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMinecraft World Generation Skill
Minecraft世界生成技能
Two Approaches to Custom Worldgen
自定义世界生成的两种方法
| Approach | Best When | Platform |
|---|---|---|
| Datapack JSON | Overriding/extending vanilla worldgen | Vanilla, any server |
| Mod + Datagen | Registering new biomes/dimensions, code-driven | NeoForge / Fabric |
| Biome Modifier (NeoForge) | Adding features/spawns to existing biomes | NeoForge |
| BiomeModification API (Fabric) | Adding features/spawns to existing biomes | Fabric |
| 方法 | 适用场景 | 支持平台 |
|---|---|---|
| 数据包JSON | 覆盖/扩展原版世界生成 | 原版、任意服务器 |
| 模组 + 数据生成 | 注册新生物群系/维度、代码驱动逻辑 | NeoForge / Fabric |
| 生物群系修改器(NeoForge) | 向现有生物群系添加特性/生物生成 | NeoForge |
| BiomeModification API(Fabric) | 向现有生物群系添加特性/生物生成 | Fabric |
Routing Boundaries
适用边界
- : the task is biome/dimension/feature/structure worldgen design or registration.
Use when - : the task is general non-worldgen datapack work (recipes, advancements, predicates, function orchestration) (
Do not use when).minecraft-datapack - : the task is non-worldgen mod systems (items, entities, GUI, gameplay logic) (
Do not use when).minecraft-modding
- :任务为生物群系/维度/特性/结构的世界生成设计或注册时使用。
适用场景 - :任务为非世界生成相关的通用数据包工作(配方、进度、谓词、函数编排)时请勿使用(请使用
不适用场景技能)。minecraft-datapack - :任务为非世界生成相关的模组系统(物品、实体、GUI、游戏逻辑)时请勿使用(请使用
不适用场景技能)。minecraft-modding
Directory Layout (Datapack / Mod Resources)
目录结构(数据包/模组资源)
data/<namespace>/
├── worldgen/
│ ├── biome/
│ │ └── my_biome.json
│ ├── configured_feature/
│ │ └── my_ore.json
│ ├── placed_feature/
│ │ └── my_ore_placed.json
│ ├── noise_settings/
│ │ └── my_dimension_noise.json
│ ├── density_function/
│ │ └── my_density.json (advanced)
│ ├── structure/
│ │ └── my_structure.json
│ ├── structure_set/
│ │ └── my_structures.json
│ ├── processor_list/
│ │ └── my_processors.json
│ ├── template_pool/
│ │ └── my_pool.json
│ └── carver/
│ └── my_carver.json
├── dimension/
│ └── my_dimension.json
├── dimension_type/
│ └── my_type.json
├── tags/
│ └── worldgen/
│ └── biome/
│ └── is_forest.json
└── neoforge/
└── biome_modifier/ (NeoForge mod only)
└── add_ores.jsondata/<namespace>/
├── worldgen/
│ ├── biome/
│ │ └── my_biome.json
│ ├── configured_feature/
│ │ └── my_ore.json
│ ├── placed_feature/
│ │ └── my_ore_placed.json
│ ├── noise_settings/
│ │ └── my_dimension_noise.json
│ ├── density_function/
│ │ └── my_density.json (高级功能)
│ ├── structure/
│ │ └── my_structure.json
│ ├── structure_set/
│ │ └── my_structures.json
│ ├── processor_list/
│ │ └── my_processors.json
│ ├── template_pool/
│ │ └── my_pool.json
│ └── carver/
│ └── my_carver.json
├── dimension/
│ └── my_dimension.json
├── dimension_type/
│ └── my_type.json
├── tags/
│ └── worldgen/
│ └── biome/
│ └── is_forest.json
└── neoforge/
└── biome_modifier/ (仅NeoForge模组可用)
└── add_ores.jsonCustom Biome JSON
自定义生物群系JSON
data/<namespace>/worldgen/biome/my_biome.json
data/<namespace>/worldgen/biome/my_biome.jsondata/<namespace>/worldgen/biome/my_biome.json
data/<namespace>/worldgen/biome/my_biome.jsonjson
{
"has_precipitation": true,
"temperature": 0.7,
"temperature_modifier": "none",
"downfall": 0.8,
"effects": {
"sky_color": 7907327,
"fog_color": 12638463,
"water_color": 4159204,
"water_fog_color": 329011,
"grass_color_modifier": "none",
"ambient_sound": "minecraft:ambient.cave",
"mood_sound": {
"sound": "minecraft:ambient.cave",
"tick_delay": 6000,
"block_search_extent": 8,
"offset": 2.0
}
},
"spawners": {
"monster": [
{ "type": "minecraft:zombie", "weight": 95, "minCount": 4, "maxCount": 4 },
{ "type": "minecraft:skeleton", "weight": 100, "minCount": 4, "maxCount": 4 }
],
"creature": [
{ "type": "minecraft:sheep", "weight": 12, "minCount": 4, "maxCount": 4 }
],
"ambient": [],
"axolotls": [],
"underground_water_creature": [],
"water_creature": [],
"water_ambient": [],
"misc": []
},
"spawn_costs": {},
"carvers": {
"air": ["minecraft:cave", "minecraft:cave_extra_underground", "minecraft:canyon"]
},
"features": [
[],
[],
["minecraft:lake_lava_underground", "minecraft:lake_lava_surface"],
["minecraft:amethyst_geode", "minecraft:monster_room"],
[],
[],
[
"minecraft:ore_dirt", "minecraft:ore_gravel", "minecraft:ore_granite_upper",
"minecraft:ore_coal_upper", "minecraft:ore_coal_lower",
"<namespace>:my_ore_placed"
],
[],
["minecraft:spring_lava"],
[],
["minecraft:freeze_top_layer"]
]
}Thearray has exactly 11 slots (indices 0–10), one perfeatures:GenerationStep.Decoration
Index Step Put here 0 RAW_GENERATION(rarely used) 1 LAKESSurface water/lava lakes 2 LOCAL_MODIFICATIONSUnderground lava lakes, geodes 3 UNDERGROUND_STRUCTURESAmethyst geodes, dungeons 4 SURFACE_STRUCTURESGlaciers, blue ice patches 5 STRONGHOLDS(unused in biome JSON) 6 UNDERGROUND_ORESAll ores go here 7 UNDERGROUND_DECORATIONFossils, infested stone 8 FLUID_SPRINGS ,spring_waterspring_lava9 VEGETAL_DECORATIONTrees, grass, flowers 10 TOP_LAYER_MODIFICATIONfreeze_top_layerCustom ores added via placed features must be placed at index 6.
json
{
"has_precipitation": true,
"temperature": 0.7,
"temperature_modifier": "none",
"downfall": 0.8,
"effects": {
"sky_color": 7907327,
"fog_color": 12638463,
"water_color": 4159204,
"water_fog_color": 329011,
"grass_color_modifier": "none",
"ambient_sound": "minecraft:ambient.cave",
"mood_sound": {
"sound": "minecraft:ambient.cave",
"tick_delay": 6000,
"block_search_extent": 8,
"offset": 2.0
}
},
"spawners": {
"monster": [
{ "type": "minecraft:zombie", "weight": 95, "minCount": 4, "maxCount": 4 },
{ "type": "minecraft:skeleton", "weight": 100, "minCount": 4, "maxCount": 4 }
],
"creature": [
{ "type": "minecraft:sheep", "weight": 12, "minCount": 4, "maxCount": 4 }
],
"ambient": [],
"axolotls": [],
"underground_water_creature": [],
"water_creature": [],
"water_ambient": [],
"misc": []
},
"spawn_costs": {},
"carvers": {
"air": ["minecraft:cave", "minecraft:cave_extra_underground", "minecraft:canyon"]
},
"features": [
[],
[],
["minecraft:lake_lava_underground", "minecraft:lake_lava_surface"],
["minecraft:amethyst_geode", "minecraft:monster_room"],
[],
[],
[
"minecraft:ore_dirt", "minecraft:ore_gravel", "minecraft:ore_granite_upper",
"minecraft:ore_coal_upper", "minecraft:ore_coal_lower",
"<namespace>:my_ore_placed"
],
[],
["minecraft:spring_lava"],
[],
["minecraft:freeze_top_layer"]
]
}数组恰好有11个插槽(索引0–10),每个对应一个features:GenerationStep.Decoration
索引 步骤 放置内容 0 RAW_GENERATION(很少使用) 1 LAKES地表水/熔岩湖 2 LOCAL_MODIFICATIONS地下熔岩湖、晶洞 3 UNDERGROUND_STRUCTURES紫水晶晶洞、地牢 4 SURFACE_STRUCTURES冰川、蓝冰块 5 STRONGHOLDS(生物群系JSON中未使用) 6 UNDERGROUND_ORES所有矿石都放在这里 7 UNDERGROUND_DECORATION化石、被虫蚀的石头 8 FLUID_SPRINGS 、spring_waterspring_lava9 VEGETAL_DECORATION树木、草、花 10 TOP_LAYER_MODIFICATIONfreeze_top_layer通过已放置特性添加的自定义矿石必须放在索引6的位置。
Configured Feature
已配置特性(Configured Feature)
data/<namespace>/worldgen/configured_feature/my_ore.json
data/<namespace>/worldgen/configured_feature/my_ore.jsondata/<namespace>/worldgen/configured_feature/my_ore.json
data/<namespace>/worldgen/configured_feature/my_ore.jsonjson
{
"type": "minecraft:ore",
"config": {
"targets": [
{
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
},
"state": {
"Name": "minecraft:emerald_ore"
}
}
],
"size": 4,
"discard_chance_on_air_exposure": 0.0
}
}json
{
"type": "minecraft:ore",
"config": {
"targets": [
{
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
},
"state": {
"Name": "minecraft:emerald_ore"
}
}
],
"size": 4,
"discard_chance_on_air_exposure": 0.0
}
}Other feature types
其他特性类型
| Type | Use |
|---|---|
| Ore veins |
| Tree placement |
| Grass, flowers, mushrooms |
| Hay bales, pumpkins |
| Water/lava lakes |
| Sand/gravel/clay disks |
| Wither roses, etc. |
| Single block placement |
| Fill an entire layer |
| Amethyst geodes |
| Wraps another feature with placement |
| 类型 | 用途 |
|---|---|
| 矿脉 |
| 树木放置 |
| 草、花、蘑菇 |
| 干草捆、南瓜 |
| 水/熔岩湖 |
| 沙子/沙砾/黏土盘 |
| 凋零玫瑰等 |
| 单方块放置 |
| 填充整层 |
| 紫水晶晶洞 |
| 用放置规则包裹另一个特性 |
Placed Feature
已放置特性(Placed Feature)
data/<namespace>/worldgen/placed_feature/my_ore_placed.json
data/<namespace>/worldgen/placed_feature/my_ore_placed.jsondata/<namespace>/worldgen/placed_feature/my_ore_placed.json
data/<namespace>/worldgen/placed_feature/my_ore_placed.jsonjson
{
"feature": "<namespace>:my_ore",
"placement": [
{
"type": "minecraft:count",
"count": 8
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"min_inclusive": { "above_bottom": 0 },
"max_inclusive": { "absolute": 64 }
}
},
{
"type": "minecraft:biome"
}
]
}json
{
"feature": "<namespace>:my_ore",
"placement": [
{
"type": "minecraft:count",
"count": 8
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"min_inclusive": { "above_bottom": 0 },
"max_inclusive": { "absolute": 64 }
}
},
{
"type": "minecraft:biome"
}
]
}Common placement modifiers
常用放置修饰符
| Type | Effect |
|---|---|
| Number of attempts |
| Per layer |
| Randomize X/Z within chunk |
| Only place if biome has this feature |
| Y-level range |
| Filter by surface depth |
| Count varies with noise |
| 1-in-N chance |
| Scans up/down for a condition |
| 类型 | 效果 |
|---|---|
| 尝试次数 |
| 每层尝试次数 |
| 在区块内随机X/Z坐标 |
| 仅在生物群系包含该特性时放置 |
| Y轴高度范围 |
| 按地表深度过滤 |
| 数量随噪声变化 |
| N分之一概率 |
| 上下扫描满足条件的位置 |
Dimension Type
维度类型(Dimension Type)
data/<namespace>/dimension_type/my_type.json
data/<namespace>/dimension_type/my_type.jsondata/<namespace>/dimension_type/my_type.json
data/<namespace>/dimension_type/my_type.jsonjson
{
"ultrawarm": false,
"natural": true,
"coordinate_scale": 1.0,
"has_skylight": true,
"has_ceiling": false,
"ambient_light": 0.0,
"fixed_time": false,
"monster_spawn_light_level": {
"type": "minecraft:uniform",
"min_inclusive": 0,
"max_inclusive": 7
},
"monster_spawn_block_light_limit": 0,
"piglin_safe": false,
"bed_works": true,
"respawn_anchor_works": false,
"has_raids": true,
"logical_height": 384,
"height": 384,
"min_y": -64,
"infiniburn": "#minecraft:infiniburn_overworld",
"effects": "minecraft:overworld"
}json
{
"ultrawarm": false,
"natural": true,
"coordinate_scale": 1.0,
"has_skylight": true,
"has_ceiling": false,
"ambient_light": 0.0,
"fixed_time": false,
"monster_spawn_light_level": {
"type": "minecraft:uniform",
"min_inclusive": 0,
"max_inclusive": 7
},
"monster_spawn_block_light_limit": 0,
"piglin_safe": false,
"bed_works": true,
"respawn_anchor_works": false,
"has_raids": true,
"logical_height": 384,
"height": 384,
"min_y": -64,
"infiniburn": "#minecraft:infiniburn_overworld",
"effects": "minecraft:overworld"
}Custom Dimension
自定义维度
data/<namespace>/dimension/my_dimension.json
data/<namespace>/dimension/my_dimension.jsondata/<namespace>/dimension/my_dimension.json
data/<namespace>/dimension/my_dimension.jsonjson
{
"type": "<namespace>:my_type",
"generator": {
"type": "minecraft:noise",
"biome_source": {
"type": "minecraft:fixed",
"biome": "<namespace>:my_biome"
},
"settings": "minecraft:overworld"
}
}json
{
"type": "<namespace>:my_type",
"generator": {
"type": "minecraft:noise",
"biome_source": {
"type": "minecraft:fixed",
"biome": "<namespace>:my_biome"
},
"settings": "minecraft:overworld"
}
}Multi-biome dimension with minecraft:multi_noise
source
minecraft:multi_noise使用minecraft:multi_noise
源的多生物群系维度
minecraft:multi_noisejson
{
"type": "<namespace>:my_type",
"generator": {
"type": "minecraft:noise",
"biome_source": {
"type": "minecraft:multi_noise",
"biomes": [
{
"parameters": {
"temperature": [ -1.0, -0.45 ],
"humidity": [ -1.0, -0.35 ],
"continentalness": [ -1.2, -1.05 ],
"erosion": [ -0.78, 0.0 ],
"weirdness": [ 0.0, 0.0 ],
"depth": [ 0.0, 0.0 ],
"offset": 0.0
},
"biome": "<namespace>:my_biome"
}
]
},
"settings": "minecraft:overworld"
}
}json
{
"type": "<namespace>:my_type",
"generator": {
"type": "minecraft:noise",
"biome_source": {
"type": "minecraft:multi_noise",
"biomes": [
{
"parameters": {
"temperature": [ -1.0, -0.45 ],
"humidity": [ -1.0, -0.35 ],
"continentalness": [ -1.2, -1.05 ],
"erosion": [ -0.78, 0.0 ],
"weirdness": [ 0.0, 0.0 ],
"depth": [ 0.0, 0.0 ],
"offset": 0.0
},
"biome": "<namespace>:my_biome"
}
]
},
"settings": "minecraft:overworld"
}
}NeoForge: Biome Modifier
NeoForge:生物群系修改器
Biome Modifiers let you add features, spawns, or carvers to existing biomes without
replacing the biome JSON.
生物群系修改器允许你向现有生物群系添加特性、生物生成或雕刻器,无需替换生物群系JSON。
JSON biome modifier (data/<namespace>/neoforge/biome_modifier/add_ores.json
)
data/<namespace>/neoforge/biome_modifier/add_ores.jsonJSON生物群系修改器(data/<namespace>/neoforge/biome_modifier/add_ores.json
)
data/<namespace>/neoforge/biome_modifier/add_ores.jsonjson
{
"type": "neoforge:add_features",
"biomes": "#minecraft:is_overworld",
"features": "<namespace>:my_ore_placed",
"step": "underground_ores"
}json
{
"type": "neoforge:add_features",
"biomes": "#minecraft:is_overworld",
"features": "<namespace>:my_ore_placed",
"step": "underground_ores"
}Other NeoForge biome modifier types
其他NeoForge生物群系修改器类型
json
{ "type": "neoforge:add_spawns", "biomes": "#minecraft:is_forest",
"spawners": [{ "type": "minecraft:wolf", "weight": 5, "minCount": 2, "maxCount": 4 }] }
{ "type": "neoforge:remove_features", "biomes": "#minecraft:is_plains",
"features": "minecraft:ore_coal_upper", "steps": ["underground_ores"] }
{ "type": "neoforge:remove_spawns", "biomes": "#minecraft:is_ocean",
"entity_types": "#minecraft:skeletons" }json
{ "type": "neoforge:add_spawns", "biomes": "#minecraft:is_forest",
"spawners": [{ "type": "minecraft:wolf", "weight": 5, "minCount": 2, "maxCount": 4 }] }
{ "type": "neoforge:remove_features", "biomes": "#minecraft:is_plains",
"features": "minecraft:ore_coal_upper", "steps": ["underground_ores"] }
{ "type": "neoforge:remove_spawns", "biomes": "#minecraft:is_ocean",
"entity_types": "#minecraft:skeletons" }Fabric: BiomeModification API (Code)
Fabric:BiomeModification API(代码)
java
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.minecraft.world.level.levelgen.GenerationStep;
public class MyModWorldgen {
public static void init() {
// Add a placed feature to all overworld biomes
BiomeModifications.addFeature(
BiomeSelectors.foundInOverworld(),
GenerationStep.Decoration.UNDERGROUND_ORES,
ResourceKey.create(
Registries.PLACED_FEATURE,
ResourceLocation.fromNamespaceAndPath(MyMod.MOD_ID, "my_ore_placed")
)
);
// Add mob spawns
BiomeModifications.addSpawn(
BiomeSelectors.tag(BiomeTags.IS_FOREST),
MobCategory.CREATURE,
EntityType.WOLF,
5, 2, 4
);
}
}java
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.minecraft.world.level.levelgen.GenerationStep;
public class MyModWorldgen {
public static void init() {
// 向所有主世界生物群系添加已放置特性
BiomeModifications.addFeature(
BiomeSelectors.foundInOverworld(),
GenerationStep.Decoration.UNDERGROUND_ORES,
ResourceKey.create(
Registries.PLACED_FEATURE,
ResourceLocation.fromNamespaceAndPath(MyMod.MOD_ID, "my_ore_placed")
)
);
// 添加生物生成规则
BiomeModifications.addSpawn(
BiomeSelectors.tag(BiomeTags.IS_FOREST),
MobCategory.CREATURE,
EntityType.WOLF,
5, 2, 4
);
}
}Mod-Registered Worldgen (NeoForge + Fabric via Datagen)
模组注册的世界生成(NeoForge + Fabric 数据生成实现)
Register worldgen keys in code
在代码中注册世界生成键
java
// In a dedicated worldgen registry class
public class ModWorldgen {
public static final ResourceKey<Biome> MY_BIOME = ResourceKey.create(
Registries.BIOME,
ResourceLocation.fromNamespaceAndPath(MyMod.MOD_ID, "my_biome")
);
public static final ResourceKey<PlacedFeature> MY_ORE_PLACED = ResourceKey.create(
Registries.PLACED_FEATURE,
ResourceLocation.fromNamespaceAndPath(MyMod.MOD_ID, "my_ore_placed")
);
}java
// 放在专用的世界生成注册类中
public class ModWorldgen {
public static final ResourceKey<Biome> MY_BIOME = ResourceKey.create(
Registries.BIOME,
ResourceLocation.fromNamespaceAndPath(MyMod.MOD_ID, "my_biome")
);
public static final ResourceKey<PlacedFeature> MY_ORE_PLACED = ResourceKey.create(
Registries.PLACED_FEATURE,
ResourceLocation.fromNamespaceAndPath(MyMod.MOD_ID, "my_ore_placed")
);
}Datagen: NeoForge (DatapackBuiltinEntriesProvider
)
DatapackBuiltinEntriesProvider数据生成:NeoForge(DatapackBuiltinEntriesProvider
)
DatapackBuiltinEntriesProviderjava
public class ModWorldgenProvider extends DatapackBuiltinEntriesProvider {
private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.CONFIGURED_FEATURE, ModWorldgenProvider::bootstrapConfigured)
.add(Registries.PLACED_FEATURE, ModWorldgenProvider::bootstrapPlaced);
public ModWorldgenProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries, BUILDER, Set.of(MyMod.MOD_ID));
}
private static void bootstrapConfigured(BootstrapContext<ConfiguredFeature<?, ?>> ctx) {
ctx.register(
ModWorldgen.MY_ORE_CONFIGURED,
new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(
OreConfiguration.target(
new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES),
ModBlocks.MY_ORE.get().defaultBlockState()
),
9 // vein size
))
);
}
private static void bootstrapPlaced(BootstrapContext<PlacedFeature> ctx) {
HolderGetter<ConfiguredFeature<?, ?>> configured =
ctx.lookup(Registries.CONFIGURED_FEATURE);
ctx.register(
ModWorldgen.MY_ORE_PLACED,
new PlacedFeature(
configured.getOrThrow(ModWorldgen.MY_ORE_CONFIGURED),
List.of(
HeightRangePlacement.triangle(
VerticalAnchor.absolute(-64),
VerticalAnchor.absolute(32)
),
CountPlacement.of(8),
InSquarePlacement.spread(),
BiomeFilter.biome()
)
)
);
}
}Register in your handler:
GatherDataEventjava
@SubscribeEvent
public static void onGatherData(GatherDataEvent event) {
DataGenerator gen = event.getGenerator();
PackOutput output = gen.getPackOutput();
gen.addProvider(event.includeServer(),
new ModWorldgenProvider(output, event.getLookupProvider()));
}java
public class ModWorldgenProvider extends DatapackBuiltinEntriesProvider {
private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.CONFIGURED_FEATURE, ModWorldgenProvider::bootstrapConfigured)
.add(Registries.PLACED_FEATURE, ModWorldgenProvider::bootstrapPlaced);
public ModWorldgenProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries, BUILDER, Set.of(MyMod.MOD_ID));
}
private static void bootstrapConfigured(BootstrapContext<ConfiguredFeature<?, ?>> ctx) {
ctx.register(
ModWorldgen.MY_ORE_CONFIGURED,
new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(
OreConfiguration.target(
new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES),
ModBlocks.MY_ORE.get().defaultBlockState()
),
9 // 矿脉大小
))
);
}
private static void bootstrapPlaced(BootstrapContext<PlacedFeature> ctx) {
HolderGetter<ConfiguredFeature<?, ?>> configured =
ctx.lookup(Registries.CONFIGURED_FEATURE);
ctx.register(
ModWorldgen.MY_ORE_PLACED,
new PlacedFeature(
configured.getOrThrow(ModWorldgen.MY_ORE_CONFIGURED),
List.of(
HeightRangePlacement.triangle(
VerticalAnchor.absolute(-64),
VerticalAnchor.absolute(32)
),
CountPlacement.of(8),
InSquarePlacement.spread(),
BiomeFilter.biome()
)
)
);
}
}在你的处理器中注册:
GatherDataEventjava
@SubscribeEvent
public static void onGatherData(GatherDataEvent event) {
DataGenerator gen = event.getGenerator();
PackOutput output = gen.getPackOutput();
gen.addProvider(event.includeServer(),
new ModWorldgenProvider(output, event.getLookupProvider()));
}Datagen: Fabric (FabricDynamicRegistryProvider
)
FabricDynamicRegistryProvider数据生成:Fabric(FabricDynamicRegistryProvider
)
FabricDynamicRegistryProviderjava
public class ModWorldgenProvider extends FabricDynamicRegistryProvider {
public ModWorldgenProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries);
}
@Override
protected void configure(HolderLookup.Provider registries, Entries entries) {
entries.addAll(registries.lookupOrThrow(Registries.CONFIGURED_FEATURE));
entries.addAll(registries.lookupOrThrow(Registries.PLACED_FEATURE));
}
@Override
public String getName() {
return "Worldgen";
}
}java
public class ModWorldgenProvider extends FabricDynamicRegistryProvider {
public ModWorldgenProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries);
}
@Override
protected void configure(HolderLookup.Provider registries, Entries entries) {
entries.addAll(registries.lookupOrThrow(Registries.CONFIGURED_FEATURE));
entries.addAll(registries.lookupOrThrow(Registries.PLACED_FEATURE));
}
@Override
public String getName() {
return "Worldgen";
}
}Custom Structure
自定义结构
data/<namespace>/worldgen/structure/my_structure.json
data/<namespace>/worldgen/structure/my_structure.jsondata/<namespace>/worldgen/structure/my_structure.json
data/<namespace>/worldgen/structure/my_structure.jsonjson
{
"type": "minecraft:jigsaw",
"biomes": "#<namespace>:my_biome_tag",
"step": "surface_structures",
"terrain_adaptation": "beard_thin",
"start_pool": "<namespace>:my_pool/start",
"size": 6,
"max_distance_from_center": 80,
"use_expansion_hack": false,
"spawn_overrides": {}
}json
{
"type": "minecraft:jigsaw",
"biomes": "#<namespace>:my_biome_tag",
"step": "surface_structures",
"terrain_adaptation": "beard_thin",
"start_pool": "<namespace>:my_pool/start",
"size": 6,
"max_distance_from_center": 80,
"use_expansion_hack": false,
"spawn_overrides": {}
}Template pool for jigsaw structures
拼图结构的模板池
json
{
"fallback": "minecraft:empty",
"elements": [
{
"weight": 1,
"element": {
"element_type": "minecraft:single_pool_element",
"location": "<namespace>:my_structure/start",
"projection": "rigid",
"processors": "minecraft:empty"
}
}
]
}json
{
"fallback": "minecraft:empty",
"elements": [
{
"weight": 1,
"element": {
"element_type": "minecraft:single_pool_element",
"location": "<namespace>:my_structure/start",
"projection": "rigid",
"processors": "minecraft:empty"
}
}
]
}Structure Set
结构集
data/<namespace>/worldgen/structure_set/my_structures.json
data/<namespace>/worldgen/structure_set/my_structures.jsondata/<namespace>/worldgen/structure_set/my_structures.json
data/<namespace>/worldgen/structure_set/my_structures.jsonjson
{
"structures": [
{
"structure": "<namespace>:my_structure",
"weight": 1
}
],
"placement": {
"type": "minecraft:random_spread",
"spacing": 32,
"separation": 8,
"salt": 12345678
}
}json
{
"structures": [
{
"structure": "<namespace>:my_structure",
"weight": 1
}
],
"placement": {
"type": "minecraft:random_spread",
"spacing": 32,
"separation": 8,
"salt": 12345678
}
}Testing Worldgen
测试世界生成
bash
undefinedbash
undefinedCreate a new world with datapack loaded
加载数据包创建新世界
In-game with a mod:
在装了模组的游戏内执行:
/locate structure <namespace>:my_structure
/locate biome <namespace>:my_biome
/placefeature <namespace>:my_ore_placed
/locate structure <namespace>:my_structure
/locate biome <namespace>:my_biome
/placefeature <namespace>:my_ore_placed
Reload worldgen data (does not affect already-generated chunks)
重载世界生成数据(不会影响已经生成的区块)
/reload
/reload
For dimension testing — must use /execute in <namespace>:my_dimension
测试维度时必须使用 /execute in <namespace>:my_dimension
execute in <namespace>:my_dimension run tp @s 0 100 0
undefinedexecute in <namespace>:my_dimension run tp @s 0 100 0
undefinedValidator Script
验证脚本
Use the bundled validator before shipping worldgen JSON changes:
bash
undefined发布世界生成JSON改动前请使用附带的验证工具:
bash
undefinedRun from the installed skill directory:
从已安装的skill目录运行:
./scripts/validate-worldgen-json.sh --root /path/to/datapack-or-mod-resources
./scripts/validate-worldgen-json.sh --root /path/to/datapack-or-mod-resources
Strict mode treats warnings as failures:
严格模式将警告视为失败:
./scripts/validate-worldgen-json.sh --root /path/to/datapack-or-mod-resources --strict
What it checks:
- JSON validity for `worldgen/**` and `neoforge/biome_modifier/**`
- Cross-reference integrity for `placed_feature -> configured_feature`
- Cross-reference integrity for `structure_set -> structure` and biome/biome_modifier feature targets
---./scripts/validate-worldgen-json.sh --root /path/to/datapack-or-mod-resources --strict
检查内容:
- `worldgen/**` 和 `neoforge/biome_modifier/**` 下的JSON有效性
- `placed_feature -> configured_feature` 的交叉引用完整性
- `structure_set -> structure` 和生物群系/生物群系修改器特性目标的交叉引用完整性
---References
参考资料
- Minecraft Wiki — World generation: https://minecraft.wiki/w/Custom_world_generation
- Minecraft Wiki — Biome: https://minecraft.wiki/w/Biome/JSON_format
- Minecraft Wiki — Features: https://minecraft.wiki/w/World_generation/Configured_feature
- NeoForge Biome Modifiers: https://docs.neoforged.net/docs/worldgen/biomemodifier/
- Fabric BiomeModifications: https://wiki.fabricmc.net/tutorial:biomemodification
- misode's data pack generator (worldgen UI): https://misode.github.io/worldgen/
- Minecraft Wiki — 世界生成: https://minecraft.wiki/w/Custom_world_generation
- Minecraft Wiki — 生物群系: https://minecraft.wiki/w/Biome/JSON_format
- Minecraft Wiki — 特性: https://minecraft.wiki/w/World_generation/Configured_feature
- NeoForge生物群系修改器: https://docs.neoforged.net/docs/worldgen/biomemodifier/
- Fabric生物群系修改: https://wiki.fabricmc.net/tutorial:biomemodification
- misode的数据包生成器(世界生成UI): https://misode.github.io/worldgen/