redscript-mc 3.0.1 → 3.0.2

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.
Files changed (225) hide show
  1. package/.github/workflows/ci.yml +1 -0
  2. package/README.md +119 -313
  3. package/README.zh.md +118 -314
  4. package/ROADMAP.md +5 -5
  5. package/dist/data/impl_test/function/counter/get.mcfunction +5 -0
  6. package/dist/data/impl_test/function/counter/inc.mcfunction +7 -0
  7. package/dist/data/impl_test/function/counter/new.mcfunction +4 -0
  8. package/dist/data/impl_test/function/load.mcfunction +1 -0
  9. package/dist/data/impl_test/function/test_impl.mcfunction +10 -0
  10. package/dist/data/minecraft/tags/function/load.json +5 -0
  11. package/dist/data/playground/function/load.mcfunction +1 -0
  12. package/dist/data/playground/function/start.mcfunction +4 -0
  13. package/dist/data/playground/function/start__say_macro_t1.mcfunction +1 -0
  14. package/dist/data/playground/function/stop.mcfunction +5 -0
  15. package/dist/data/playground/function/stop__say_macro_t0.mcfunction +1 -0
  16. package/dist/data/stdlib_queue8_test/function/__queue_append_apply.mcfunction +4 -0
  17. package/dist/data/stdlib_queue8_test/function/__queue_peek_apply.mcfunction +4 -0
  18. package/dist/data/stdlib_queue8_test/function/__queue_size_raw_apply.mcfunction +4 -0
  19. package/dist/data/stdlib_queue8_test/function/load.mcfunction +1 -0
  20. package/dist/data/stdlib_queue8_test/function/queue_clear.mcfunction +6 -0
  21. package/dist/data/stdlib_queue8_test/function/queue_empty__merge_1.mcfunction +5 -0
  22. package/dist/data/stdlib_queue8_test/function/queue_empty__then_0.mcfunction +5 -0
  23. package/dist/data/stdlib_queue8_test/function/queue_peek__merge_1.mcfunction +13 -0
  24. package/dist/data/stdlib_queue8_test/function/queue_peek__then_0.mcfunction +5 -0
  25. package/dist/data/stdlib_queue8_test/function/queue_pop__merge_1.mcfunction +15 -0
  26. package/dist/data/stdlib_queue8_test/function/queue_pop__then_0.mcfunction +5 -0
  27. package/dist/data/stdlib_queue8_test/function/queue_push__const_11.mcfunction +6 -0
  28. package/dist/data/stdlib_queue8_test/function/queue_push__const_22.mcfunction +6 -0
  29. package/dist/data/stdlib_queue8_test/function/queue_size.mcfunction +13 -0
  30. package/dist/data/stdlib_queue8_test/function/test_queue_push_and_size.mcfunction +13 -0
  31. package/dist/data/test/function/load.mcfunction +1 -0
  32. package/dist/data/test/function/say_at.mcfunction +6 -0
  33. package/dist/data/test/function/test.mcfunction +4 -0
  34. package/dist/pack.mcmeta +6 -0
  35. package/dist/package.json +1 -1
  36. package/dist/src/__tests__/formatter-extra.test.d.ts +7 -0
  37. package/dist/src/__tests__/formatter-extra.test.js +123 -0
  38. package/dist/src/__tests__/global-vars.test.d.ts +13 -0
  39. package/dist/src/__tests__/global-vars.test.js +156 -0
  40. package/dist/src/__tests__/lint/new-rules.test.d.ts +9 -0
  41. package/dist/src/__tests__/lint/new-rules.test.js +402 -0
  42. package/dist/src/__tests__/lsp-rename.test.d.ts +8 -0
  43. package/dist/src/__tests__/lsp-rename.test.js +157 -0
  44. package/dist/src/__tests__/mc-integration/say-fstring.test.d.ts +11 -0
  45. package/dist/src/__tests__/mc-integration/say-fstring.test.js +220 -0
  46. package/dist/src/__tests__/mc-integration/stdlib-coverage-2.test.js +1 -1
  47. package/dist/src/__tests__/mc-integration/stdlib-coverage-3.test.js +1 -1
  48. package/dist/src/__tests__/mc-integration/stdlib-coverage-4.test.js +1 -1
  49. package/dist/src/__tests__/mc-integration/stdlib-coverage-5.test.js +1 -1
  50. package/dist/src/__tests__/mc-integration/stdlib-coverage-6.test.js +1 -1
  51. package/dist/src/__tests__/mc-integration/stdlib-coverage-7.test.js +1 -1
  52. package/dist/src/__tests__/mc-integration/stdlib-coverage-8.test.js +1 -1
  53. package/dist/src/__tests__/mc-syntax.test.js +4 -1
  54. package/dist/src/__tests__/monomorphize-coverage.test.d.ts +9 -0
  55. package/dist/src/__tests__/monomorphize-coverage.test.js +204 -0
  56. package/dist/src/__tests__/optimizer-cse.test.d.ts +7 -0
  57. package/dist/src/__tests__/optimizer-cse.test.js +226 -0
  58. package/dist/src/__tests__/parser.test.js +4 -13
  59. package/dist/src/__tests__/repl-server-extra.test.js +6 -7
  60. package/dist/src/__tests__/repl-server.test.js +5 -7
  61. package/dist/src/__tests__/stdlib/queue.test.js +6 -6
  62. package/dist/src/cli.js +0 -0
  63. package/dist/src/lexer/index.js +2 -1
  64. package/dist/src/lint/index.d.ts +12 -5
  65. package/dist/src/lint/index.js +730 -5
  66. package/dist/src/lsp/main.js +0 -0
  67. package/dist/src/mc-test/client.d.ts +21 -0
  68. package/dist/src/mc-test/client.js +34 -0
  69. package/dist/src/mir/lower.js +108 -6
  70. package/dist/src/optimizer/interprocedural.js +37 -2
  71. package/dist/src/parser/decl-parser.d.ts +19 -0
  72. package/dist/src/parser/decl-parser.js +323 -0
  73. package/dist/src/parser/expr-parser.d.ts +46 -0
  74. package/dist/src/parser/expr-parser.js +759 -0
  75. package/dist/src/parser/index.d.ts +8 -129
  76. package/dist/src/parser/index.js +13 -2262
  77. package/dist/src/parser/stmt-parser.d.ts +28 -0
  78. package/dist/src/parser/stmt-parser.js +577 -0
  79. package/dist/src/parser/type-parser.d.ts +20 -0
  80. package/dist/src/parser/type-parser.js +257 -0
  81. package/dist/src/parser/utils.d.ts +34 -0
  82. package/dist/src/parser/utils.js +141 -0
  83. package/docs/dev/README-mc-integration-tests.md +141 -0
  84. package/docs/lint-rules.md +162 -0
  85. package/docs/stdlib/bigint.md +2 -0
  86. package/editors/vscode/README.md +63 -41
  87. package/editors/vscode/out/extension.js +1881 -1776
  88. package/editors/vscode/out/lsp-server.js +4257 -3651
  89. package/editors/vscode/package-lock.json +3 -3
  90. package/editors/vscode/package.json +1 -1
  91. package/examples/loops-demo.mcrs +87 -0
  92. package/package.json +1 -1
  93. package/redscript-docs/docs/en/stdlib/advanced.md +629 -0
  94. package/redscript-docs/docs/en/stdlib/bigint.md +316 -0
  95. package/redscript-docs/docs/en/stdlib/bits.md +292 -0
  96. package/redscript-docs/docs/en/stdlib/bossbar.md +177 -0
  97. package/redscript-docs/docs/en/stdlib/calculus.md +289 -0
  98. package/redscript-docs/docs/en/stdlib/color.md +353 -0
  99. package/redscript-docs/docs/en/stdlib/combat.md +88 -0
  100. package/redscript-docs/docs/en/stdlib/cooldown.md +82 -0
  101. package/redscript-docs/docs/en/stdlib/dialog.md +155 -0
  102. package/redscript-docs/docs/en/stdlib/easing.md +558 -0
  103. package/redscript-docs/docs/en/stdlib/ecs.md +475 -0
  104. package/redscript-docs/docs/en/stdlib/effects.md +324 -0
  105. package/redscript-docs/docs/en/stdlib/events.md +3 -0
  106. package/redscript-docs/docs/en/stdlib/expr.md +45 -0
  107. package/redscript-docs/docs/en/stdlib/fft.md +141 -0
  108. package/redscript-docs/docs/en/stdlib/geometry.md +430 -0
  109. package/redscript-docs/docs/en/stdlib/graph.md +259 -0
  110. package/redscript-docs/docs/en/stdlib/heap.md +185 -0
  111. package/redscript-docs/docs/en/stdlib/interactions.md +179 -0
  112. package/redscript-docs/docs/en/stdlib/inventory.md +97 -0
  113. package/redscript-docs/docs/en/stdlib/linalg.md +557 -0
  114. package/redscript-docs/docs/en/stdlib/list.md +559 -0
  115. package/redscript-docs/docs/en/stdlib/map.md +140 -0
  116. package/redscript-docs/docs/en/stdlib/math.md +193 -0
  117. package/redscript-docs/docs/en/stdlib/math_hp.md +149 -0
  118. package/redscript-docs/docs/en/stdlib/matrix.md +403 -0
  119. package/redscript-docs/docs/en/stdlib/mobs.md +965 -0
  120. package/redscript-docs/docs/en/stdlib/noise.md +244 -0
  121. package/redscript-docs/docs/en/stdlib/ode.md +253 -0
  122. package/redscript-docs/docs/en/stdlib/parabola.md +342 -0
  123. package/redscript-docs/docs/en/stdlib/particles.md +311 -0
  124. package/redscript-docs/docs/en/stdlib/pathfind.md +255 -0
  125. package/redscript-docs/docs/en/stdlib/physics.md +493 -0
  126. package/redscript-docs/docs/en/stdlib/player.md +78 -0
  127. package/redscript-docs/docs/en/stdlib/quaternion.md +673 -0
  128. package/redscript-docs/docs/en/stdlib/queue.md +134 -0
  129. package/redscript-docs/docs/en/stdlib/random.md +223 -0
  130. package/redscript-docs/docs/en/stdlib/result.md +143 -0
  131. package/redscript-docs/docs/en/stdlib/scheduler.md +183 -0
  132. package/redscript-docs/docs/en/stdlib/set_int.md +190 -0
  133. package/redscript-docs/docs/en/stdlib/sets.md +101 -0
  134. package/redscript-docs/docs/en/stdlib/signal.md +400 -0
  135. package/redscript-docs/docs/en/stdlib/sort.md +104 -0
  136. package/redscript-docs/docs/en/stdlib/spawn.md +147 -0
  137. package/redscript-docs/docs/en/stdlib/state.md +142 -0
  138. package/redscript-docs/docs/en/stdlib/strings.md +154 -0
  139. package/redscript-docs/docs/en/stdlib/tags.md +3451 -0
  140. package/redscript-docs/docs/en/stdlib/teams.md +153 -0
  141. package/redscript-docs/docs/en/stdlib/timer.md +246 -0
  142. package/redscript-docs/docs/en/stdlib/vec.md +158 -0
  143. package/redscript-docs/docs/en/stdlib/world.md +298 -0
  144. package/redscript-docs/docs/zh/stdlib/advanced.md +615 -0
  145. package/redscript-docs/docs/zh/stdlib/bigint.md +316 -0
  146. package/redscript-docs/docs/zh/stdlib/bits.md +292 -0
  147. package/redscript-docs/docs/zh/stdlib/bossbar.md +170 -0
  148. package/redscript-docs/docs/zh/stdlib/calculus.md +287 -0
  149. package/redscript-docs/docs/zh/stdlib/color.md +353 -0
  150. package/redscript-docs/docs/zh/stdlib/combat.md +88 -0
  151. package/redscript-docs/docs/zh/stdlib/cooldown.md +84 -0
  152. package/redscript-docs/docs/zh/stdlib/dialog.md +152 -0
  153. package/redscript-docs/docs/zh/stdlib/easing.md +558 -0
  154. package/redscript-docs/docs/zh/stdlib/ecs.md +472 -0
  155. package/redscript-docs/docs/zh/stdlib/effects.md +324 -0
  156. package/redscript-docs/docs/zh/stdlib/events.md +3 -0
  157. package/redscript-docs/docs/zh/stdlib/expr.md +37 -0
  158. package/redscript-docs/docs/zh/stdlib/fft.md +128 -0
  159. package/redscript-docs/docs/zh/stdlib/geometry.md +430 -0
  160. package/redscript-docs/docs/zh/stdlib/graph.md +259 -0
  161. package/redscript-docs/docs/zh/stdlib/heap.md +185 -0
  162. package/redscript-docs/docs/zh/stdlib/interactions.md +160 -0
  163. package/redscript-docs/docs/zh/stdlib/inventory.md +94 -0
  164. package/redscript-docs/docs/zh/stdlib/linalg.md +543 -0
  165. package/redscript-docs/docs/zh/stdlib/list.md +561 -0
  166. package/redscript-docs/docs/zh/stdlib/map.md +132 -0
  167. package/redscript-docs/docs/zh/stdlib/math.md +193 -0
  168. package/redscript-docs/docs/zh/stdlib/math_hp.md +143 -0
  169. package/redscript-docs/docs/zh/stdlib/matrix.md +396 -0
  170. package/redscript-docs/docs/zh/stdlib/mobs.md +965 -0
  171. package/redscript-docs/docs/zh/stdlib/noise.md +244 -0
  172. package/redscript-docs/docs/zh/stdlib/ode.md +243 -0
  173. package/redscript-docs/docs/zh/stdlib/parabola.md +337 -0
  174. package/redscript-docs/docs/zh/stdlib/particles.md +307 -0
  175. package/redscript-docs/docs/zh/stdlib/pathfind.md +255 -0
  176. package/redscript-docs/docs/zh/stdlib/physics.md +493 -0
  177. package/redscript-docs/docs/zh/stdlib/player.md +78 -0
  178. package/redscript-docs/docs/zh/stdlib/quaternion.md +669 -0
  179. package/redscript-docs/docs/zh/stdlib/queue.md +124 -0
  180. package/redscript-docs/docs/zh/stdlib/random.md +222 -0
  181. package/redscript-docs/docs/zh/stdlib/result.md +147 -0
  182. package/redscript-docs/docs/zh/stdlib/scheduler.md +173 -0
  183. package/redscript-docs/docs/zh/stdlib/set_int.md +180 -0
  184. package/redscript-docs/docs/zh/stdlib/sets.md +107 -0
  185. package/redscript-docs/docs/zh/stdlib/signal.md +373 -0
  186. package/redscript-docs/docs/zh/stdlib/sort.md +104 -0
  187. package/redscript-docs/docs/zh/stdlib/spawn.md +142 -0
  188. package/redscript-docs/docs/zh/stdlib/state.md +134 -0
  189. package/redscript-docs/docs/zh/stdlib/strings.md +107 -0
  190. package/redscript-docs/docs/zh/stdlib/tags.md +3451 -0
  191. package/redscript-docs/docs/zh/stdlib/teams.md +150 -0
  192. package/redscript-docs/docs/zh/stdlib/timer.md +254 -0
  193. package/redscript-docs/docs/zh/stdlib/vec.md +158 -0
  194. package/redscript-docs/docs/zh/stdlib/world.md +289 -0
  195. package/src/__tests__/formatter-extra.test.ts +139 -0
  196. package/src/__tests__/global-vars.test.ts +171 -0
  197. package/src/__tests__/lint/new-rules.test.ts +437 -0
  198. package/src/__tests__/lsp-rename.test.ts +171 -0
  199. package/src/__tests__/mc-integration/say-fstring.test.ts +211 -0
  200. package/src/__tests__/mc-integration/stdlib-coverage-2.test.ts +1 -1
  201. package/src/__tests__/mc-integration/stdlib-coverage-3.test.ts +1 -1
  202. package/src/__tests__/mc-integration/stdlib-coverage-4.test.ts +1 -1
  203. package/src/__tests__/mc-integration/stdlib-coverage-5.test.ts +1 -1
  204. package/src/__tests__/mc-integration/stdlib-coverage-6.test.ts +1 -1
  205. package/src/__tests__/mc-integration/stdlib-coverage-7.test.ts +1 -1
  206. package/src/__tests__/mc-integration/stdlib-coverage-8.test.ts +1 -1
  207. package/src/__tests__/mc-syntax.test.ts +3 -0
  208. package/src/__tests__/monomorphize-coverage.test.ts +220 -0
  209. package/src/__tests__/optimizer-cse.test.ts +250 -0
  210. package/src/__tests__/parser.test.ts +4 -13
  211. package/src/__tests__/repl-server-extra.test.ts +6 -6
  212. package/src/__tests__/repl-server.test.ts +5 -6
  213. package/src/__tests__/stdlib/queue.test.ts +6 -6
  214. package/src/lexer/index.ts +2 -1
  215. package/src/lint/index.ts +713 -5
  216. package/src/mc-test/client.ts +40 -0
  217. package/src/mir/lower.ts +111 -2
  218. package/src/optimizer/interprocedural.ts +40 -2
  219. package/src/parser/decl-parser.ts +349 -0
  220. package/src/parser/expr-parser.ts +838 -0
  221. package/src/parser/index.ts +17 -2558
  222. package/src/parser/stmt-parser.ts +585 -0
  223. package/src/parser/type-parser.ts +276 -0
  224. package/src/parser/utils.ts +173 -0
  225. package/src/stdlib/queue.mcrs +19 -6
