sapdon 3.2.2 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -121
- package/doc/dev/architecture.md +415 -0
- package/doc/dev/cli.md +467 -0
- package/doc/dev/core.md +717 -0
- package/doc/dev/oc.md +582 -0
- package/doc/user/api/biome.md +558 -0
- package/doc/user/api/block.md +945 -0
- package/doc/user/api/entity.md +685 -0
- package/doc/user/api/extra.md +231 -0
- package/doc/user/api/item.md +896 -0
- package/doc/user/api/recipe.md +427 -0
- package/doc/user/api/texture.md +181 -0
- package/doc/user/config/build-config.md +84 -0
- package/doc/user/config/mod-info.md +33 -0
- package/doc/user/faq.md +160 -0
- package/doc/user/quick-start.md +108 -0
- package/doc/user/tutorials/block.md +463 -0
- package/doc/user/tutorials/entity.md +356 -0
- package/doc/user/tutorials/item.md +449 -0
- package/doc/user/tutorials/recipe.md +278 -0
- package/package.json +4 -3
- package/prod/cli/index.js +1 -1
- package/prod/cli/start.js +1 -1458
- package/prod/core/index.d.ts +3290 -2150
- package/prod/core/index.js +1 -59015
- package/prod/core/package.json +7 -0
- package/prod/oc/index.d.ts +348 -108
- package/prod/oc/index.js +1 -1
- package/prod/oc/package.json +7 -0
- package/prod/utils/index.d.ts +20 -2
- package/prod/utils/index.js +1 -1
- package/prod/utils/package.json +7 -0
- package/doc/BlockAPI.md +0 -145
- package/doc/api.md +0 -128
- package/doc/oc/index.md +0 -0
- package/doc/sapdon-ts.md +0 -64
- package/src/templates/js_sapdon/build.config +0 -23
- package/src/templates/js_sapdon/main.mjs +0 -4
- package/src/templates/js_sapdon/mod.info +0 -7
- package/src/templates/js_sapdon/pack_icon.png +0 -0
- package/src/templates/js_sapdon/package.json +0 -20
- package/src/templates/js_sapdon/res/animations/animation_item.animation.json +0 -34
- package/src/templates/js_sapdon/res/animations/large_item.animation.json +0 -27
- package/src/templates/js_sapdon/res/models/blocks/crop.geo.json +0 -48
- package/src/templates/js_sapdon/res/models/entity/animation/animation_item.geo.json +0 -26
- package/src/templates/js_sapdon/res/models/entity/animation/large_item.geo.json +0 -28
- package/src/templates/js_sapdon/res/textures/blocks/none.png +0 -0
- package/src/templates/js_sapdon/res/textures/blocks/test_log_oak.png +0 -0
- package/src/templates/js_sapdon/res/textures/blocks/test_log_top.png +0 -0
- package/src/templates/js_sapdon/res/textures/items/masterball.png +0 -0
- package/src/templates/js_sapdon/scripts/custom_components/cropComponent.js +0 -50
- package/src/templates/js_sapdon/scripts/custom_components/items/gui_book.js +0 -37
- package/src/templates/js_sapdon/scripts/custom_components/registry.js +0 -25
- package/src/templates/js_sapdon/scripts/index.js +0 -0
- package/src/templates/ts_sapdon/build.config +0 -23
- package/src/templates/ts_sapdon/main.ts +0 -11
- package/src/templates/ts_sapdon/mod.info +0 -7
- package/src/templates/ts_sapdon/pack_icon.png +0 -0
- package/src/templates/ts_sapdon/package.json +0 -20
- package/src/templates/ts_sapdon/res/models/blocks/crop.geo.json +0 -48
- package/src/templates/ts_sapdon/res/textures/blocks/test_log_oak.png +0 -0
- package/src/templates/ts_sapdon/res/textures/blocks/test_log_top.png +0 -0
- package/src/templates/ts_sapdon/res/textures/items/masterball.png +0 -0
- package/src/templates/ts_sapdon/scripts/components/cropComponent.ts +0 -44
- package/src/templates/ts_sapdon/scripts/components/items/guiBook.ts +0 -36
- package/src/templates/ts_sapdon/scripts/components/registry.ts +0 -24
- package/src/templates/ts_sapdon/scripts/index.ts +0 -7
- package/src/templates/ts_sapdon/tsconfig.json +0 -117
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
# 生物群系与特征系统 API 参考
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## BiomeAPI
|
|
6
|
+
|
|
7
|
+
工厂函数,用于创建生物群系并自动注册到游戏系统。
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { BiomeAPI, registry } from '@sapdon/core'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### createBiome
|
|
16
|
+
|
|
17
|
+
创建生物群系实例。
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
BiomeAPI.createBiome(identifier: string): Biome
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**参数**
|
|
24
|
+
|
|
25
|
+
| 参数 | 类型 | 说明 |
|
|
26
|
+
|------|------|------|
|
|
27
|
+
| `identifier` | `string` | 生物群系唯一标识符,格式 `命名空间:名称` |
|
|
28
|
+
|
|
29
|
+
**示例**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const biome = BiomeAPI.createBiome('sapdon:mystic_forest')
|
|
33
|
+
registry.submit()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
返回的 `Biome` 实例通过 `.addComponent()` 链式添加组件。
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Biome
|
|
41
|
+
|
|
42
|
+
生物群系类,通过 `addComponent()` 添加组件后提交。
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { Biome, BiomeComponent } from '@sapdon/core'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### addComponent
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
biome.addComponent(componentMap: Map): this
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**参数**
|
|
55
|
+
|
|
56
|
+
| 参数 | 类型 | 说明 |
|
|
57
|
+
|------|------|------|
|
|
58
|
+
| `componentMap` | `Map<string, any>` | 由 `BiomeComponent` 静态方法生成的组件 Map |
|
|
59
|
+
|
|
60
|
+
**示例**
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const biome = BiomeAPI.createBiome('sapdon:mystic_forest')
|
|
64
|
+
|
|
65
|
+
biome.addComponent(
|
|
66
|
+
BiomeComponent.setClimate(0.5, 0.1, 0.8)
|
|
67
|
+
)
|
|
68
|
+
biome.addComponent(
|
|
69
|
+
BiomeComponent.setOverworldHeight([0.1, 0.2])
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
registry.submit()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 合并多个组件
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
biome.addComponent(
|
|
79
|
+
BiomeComponent.combineComponents(
|
|
80
|
+
BiomeComponent.setClimate(0.5, 0.3, 0.7),
|
|
81
|
+
BiomeComponent.setOverworldHeight([0.1, 0.2])
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## BiomeComponent
|
|
89
|
+
|
|
90
|
+
静态工具方法集合,用于生成生物群系组件 Map。每个方法返回 `Map<string, any>`。
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { BiomeComponent } from '@sapdon/core'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### setClimate
|
|
97
|
+
|
|
98
|
+
设置生物群系的气候参数。
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
static setClimate(
|
|
102
|
+
downfall: number,
|
|
103
|
+
snow_accumulation: number,
|
|
104
|
+
temperature: number
|
|
105
|
+
): Map
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**参数**
|
|
109
|
+
|
|
110
|
+
| 参数 | 类型 | 说明 |
|
|
111
|
+
|------|------|------|
|
|
112
|
+
| `downfall` | `number` | 降水量,范围通常 0 ~ 1 |
|
|
113
|
+
| `snow_accumulation` | `number` | 积雪量,范围通常 0 ~ 1 |
|
|
114
|
+
| `temperature` | `number` | 温度,范围通常 0 ~ 1 |
|
|
115
|
+
|
|
116
|
+
**示例**
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
BiomeComponent.setClimate(0.4, 0.0, 0.9) // 温暖干燥
|
|
120
|
+
BiomeComponent.setClimate(0.9, 0.5, 0.0) // 寒冷多雪
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### setOverworldHeight
|
|
124
|
+
|
|
125
|
+
设置生物群系的世界高度参数,控制地形生成。
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
static setOverworldHeight(noise_params: object): Map
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**参数**
|
|
132
|
+
|
|
133
|
+
| 参数 | 类型 | 说明 |
|
|
134
|
+
|------|------|------|
|
|
135
|
+
| `noise_params` | `Array<number>` | 噪声参数,如 `[0.1, 0.2]` |
|
|
136
|
+
|
|
137
|
+
**示例**
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// 平坦地形
|
|
141
|
+
BiomeComponent.setOverworldHeight([0.05, 0.05])
|
|
142
|
+
|
|
143
|
+
// 起伏山地
|
|
144
|
+
BiomeComponent.setOverworldHeight([0.2, 0.4])
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### setSurfaceParameters
|
|
148
|
+
|
|
149
|
+
设置生物群系的表面方块参数。
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
static setSurfaceParameters(params: {
|
|
153
|
+
sea_floor_depth: number
|
|
154
|
+
sea_floor_material: string
|
|
155
|
+
foundation_material: string
|
|
156
|
+
mid_material: string
|
|
157
|
+
top_material: string
|
|
158
|
+
sea_material: string
|
|
159
|
+
}): Map
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**参数**
|
|
163
|
+
|
|
164
|
+
| 参数 | 类型 | 说明 |
|
|
165
|
+
|------|------|------|
|
|
166
|
+
| `sea_floor_depth` | `number` | 海底深度 |
|
|
167
|
+
| `sea_floor_material` | `string` | 海底材料,如 `"minecraft:sand"` |
|
|
168
|
+
| `foundation_material` | `string` | 基础材料,如 `"minecraft:stone"` |
|
|
169
|
+
| `mid_material` | `string` | 中间层材料,如 `"minecraft:dirt"` |
|
|
170
|
+
| `top_material` | `string` | 顶层材料,如 `"minecraft:grass_block"` |
|
|
171
|
+
| `sea_material` | `string` | 海洋材料,如 `"minecraft:water"` |
|
|
172
|
+
|
|
173
|
+
**示例**
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
BiomeComponent.setSurfaceParameters({
|
|
177
|
+
sea_floor_depth: 7,
|
|
178
|
+
sea_floor_material: 'minecraft:gravel',
|
|
179
|
+
foundation_material: 'minecraft:stone',
|
|
180
|
+
mid_material: 'minecraft:dirt',
|
|
181
|
+
top_material: 'minecraft:grass_block',
|
|
182
|
+
sea_material: 'minecraft:water'
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### setOverworldGenerationRules
|
|
187
|
+
|
|
188
|
+
设置生物群系在主世界生成时的气候权重。
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
static setOverworldGenerationRules(
|
|
192
|
+
medium_weight: number,
|
|
193
|
+
warm_weight: number,
|
|
194
|
+
cold_weight: number
|
|
195
|
+
): Map
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**参数**
|
|
199
|
+
|
|
200
|
+
| 参数 | 类型 | 说明 |
|
|
201
|
+
|------|------|------|
|
|
202
|
+
| `medium_weight` | `number` | 中等气候权重 |
|
|
203
|
+
| `warm_weight` | `number` | 温暖气候权重 |
|
|
204
|
+
| `cold_weight` | `number` | 寒冷气候权重 |
|
|
205
|
+
|
|
206
|
+
**示例**
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// 仅生成于温暖气候
|
|
210
|
+
BiomeComponent.setOverworldGenerationRules(0, 100, 0)
|
|
211
|
+
|
|
212
|
+
// 均匀分布于所有气候
|
|
213
|
+
BiomeComponent.setOverworldGenerationRules(100, 100, 100)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### combineComponents
|
|
217
|
+
|
|
218
|
+
合并多个组件 Map。
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
static combineComponents(...componentMaps: Map[]): Map
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**示例**
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
BiomeComponent.combineComponents(
|
|
228
|
+
BiomeComponent.setClimate(0.5, 0.3, 0.7),
|
|
229
|
+
BiomeComponent.setOverworldHeight([0.1, 0.2]),
|
|
230
|
+
BiomeComponent.setSurfaceParameters({
|
|
231
|
+
sea_floor_depth: 7,
|
|
232
|
+
sea_floor_material: 'minecraft:sand',
|
|
233
|
+
foundation_material: 'minecraft:stone',
|
|
234
|
+
mid_material: 'minecraft:dirt',
|
|
235
|
+
top_material: 'minecraft:grass_block',
|
|
236
|
+
sea_material: 'minecraft:water'
|
|
237
|
+
})
|
|
238
|
+
)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### 完整示例
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { BiomeAPI, registry, BiomeComponent } from '@sapdon/core'
|
|
245
|
+
|
|
246
|
+
const biome = BiomeAPI.createBiome('sapdon:crystal_plains')
|
|
247
|
+
|
|
248
|
+
biome.addComponent(
|
|
249
|
+
BiomeComponent.combineComponents(
|
|
250
|
+
BiomeComponent.setClimate(0.3, 0.0, 0.6),
|
|
251
|
+
BiomeComponent.setOverworldHeight([0.05, 0.1]),
|
|
252
|
+
BiomeComponent.setSurfaceParameters({
|
|
253
|
+
sea_floor_depth: 5,
|
|
254
|
+
sea_floor_material: 'minecraft:sand',
|
|
255
|
+
foundation_material: 'minecraft:stone',
|
|
256
|
+
mid_material: 'minecraft:dirt',
|
|
257
|
+
top_material: 'minecraft:grass_block',
|
|
258
|
+
sea_material: 'minecraft:water'
|
|
259
|
+
}),
|
|
260
|
+
BiomeComponent.setOverworldGenerationRules(50, 100, 30)
|
|
261
|
+
)
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
registry.submit()
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## FeatureAPI
|
|
270
|
+
|
|
271
|
+
工厂函数,用于创建特征(如矿脉)和特征规则。
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import { FeatureAPI, registry } from '@sapdon/core'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### createOreFeature
|
|
280
|
+
|
|
281
|
+
创建矿脉特征。
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
FeatureAPI.createOreFeature(
|
|
285
|
+
identifier: string,
|
|
286
|
+
count: number,
|
|
287
|
+
replace_rules: any[]
|
|
288
|
+
): OreFeature
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**参数**
|
|
292
|
+
|
|
293
|
+
| 参数 | 类型 | 说明 |
|
|
294
|
+
|------|------|------|
|
|
295
|
+
| `identifier` | `string` | 特征唯一标识符 |
|
|
296
|
+
| `count` | `number` | 每区块矿石团块数量 |
|
|
297
|
+
| `replace_rules` | `object[]` | 替换规则数组 |
|
|
298
|
+
|
|
299
|
+
**示例**
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
FeatureAPI.createOreFeature(
|
|
303
|
+
'sapdon:ruby_ore_feature',
|
|
304
|
+
8,
|
|
305
|
+
[
|
|
306
|
+
{
|
|
307
|
+
places_block: 'sapdon:ruby_ore',
|
|
308
|
+
may_replace: [{ name: 'minecraft:stone' }]
|
|
309
|
+
}
|
|
310
|
+
]
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
registry.submit()
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### createFeatureRules
|
|
317
|
+
|
|
318
|
+
创建特征规则,控制特征如何在世界中生成。
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
FeatureAPI.createFeatureRules(
|
|
322
|
+
identifier: string,
|
|
323
|
+
places_feature: string
|
|
324
|
+
): FeatureRule
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**参数**
|
|
328
|
+
|
|
329
|
+
| 参数 | 类型 | 说明 |
|
|
330
|
+
|------|------|------|
|
|
331
|
+
| `identifier` | `string` | 特征规则唯一标识符 |
|
|
332
|
+
| `places_feature` | `string` | 要放置的特征标识符 |
|
|
333
|
+
|
|
334
|
+
**示例**
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
const rule = FeatureAPI.createFeatureRules(
|
|
338
|
+
'sapdon:ruby_ore_rule',
|
|
339
|
+
'sapdon:ruby_ore_feature'
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
rule.setPlacementPass('underground_pass')
|
|
343
|
+
rule.setIterations(10)
|
|
344
|
+
|
|
345
|
+
registry.submit()
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## FeatureRule
|
|
351
|
+
|
|
352
|
+
特征规则类,控制特征的生成条件和分布方式。
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import { FeatureRule, BiomeFilter, CoordinateDistribution } from '@sapdon/core'
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### setPlacementPass
|
|
359
|
+
|
|
360
|
+
设置生成阶段。
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
featureRule.setPlacementPass(pass: string): void
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
| 参数 | 类型 | 说明 |
|
|
367
|
+
|------|------|------|
|
|
368
|
+
| `pass` | `string` | 生成阶段标识符,如 `"underground_pass"`、`"surface_pass"` |
|
|
369
|
+
|
|
370
|
+
### setBiomeFilter
|
|
371
|
+
|
|
372
|
+
设置生物群系过滤条件。
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
featureRule.setBiomeFilter(biomeFilter: BiomeFilter): void
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
| 参数 | 类型 | 说明 |
|
|
379
|
+
|------|------|------|
|
|
380
|
+
| `biomeFilter` | `BiomeFilter` | 生物群系过滤条件实例 |
|
|
381
|
+
|
|
382
|
+
### setIterations
|
|
383
|
+
|
|
384
|
+
设置每区块放置尝试次数。
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
featureRule.setIterations(iterations: number): void
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
| 参数 | 类型 | 说明 |
|
|
391
|
+
|------|------|------|
|
|
392
|
+
| `iterations` | `number` | 放置尝试次数 |
|
|
393
|
+
|
|
394
|
+
### setAxisDistribution
|
|
395
|
+
|
|
396
|
+
设置指定坐标轴的分布规则。
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
featureRule.setAxisDistribution(
|
|
400
|
+
axis: 'x' | 'y' | 'z',
|
|
401
|
+
config: CoordinateDistribution
|
|
402
|
+
): void
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
| 参数 | 类型 | 说明 |
|
|
406
|
+
|------|------|------|
|
|
407
|
+
| `axis` | `string` | 坐标轴 `"x"` / `"y"` / `"z"` |
|
|
408
|
+
| `config` | `CoordinateDistribution` | 分布配置 |
|
|
409
|
+
|
|
410
|
+
### 完整示例
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
import { FeatureAPI, registry, BiomeFilter, CoordinateDistribution } from '@sapdon/core'
|
|
414
|
+
|
|
415
|
+
// 1. 创建矿脉特征
|
|
416
|
+
FeatureAPI.createOreFeature(
|
|
417
|
+
'sapdon:ruby_ore_feature',
|
|
418
|
+
10,
|
|
419
|
+
[
|
|
420
|
+
{
|
|
421
|
+
places_block: 'sapdon:ruby_ore',
|
|
422
|
+
may_replace: [{ name: 'minecraft:stone' }]
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
// 2. 创建特征规则
|
|
428
|
+
const rule = FeatureAPI.createFeatureRules(
|
|
429
|
+
'sapdon:ruby_ore_rule',
|
|
430
|
+
'sapdon:ruby_ore_feature'
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
// 3. 配置生成条件
|
|
434
|
+
rule.setPlacementPass('underground_pass')
|
|
435
|
+
|
|
436
|
+
// 4. 设置生物群系过滤 — 仅主世界群系
|
|
437
|
+
const biomeFilter = new BiomeFilter()
|
|
438
|
+
biomeFilter.addSimpleCondition('has_biome_tag', '==', 'overworld')
|
|
439
|
+
rule.setBiomeFilter(biomeFilter)
|
|
440
|
+
|
|
441
|
+
// 5. 设置放置尝试次数
|
|
442
|
+
rule.setIterations(10)
|
|
443
|
+
|
|
444
|
+
// 6. 设置 Y 轴分布范围 (5 ~ 40 层)
|
|
445
|
+
rule.setAxisDistribution('y', new CoordinateDistribution('uniform', [5, 40]))
|
|
446
|
+
// X/Z 轴默认范围为 [0, 16](单个区块范围)
|
|
447
|
+
rule.setAxisDistribution('x', new CoordinateDistribution('uniform', [0, 16]))
|
|
448
|
+
rule.setAxisDistribution('z', new CoordinateDistribution('uniform', [0, 16]))
|
|
449
|
+
|
|
450
|
+
registry.submit()
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
## BiomeFilter
|
|
456
|
+
|
|
457
|
+
生物群系过滤条件类,用于指定特征在哪些群系中生成。
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import { BiomeFilter } from '@sapdon/core'
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### 方法
|
|
464
|
+
|
|
465
|
+
| 方法 | 返回 | 说明 |
|
|
466
|
+
|------|------|------|
|
|
467
|
+
| `addSimpleCondition(test, operator, value)` | `this` | 添加简单条件 |
|
|
468
|
+
| `addLogicGroup(logicType, conditions)` | `this` | 添加逻辑组(`any_of` / `all_of`) |
|
|
469
|
+
|
|
470
|
+
**示例**
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
const filter = new BiomeFilter()
|
|
474
|
+
|
|
475
|
+
// 仅主世界群系
|
|
476
|
+
filter.addSimpleCondition('has_biome_tag', '==', 'overworld')
|
|
477
|
+
|
|
478
|
+
// 排除特定群系
|
|
479
|
+
filter.addLogicGroup('any_of', [
|
|
480
|
+
{ test: 'has_biome_tag', operator: '!=', value: 'ocean' },
|
|
481
|
+
{ test: 'has_biome_tag', operator: '!=', value: 'river' }
|
|
482
|
+
])
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## CoordinateDistribution
|
|
488
|
+
|
|
489
|
+
坐标轴分布规则类,控制特征在 X / Y / Z 轴上的分布范围。
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
import { CoordinateDistribution } from '@sapdon/core'
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### 构造函数
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
new CoordinateDistribution(
|
|
499
|
+
distribution: 'uniform' | 'triangle' = 'uniform',
|
|
500
|
+
extent: [number, number] = [0, 16]
|
|
501
|
+
)
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**参数**
|
|
505
|
+
|
|
506
|
+
| 参数 | 类型 | 说明 |
|
|
507
|
+
|------|------|------|
|
|
508
|
+
| `distribution` | `string` | 分布类型:`"uniform"`(均匀)、`"triangle"`(三角) |
|
|
509
|
+
| `extent` | `[number, number]` | 范围,如 `[0, 16]`、`[5, 40]` |
|
|
510
|
+
|
|
511
|
+
**示例**
|
|
512
|
+
|
|
513
|
+
```typescript
|
|
514
|
+
// Y 轴 5-40 层均匀分布
|
|
515
|
+
new CoordinateDistribution('uniform', [5, 40])
|
|
516
|
+
|
|
517
|
+
// X 轴整区块均匀分布
|
|
518
|
+
new CoordinateDistribution('uniform', [0, 16])
|
|
519
|
+
|
|
520
|
+
// Y 轴三角分布(中间值附近概率更高)
|
|
521
|
+
new CoordinateDistribution('triangle', [0, 64])
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 类型汇总
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
// 生物群系
|
|
530
|
+
BiomeAPI.createBiome(identifier): Biome
|
|
531
|
+
|
|
532
|
+
class Biome
|
|
533
|
+
addComponent(componentMap): this
|
|
534
|
+
|
|
535
|
+
class BiomeComponent
|
|
536
|
+
static setClimate(downfall, snow, temp): Map
|
|
537
|
+
static setOverworldHeight(noise_params): Map
|
|
538
|
+
static setSurfaceParameters(params): Map
|
|
539
|
+
static setOverworldGenerationRules(medium, warm, cold): Map
|
|
540
|
+
static combineComponents(...maps): Map
|
|
541
|
+
|
|
542
|
+
// 特征
|
|
543
|
+
FeatureAPI.createOreFeature(id, count, replace_rules): OreFeature
|
|
544
|
+
FeatureAPI.createFeatureRules(id, places_feature): FeatureRule
|
|
545
|
+
|
|
546
|
+
class FeatureRule
|
|
547
|
+
setPlacementPass(pass): void
|
|
548
|
+
setBiomeFilter(filter): void
|
|
549
|
+
setIterations(count): void
|
|
550
|
+
setAxisDistribution(axis, config): void
|
|
551
|
+
|
|
552
|
+
class BiomeFilter
|
|
553
|
+
addSimpleCondition(test, operator, value): this
|
|
554
|
+
addLogicGroup(type, conditions): this
|
|
555
|
+
|
|
556
|
+
class CoordinateDistribution
|
|
557
|
+
constructor(distribution, extent)
|
|
558
|
+
```
|