# 方块

:::warning
该 API 文档：[GameVoxels](https://docs.dao3.fun/api/GameVoxels/operate.html)
:::

## 改进说明

### 修改背景

在原先的官方 d.ts 文件中，该 API 接口的方块数据被宽泛地定义为`number`或`string`类型，这可能会引发以下问题：

- 允许输入任意数据
- 运行时可能因无法获取对应方块而产生 BUG

### 改进方案

因为神岛方块是有限的，我们引入了自定义类型来严格规范输入数据。

### 改进效果

- 确保数据合法性
- 提升代码可读性
- 增强错误检查能力

## 使用指南

### 示例演示

#### 正常输入

![](/QQ20241209-110216.png)

#### 异常输入

![](/QQ20241209-110144.png)

## 数据类型定义

```typescript
/**
 * 方块收录最新时间：2024/10/17
 * 已收录384种方块
 */
type voxelName =
  | "A"
  | "B"
  | "C"
  | "D"
  | "E"
  | "F"
  | "G"
  | "H"
  | "I"
  | "J"
  | "K"
  | "L"
  | "M"
  | "N"
  | "O"
  | "P"
  | "Q"
  | "R"
  | "S"
  | "T"
  | "U"
  | "V"
  | "W"
  | "X"
  | "Y"
  | "Z"
  | "acacia"
  | "add"
  | "air"
  | "air_duct"
  | "ampersand"
  | "asterisk"
  | "at"
  | "backslash"
  | "bamboo"
  | "barrier"
  | "bat_window"
  | "bear_footprint"
  | "biscuit"
  | "black"
  | "black_glass"
  | "blue"
  | "blue_decorative_light"
  | "blue_gift"
  | "blue_glass"
  | "blue_grass"
  | "blue_grass_all"
  | "blue_light"
  | "blue_surface_01"
  | "blue_surface_02"
  | "blueberry_juice"
  | "board0"
  | "board1"
  | "board10"
  | "board11"
  | "board12"
  | "board13"
  | "board14"
  | "board15"
  | "board2"
  | "board3"
  | "board4"
  | "board5"
  | "board6"
  | "board7"
  | "board8"
  | "board9"
  | "board_01"
  | "board_02"
  | "board_03"
  | "board_04"
  | "board_05"
  | "board_06"
  | "board_07"
  | "bookshelf"
  | "bounce_pad"
  | "bracket_close"
  | "bracket_open"
  | "brick_01"
  | "brick_02"
  | "brick_red"
  | "button"
  | "cadet_blue"
  | "candy"
  | "caret"
  | "carpet_01"
  | "carpet_02"
  | "carpet_03"
  | "carpet_04"
  | "carpet_05"
  | "carpet_06"
  | "carpet_07"
  | "carpet_08"
  | "carpet_09"
  | "carpet_10"
  | "carpet_11"
  | "carpet_12"
  | "carpet_13"
  | "coffee"
  | "coffee_gray"
  | "colon"
  | "color_glass"
  | "comma"
  | "conveyor"
  | "crane_lantern"
  | "crane_roof_01"
  | "crane_roof_02"
  | "cross_window"
  | "dark_blue_grass"
  | "dark_blue_grass_all"
  | "dark_brick_00"
  | "dark_brick_01"
  | "dark_brick_02"
  | "dark_grass"
  | "dark_grass_all"
  | "dark_grass_rock"
  | "dark_grass_sand"
  | "dark_gray"
  | "dark_orchid"
  | "dark_purple_grass"
  | "dark_purple_grass_all"
  | "dark_red"
  | "dark_red_grass"
  | "dark_red_grass_all"
  | "dark_salmon"
  | "dark_sand"
  | "dark_slate_blue"
  | "dark_stone"
  | "dark_surface"
  | "dark_volcanic_rock"
  | "dark_yellow_grass"
  | "dark_yellow_grass_all"
  | "dirt"
  | "divide"
  | "eight"
  | "equal"
  | "exclamation_mark"
  | "express_box"
  | "fan"
  | "firecracker"
  | "five"
  | "four"
  | "fu"
  | "geometric_window_01"
  | "geometric_window_02"
  | "glass"
  | "gold_trim_brick"
  | "grape_juice"
  | "grass"
  | "grass_all"
  | "grass_rock"
  | "grass_sand"
  | "greater_than"
  | "green_decorative_light"
  | "green_glass"
  | "green_leaf"
  | "green_light"
  | "greenbelt_L"
  | "greenbelt_L1"
  | "grey_stone_brick"
  | "honeycomb_01"
  | "honeycomb_02"
  | "ice"
  | "ice_brick"
  | "ice_wall"
  | "indigo_light"
  | "lab_lamp_01"
  | "lab_lamp_02"
  | "lab_lamp_03"
  | "lab_material_01"
  | "lab_material_02"
  | "lab_material_03"
  | "lab_material_04"
  | "lab_material_05"
  | "lab_material_06"
  | "lab_material_07"
  | "lab_material_08"
  | "lab_material_09"
  | "lab_material_10"
  | "lab_material_11"
  | "lab_material_12"
  | "lab_material_13"
  | "lab_material_14"
  | "lab_material_15"
  | "lab_screen"
  | "lab_wire"
  | "lantern_01"
  | "lantern_02"
  | "lava01"
  | "lava02"
  | "leaf_01"
  | "leaf_02"
  | "leaf_03"
  | "leaf_04"
  | "leaf_05"
  | "leaf_06"
  | "ledfloor01"
  | "ledfloor02"
  | "lemon"
  | "lemon_juice"
  | "less_than"
  | "light_blue_grass"
  | "light_blue_grass_all"
  | "light_dirt"
  | "light_gray"
  | "light_grey_stone_brick"
  | "light_purple_grass_"
  | "light_purple_grass_all"
  | "light_sand"
  | "light_volcanic_rock"
  | "lime_juice"
  | "macaroon"
  | "maroon"
  | "medium_gray"
  | "medium_green"
  | "medium_orchid"
  | "medium_purple"
  | "medium_spring_green"
  | "medium_violet_red"
  | "medium_yellow"
  | "milk"
  | "mint_green"
  | "mint_green_light"
  | "multiply"
  | "navajo_white"
  | "nine"
  | "olive_green"
  | "one"
  | "orange"
  | "orange_grass"
  | "orange_grass_all"
  | "orange_juice"
  | "orange_light"
  | "orange_red"
  | "palace_carving"
  | "palace_cloud"
  | "palace_eaves_01"
  | "palace_eaves_02"
  | "palace_eaves_03"
  | "palace_eaves_04"
  | "palace_eaves_05"
  | "palace_eaves_06"
  | "palace_eaves_07"
  | "palace_eaves_08"
  | "palace_floor"
  | "palace_lamp"
  | "palace_roof"
  | "palace_window"
  | "pale_green"
  | "palm"
  | "paren_close"
  | "paren_open"
  | "peach_juice"
  | "percent"
  | "period"
  | "peru"
  | "pink"
  | "pink_cake"
  | "pink_grass"
  | "pink_grass_all"
  | "pink_light"
  | "plank_01"
  | "plank_02"
  | "plank_03"
  | "plank_04"
  | "plank_05"
  | "plank_06"
  | "plank_07"
  | "polar_ice"
  | "polar_region"
  | "pound"
  | "powder_blue"
  | "pumpkin"
  | "pumpkin_lantern"
  | "purple"
  | "purple_grass"
  | "purple_grass_all"
  | "purple_surface_01"
  | "purple_surface_02"
  | "quartz_brick"
  | "question_mark"
  | "quotation_mark"
  | "rainbow_cube"
  | "red"
  | "red_brick"
  | "red_brick_floor"
  | "red_brick_wall"
  | "red_decorative_light"
  | "red_gift"
  | "red_glass"
  | "red_light"
  | "rock"
  | "roof_blue_04"
  | "roof_green"
  | "roof_grey"
  | "roof_purple"
  | "roof_red"
  | "roof_yellow"
  | "sakura_pink"
  | "sand"
  | "sand_stones"
  | "semicolon"
  | "seven"
  | "sienna"
  | "six"
  | "sky_blue"
  | "slash"
  | "snow"
  | "snow_grass"
  | "snow_land"
  | "snowflake_lamp"
  | "snowland"
  | "snowman_body"
  | "snowman_head"
  | "soy_sauce"
  | "special_grass_01"
  | "special_grass_02"
  | "special_grass_03"
  | "special_grass_04"
  | "special_grass_05"
  | "special_grass_06"
  | "special_grass_07"
  | "special_grass_08"
  | "special_grass_09"
  | "special_grass_10"
  | "special_grass_11"
  | "special_grass_12"
  | "special_grass_13"
  | "special_grass_14"
  | "special_grass_15"
  | "special_grass_16"
  | "special_land_01"
  | "special_sand_01"
  | "special_sand_02"
  | "special_sand_03"
  | "special_sand_04"
  | "special_sand_05"
  | "spiderweb"
  | "stained_glass"
  | "stainless_steel"
  | "star_lamp"
  | "stone"
  | "stone_brick_01"
  | "stone_brick_02"
  | "stone_pillar_03"
  | "stone_pillar_04"
  | "stone_pillar_05"
  | "stone_pillar_06"
  | "stone_wall"
  | "stone_wall_01"
  | "strawberry_juice"
  | "stripe_01"
  | "stripe_02"
  | "stripe_03"
  | "stripe_04"
  | "stripe_05"
  | "subtract"
  | "television"
  | "three"
  | "tilde"
  | "toolbox"
  | "traditional_window"
  | "treasure_chest"
  | "turquoise"
  | "two"
  | "warm_yellow_light"
  | "water"
  | "white"
  | "white_grass"
  | "white_light"
  | "window"
  | "windygrass"
  | "winter_leaf"
  | "withered_grass"
  | "withered_grass_land"
  | "wood"
  | "wooden_box"
  | "woodstone_12"
  | "yellow_decorative_light"
  | "yellow_grass"
  | "yellow_green"
  | "yellow_light"
  | "zero";
type voxelId =
  | 37
  | 39
  | 41
  | 43
  | 45
  | 47
  | 49
  | 51
  | 53
  | 55
  | 57
  | 59
  | 61
  | 63
  | 65
  | 67
  | 69
  | 71
  | 73
  | 75
  | 77
  | 79
  | 81
  | 83
  | 85
  | 87
  | 133
  | 3
  | 0
  | 585
  | 485
  | 487
  | 489
  | 491
  | 574
  | 650
  | 546
  | 553
  | 341
  | 175
  | 302
  | 363
  | 566
  | 557
  | 276
  | 669
  | 671
  | 291
  | 349
  | 351
  | 416
  | 433
  | 435
  | 453
  | 455
  | 457
  | 459
  | 461
  | 463
  | 465
  | 467
  | 181
  | 183
  | 309
  | 311
  | 313
  | 315
  | 635
  | 483
  | 631
  | 493
  | 495
  | 109
  | 153
  | 155
  | 587
  | 89
  | 551
  | 497
  | 195
  | 197
  | 199
  | 201
  | 203
  | 205
  | 207
  | 235
  | 237
  | 239
  | 241
  | 243
  | 245
  | 428
  | 379
  | 499
  | 501
  | 471
  | 405
  | 401
  | 403
  | 162
  | 693
  | 695
  | 329
  | 331
  | 333
  | 317
  | 745
  | 743
  | 725
  | 95
  | 369
  | 697
  | 699
  | 107
  | 685
  | 687
  | 383
  | 729
  | 113
  | 327
  | 357
  | 735
  | 689
  | 691
  | 125
  | 9
  | 33
  | 11
  | 13
  | 479
  | 589
  | 582
  | 27
  | 25
  | 577
  | 164
  | 166
  | 170
  | 151
  | 420
  | 127
  | 741
  | 739
  | 723
  | 505
  | 278
  | 424
  | 287
  | 319
  | 321
  | 149
  | 535
  | 537
  | 398
  | 145
  | 249
  | 289
  | 591
  | 593
  | 595
  | 597
  | 599
  | 601
  | 603
  | 605
  | 607
  | 609
  | 611
  | 613
  | 615
  | 617
  | 619
  | 621
  | 622
  | 624
  | 627
  | 629
  | 157
  | 159
  | 465
  | 467
  | 251
  | 253
  | 529
  | 531
  | 533
  | 633
  | 473
  | 475
  | 121
  | 418
  | 507
  | 677
  | 679
  | 737
  | 97
  | 147
  | 681
  | 683
  | 727
  | 733
  | 414
  | 339
  | 377
  | 111
  | 391
  | 371
  | 373
  | 397
  | 375
  | 389
  | 347
  | 345
  | 517
  | 93
  | 543
  | 549
  | 293
  | 665
  | 667
  | 353
  | 355
  | 155
  | 15
  | 519
  | 581
  | 105
  | 304
  | 259
  | 261
  | 570
  | 555
  | 281
  | 359
  | 231
  | 229
  | 407
  | 227
  | 225
  | 233
  | 117
  | 135
  | 731
  | 521
  | 31
  | 393
  | 29
  | 91
  | 523
  | 169
  | 653
  | 655
  | 565
  | 343
  | 559
  | 561
  | 426
  | 701
  | 703
  | 705
  | 707
  | 709
  | 711
  | 713
  | 715
  | 717
  | 719
  | 747
  | 749
  | 751
  | 753
  | 755
  | 757
  | 721
  | 759
  | 761
  | 763
  | 765
  | 767
  | 544
  | 123
  | 247
  | 562
  | 129
  | 323
  | 325
  | 267
  | 269
  | 271
  | 273
  | 275
  | 335
  | 412
  | 185
  | 187
  | 189
  | 191
  | 193
  | 5
  | 481
  | 23
  | 525
  | 647
  | 578
  | 649
  | 367
  | 21
  | 301
  | 364
  | 177
  | 539
  | 299
  | 160
  | 469
  | 527
  | 659
  | 657
  | 257
  | 179
  | 411
  | 572
  | 477
  | 101
  | 285
  | 17;
type voxelRotation = 0 | 1 | 2 | 3;
```