@@ -0,0 +1,337 @@
1
+ # Parabola
2
+
3
+ > 本文档由 `src/stdlib/parabola.mcrs` 自动生成,请勿手动编辑。
4
+
5
+ ## API 列表
6
+
7
+ - [parabola_gravity](#parabola-gravity)
8
+ - [parabola_gravity_half](#parabola-gravity-half)
9
+ - [parabola_vx](#parabola-vx)
10
+ - [parabola_vy](#parabola-vy)
11
+ - [parabola_vz](#parabola-vz)
12
+ - [parabola_speed_xz](#parabola-speed-xz)
13
+ - [parabola_x](#parabola-x)
14
+ - [parabola_y](#parabola-y)
15
+ - [parabola_z](#parabola-z)
16
+ - [parabola_flight_time](#parabola-flight-time)
17
+ - [parabola_max_height](#parabola-max-height)
18
+ - [parabola_step_vx](#parabola-step-vx)
19
+ - [parabola_step_vy](#parabola-step-vy)
20
+ - [parabola_step_vz](#parabola-step-vz)
21
+ - [parabola_ticks_for_range](#parabola-ticks-for-range)
22
+ - [parabola_in_range](#parabola-in-range)
23
+
24
+ ---
25
+
26
+ ## `parabola_gravity` <Badge type="info" text="v2.0.0" />
27
+
28
+ 每 tick 的 Minecraft 重力加速度(×10000,固定为 800)
29
+
30
+ ```redscript
31
+ fn parabola_gravity(): int
32
+ ```
33
+
34
+ **返回:** 800
35
+
36
+ ---
37
+
38
+ ## `parabola_gravity_half` <Badge type="info" text="v2.0.0" />
39
+
40
+ 每 tick 重力加速度的一半(用于位移公式)
41
+
42
+ ```redscript
43
+ fn parabola_gravity_half(): int
44
+ ```
45
+
46
+ **返回:** 400
47
+
48
+ ---
49
+
50
+ ## `parabola_vx` <Badge type="info" text="v2.0.0" />
51
+
52
+ 计算在 ticks 个 tick 内水平移动 dx 格所需的初始 X 速度(×10000)
53
+
54
+ ```redscript
55
+ fn parabola_vx(dx: int, ticks: int): int
56
+ ```
57
+
58
+ **参数**
59
+
60
+ | 参数 | 说明 |
61
+ |------|------|
62
+ | `dx` | X 方向位移(格) |
63
+ | `ticks` | 飞行时间(tick) |
64
+
65
+ **返回:** 初始 X 速度 ×10000;ticks ≤ 0 时返回 0
66
+
67
+ **示例**
68
+
69
+ ```redscript
70
+ let vx: int = parabola_vx(10, 20)
71
+ ```
72
+
73
+ ---
74
+
75
+ ## `parabola_vy` <Badge type="info" text="v2.0.0" />
76
+
77
+ 计算在 ticks 个 tick 内垂直移动 dy 格所需的初始 Y 速度(×10000)
78
+
79
+ ```redscript
80
+ fn parabola_vy(dy: int, ticks: int): int
81
+ ```
82
+
83
+ **参数**
84
+
85
+ | 参数 | 说明 |
86
+ |------|------|
87
+ | `dy` | 垂直位移(格,正值向上) |
88
+ | `ticks` | 飞行时间(tick) |
89
+
90
+ **返回:** 初始 Y 速度 ×10000;ticks ≤ 0 时返回 0
91
+
92
+ **示例**
93
+
94
+ ```redscript
95
+ let vy: int = parabola_vy(5, 20)
96
+ ```
97
+
98
+ ---
99
+
100
+ ## `parabola_vz` <Badge type="info" text="v2.0.0" />
101
+
102
+ 计算在 ticks 个 tick 内水平移动 dz 格所需的初始 Z 速度(×10000)
103
+
104
+ ```redscript
105
+ fn parabola_vz(dz: int, ticks: int): int
106
+ ```
107
+
108
+ **参数**
109
+
110
+ | 参数 | 说明 |
111
+ |------|------|
112
+ | `dz` | Z 方向位移(格) |
113
+ | `ticks` | 飞行时间(tick) |
114
+
115
+ **返回:** 初始 Z 速度 ×10000;ticks ≤ 0 时返回 0
116
+
117
+ ---
118
+
119
+ ## `parabola_speed_xz` <Badge type="info" text="v2.0.0" />
120
+
121
+ 计算到达 (dx, dz) 所需的水平速度大小(×10000)
122
+
123
+ ```redscript
124
+ fn parabola_speed_xz(dx: int, dz: int, ticks: int): int
125
+ ```
126
+
127
+ **参数**
128
+
129
+ | 参数 | 说明 |
130
+ |------|------|
131
+ | `dx` | X 位移(格) |
132
+ | `dz` | Z 位移(格) |
133
+ | `ticks` | 飞行时间(tick) |
134
+
135
+ **返回:** 水平发射速度 ×10000;ticks ≤ 0 时返回 0
136
+
137
+ ---
138
+
139
+ ## `parabola_x` <Badge type="info" text="v2.0.0" />
140
+
141
+ 在 t tick 时的 X 位置(格)
142
+
143
+ ```redscript
144
+ fn parabola_x(vx0: int, t: int): int
145
+ ```
146
+
147
+ **参数**
148
+
149
+ | 参数 | 说明 |
150
+ |------|------|
151
+ | `vx0` | 初始 X 速度 ×10000 |
152
+ | `t` | 已过 tick 数 |
153
+
154
+ **返回:** X 位移(格)
155
+
156
+ ---
157
+
158
+ ## `parabola_y` <Badge type="info" text="v2.0.0" />
159
+
160
+ 在 t tick 时的 Y 位置(格)
161
+
162
+ ```redscript
163
+ fn parabola_y(vy0: int, t: int): int
164
+ ```
165
+
166
+ **参数**
167
+
168
+ | 参数 | 说明 |
169
+ |------|------|
170
+ | `vy0` | 初始 Y 速度 ×10000 |
171
+ | `t` | 已过 tick 数 |
172
+
173
+ **返回:** Y 位移(格,正值向上)
174
+
175
+ ---
176
+
177
+ ## `parabola_z` <Badge type="info" text="v2.0.0" />
178
+
179
+ 在 t tick 时的 Z 位置(格)
180
+
181
+ ```redscript
182
+ fn parabola_z(vz0: int, t: int): int
183
+ ```
184
+
185
+ **参数**
186
+
187
+ | 参数 | 说明 |
188
+ |------|------|
189
+ | `vz0` | 初始 Z 速度 ×10000 |
190
+ | `t` | 已过 tick 数 |
191
+
192
+ **返回:** Z 位移(格)
193
+
194
+ ---
195
+
196
+ ## `parabola_flight_time` <Badge type="info" text="v2.0.0" />
197
+
198
+ 估算抛体返回发射高度时的 tick 数
199
+
200
+ ```redscript
201
+ fn parabola_flight_time(vy0: int): int
202
+ ```
203
+
204
+ **参数**
205
+
206
+ | 参数 | 说明 |
207
+ |------|------|
208
+ | `vy0` | 初始 Y 速度 ×10000 |
209
+
210
+ **返回:** 飞行时间(tick);vy0 ≤ 0 时返回 0
211
+
212
+ **示例**
213
+
214
+ ```redscript
215
+ let t: int = parabola_flight_time(8000)
216
+ ```
217
+
218
+ ---
219
+
220
+ ## `parabola_max_height` <Badge type="info" text="v2.0.0" />
221
+
222
+ 抛体高出发射点的最大高度(格)
223
+
224
+ ```redscript
225
+ fn parabola_max_height(vy0: int): int
226
+ ```
227
+
228
+ **参数**
229
+
230
+ | 参数 | 说明 |
231
+ |------|------|
232
+ | `vy0` | 初始 Y 速度 ×10000 |
233
+
234
+ **返回:** 顶点高度(格);vy0 ≤ 0 时返回 0
235
+
236
+ **示例**
237
+
238
+ ```redscript
239
+ let h: int = parabola_max_height(8000)
240
+ ```
241
+
242
+ ---
243
+
244
+ ## `parabola_step_vx` <Badge type="info" text="v2.0.0" />
245
+
246
+ 对 X 速度施加一 tick 阻力
247
+
248
+ ```redscript
249
+ fn parabola_step_vx(vx: int, drag: int): int
250
+ ```
251
+
252
+ **参数**
253
+
254
+ | 参数 | 说明 |
255
+ |------|------|
256
+ | `vx` | 当前 X 速度 ×10000 |
257
+ | `drag` | 阻力系数 ×10000(如 9900 = 0.99 箭矢) |
258
+
259
+ **返回:** 新 X 速度 ×10000
260
+
261
+ ---
262
+
263
+ ## `parabola_step_vy` <Badge type="info" text="v2.0.0" />
264
+
265
+ 对 Y 速度先施加重力再施加阻力(一 tick)
266
+
267
+ ```redscript
268
+ fn parabola_step_vy(vy: int, drag: int): int
269
+ ```
270
+
271
+ **参数**
272
+
273
+ | 参数 | 说明 |
274
+ |------|------|
275
+ | `vy` | 当前 Y 速度 ×10000 |
276
+ | `drag` | 阻力系数 ×10000 |
277
+
278
+ **返回:** 新 Y 速度 ×10000
279
+
280
+ ---
281
+
282
+ ## `parabola_step_vz` <Badge type="info" text="v2.0.0" />
283
+
284
+ 对 Z 速度施加一 tick 阻力
285
+
286
+ ```redscript
287
+ fn parabola_step_vz(vz: int, drag: int): int
288
+ ```
289
+
290
+ **参数**
291
+
292
+ | 参数 | 说明 |
293
+ |------|------|
294
+ | `vz` | 当前 Z 速度 ×10000 |
295
+ | `drag` | 阻力系数 ×10000 |
296
+
297
+ **返回:** 新 Z 速度 ×10000
298
+
299
+ ---
300
+
301
+ ## `parabola_ticks_for_range` <Badge type="info" text="v2.0.0" />
302
+
303
+ 根据水平距离估算飞行 tick 数(启发式,约 0.8 格/tick 水平速度)
304
+
305
+ ```redscript
306
+ fn parabola_ticks_for_range(range: int): int
307
+ ```
308
+
309
+ **参数**
310
+
311
+ | 参数 | 说明 |
312
+ |------|------|
313
+ | `range` | 水平距离(格) |
314
+
315
+ **返回:** 估算 tick 数(最小为 1)
316
+
317
+ ---
318
+
319
+ ## `parabola_in_range` <Badge type="info" text="v2.0.0" />
320
+
321
+ 检查目标是否在水平射程内
322
+
323
+ ```redscript
324
+ fn parabola_in_range(dx: int, dz: int, max_range: int): int
325
+ ```
326
+
327
+ **参数**
328
+
329
+ | 参数 | 说明 |
330
+ |------|------|
331
+ | `dx` | 到目标的 X 位移(格) |
332
+ | `dz` | 到目标的 Z 位移(格) |
333
+ | `max_range` | 最大射程(格) |
334
+
335
+ **返回:** dist(dx,dz) ≤ max_range 返回 1,否则返回 0
336
+
337
+ ---
@@ -0,0 +1,307 @@
1
+ # Particles
2
+
3
+ > 本文档由 `src/stdlib/particles.mcrs` 自动生成,请勿手动编辑。
4
+
5
+ ## API 列表
6
+
7
+ - [hearts_at](#hearts-at)
8
+ - [flames](#flames)
9
+ - [smoke](#smoke)
10
+ - [explosion_effect](#explosion-effect)
11
+ - [sparkles_at](#sparkles-at)
12
+ - [angry_at](#angry-at)
13
+ - [happy_at](#happy-at)
14
+ - [portal_effect](#portal-effect)
15
+ - [totem_at](#totem-at)
16
+ - [end_sparkles_at](#end-sparkles-at)
17
+ - [particle_at_fx](#particle-at-fx)
18
+ - [draw_line_2d](#draw-line-2d)
19
+ - [draw_circle](#draw-circle)
20
+ - [draw_helix](#draw-helix)
21
+ - [particle_dot](#particle-dot)
22
+
23
+ ---
24
+
25
+ ## `hearts_at`
26
+
27
+ 在指定坐标生成爱心粒子
28
+
29
+ ```redscript
30
+ fn hearts_at(x: int, y: int, z: int)
31
+ ```
32
+
33
+ **参数**
34
+
35
+ | 参数 | 说明 |
36
+ |------|------|
37
+ | `x` | X 坐标 |
38
+ | `y` | Y 坐标 |
39
+ | `z` | Z 坐标 |
40
+
41
+ ---
42
+
43
+ ## `flames`
44
+
45
+ 在指定坐标生成火焰粒子
46
+
47
+ ```redscript
48
+ fn flames(x: int, y: int, z: int)
49
+ ```
50
+
51
+ **参数**
52
+
53
+ | 参数 | 说明 |
54
+ |------|------|
55
+ | `x` | X 坐标 |
56
+ | `y` | Y 坐标 |
57
+ | `z` | Z 坐标 |
58
+
59
+ ---
60
+
61
+ ## `smoke`
62
+
63
+ 在指定坐标生成大烟雾粒子
64
+
65
+ ```redscript
66
+ fn smoke(x: int, y: int, z: int)
67
+ ```
68
+
69
+ **参数**
70
+
71
+ | 参数 | 说明 |
72
+ |------|------|
73
+ | `x` | X 坐标 |
74
+ | `y` | Y 坐标 |
75
+ | `z` | Z 坐标 |
76
+
77
+ ---
78
+
79
+ ## `explosion_effect`
80
+
81
+ 在指定坐标生成爆炸粒子
82
+
83
+ ```redscript
84
+ fn explosion_effect(x: int, y: int, z: int)
85
+ ```
86
+
87
+ **参数**
88
+
89
+ | 参数 | 说明 |
90
+ |------|------|
91
+ | `x` | X 坐标 |
92
+ | `y` | Y 坐标 |
93
+ | `z` | Z 坐标 |
94
+
95
+ ---
96
+
97
+ ## `sparkles_at`
98
+
99
+ 在指定坐标生成附魔闪烁粒子
100
+
101
+ ```redscript
102
+ fn sparkles_at(x: int, y: int, z: int)
103
+ ```
104
+
105
+ **参数**
106
+
107
+ | 参数 | 说明 |
108
+ |------|------|
109
+ | `x` | X 坐标 |
110
+ | `y` | Y 坐标 |
111
+ | `z` | Z 坐标 |
112
+
113
+ ---
114
+
115
+ ## `angry_at`
116
+
117
+ 在指定坐标生成愤怒村民粒子
118
+
119
+ ```redscript
120
+ fn angry_at(x: int, y: int, z: int)
121
+ ```
122
+
123
+ **参数**
124
+
125
+ | 参数 | 说明 |
126
+ |------|------|
127
+ | `x` | X 坐标 |
128
+ | `y` | Y 坐标 |
129
+ | `z` | Z 坐标 |
130
+
131
+ ---
132
+
133
+ ## `happy_at`
134
+
135
+ 在指定坐标生成开心村民粒子
136
+
137
+ ```redscript
138
+ fn happy_at(x: int, y: int, z: int)
139
+ ```
140
+
141
+ **参数**
142
+
143
+ | 参数 | 说明 |
144
+ |------|------|
145
+ | `x` | X 坐标 |
146
+ | `y` | Y 坐标 |
147
+ | `z` | Z 坐标 |
148
+
149
+ ---
150
+
151
+ ## `portal_effect`
152
+
153
+ 在指定坐标生成传送门粒子
154
+
155
+ ```redscript
156
+ fn portal_effect(x: int, y: int, z: int)
157
+ ```
158
+
159
+ **参数**
160
+
161
+ | 参数 | 说明 |
162
+ |------|------|
163
+ | `x` | X 坐标 |
164
+ | `y` | Y 坐标 |
165
+ | `z` | Z 坐标 |
166
+
167
+ ---
168
+
169
+ ## `totem_at`
170
+
171
+ 在指定坐标生成不死图腾粒子
172
+
173
+ ```redscript
174
+ fn totem_at(x: int, y: int, z: int)
175
+ ```
176
+
177
+ **参数**
178
+
179
+ | 参数 | 说明 |
180
+ |------|------|
181
+ | `x` | X 坐标 |
182
+ | `y` | Y 坐标 |
183
+ | `z` | Z 坐标 |
184
+
185
+ ---
186
+
187
+ ## `end_sparkles_at`
188
+
189
+ 在指定坐标生成末地烛粒子
190
+
191
+ ```redscript
192
+ fn end_sparkles_at(x: int, y: int, z: int)
193
+ ```
194
+
195
+ **参数**
196
+
197
+ | 参数 | 说明 |
198
+ |------|------|
199
+ | `x` | X 坐标 |
200
+ | `y` | Y 坐标 |
201
+ | `z` | Z 坐标 |
202
+
203
+ ---
204
+
205
+ ## `particle_at_fx`
206
+
207
+ 在以方块 ×100 表示的定点坐标上生成粒子
208
+
209
+ ```redscript
210
+ fn particle_at_fx(x_fx: int, y_fx: int, z_fx: int, particle: string)
211
+ ```
212
+
213
+ **参数**
214
+
215
+ | 参数 | 说明 |
216
+ |------|------|
217
+ | `x_fx` | X 坐标(方块 ×100) |
218
+ | `y_fx` | Y 坐标(方块 ×100) |
219
+ | `z_fx` | Z 坐标(方块 ×100) |
220
+ | `particle` | 粒子 ID,如 `minecraft:flame` |
221
+
222
+ ---
223
+
224
+ ## `draw_line_2d`
225
+
226
+ 使用线性插值绘制二维粒子直线
227
+
228
+ ```redscript
229
+ fn draw_line_2d(x0: int, y0: int, x1: int, y1: int, steps: int, z: int, particle: string)
230
+ ```
231
+
232
+ **参数**
233
+
234
+ | 参数 | 说明 |
235
+ |------|------|
236
+ | `x0` | 起点 X(方块 ×100) |
237
+ | `y0` | 起点 Y(方块 ×100) |
238
+ | `x1` | 终点 X(方块 ×100) |
239
+ | `y1` | 终点 Y(方块 ×100) |
240
+ | `steps` | 插值步数 |
241
+ | `z` | 所在 Z 平面(方块 ×100) |
242
+ | `particle` | 粒子 ID |
243
+
244
+ ---
245
+
246
+ ## `draw_circle`
247
+
248
+ 在 XZ 平面绘制粒子圆环
249
+
250
+ ```redscript
251
+ fn draw_circle(cx: int, cy: int, cz: int, r: int, steps: int, particle: string)
252
+ ```
253
+
254
+ **参数**
255
+
256
+ | 参数 | 说明 |
257
+ |------|------|
258
+ | `cx` | 圆心 X(方块) |
259
+ | `cy` | 圆心 Y(方块) |
260
+ | `cz` | 圆心 Z(方块) |
261
+ | `r` | 半径(方块 ×100) |
262
+ | `steps` | 采样点数量 |
263
+ | `particle` | 粒子 ID |
264
+
265
+ ---
266
+
267
+ ## `draw_helix`
268
+
269
+ 绘制可配置半径、高度和圈数的粒子螺旋
270
+
271
+ ```redscript
272
+ fn draw_helix(cx: int, cy_start: int, cz: int, r: int, height: int, rotations: int, steps: int, particle: string)
273
+ ```
274
+
275
+ **参数**
276
+
277
+ | 参数 | 说明 |
278
+ |------|------|
279
+ | `cx` | 中心 X(方块) |
280
+ | `cy_start` | 起始 Y(方块) |
281
+ | `cz` | 中心 Z(方块) |
282
+ | `r` | 半径(方块 ×100) |
283
+ | `height` | 总高度(方块) |
284
+ | `rotations` | 完整旋转圈数 |
285
+ | `steps` | 采样点数量 |
286
+ | `particle` | 粒子 ID |
287
+
288
+ ---
289
+
290
+ ## `particle_dot`
291
+
292
+ 在整数方块坐标生成单个粒子
293
+
294
+ ```redscript
295
+ fn particle_dot(x: int, y: int, z: int, particle: string)
296
+ ```
297
+
298
+ **参数**
299
+
300
+ | 参数 | 说明 |
301
+ |------|------|
302
+ | `x` | X 坐标(整数方块) |
303
+ | `y` | Y 坐标(整数方块) |
304
+ | `z` | Z 坐标(整数方块) |
305
+ | `particle` | 粒子 ID |
306
+
307
+ ---