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,403 @@
1
+ # Matrix
2
+
3
+ > Auto-generated from `src/stdlib/matrix.mcrs` — do not edit manually.
4
+
5
+ ## API
6
+
7
+ - [rotate2d_x](#rotate2d-x)
8
+ - [rotate2d_y](#rotate2d-y)
9
+ - [scale_x](#scale-x)
10
+ - [scale_y](#scale-y)
11
+ - [scale_z](#scale-z)
12
+ - [uniform_scale](#uniform-scale)
13
+ - [rotate_y_x](#rotate-y-x)
14
+ - [rotate_y_z](#rotate-y-z)
15
+ - [rotate_x_y](#rotate-x-y)
16
+ - [rotate_x_z](#rotate-x-z)
17
+ - [quat_sin_half](#quat-sin-half)
18
+ - [quat_cos_half](#quat-cos-half)
19
+ - [billboard_y](#billboard-y)
20
+ - [lerp_angle](#lerp-angle)
21
+ - [mat3_mul_elem](#mat3-mul-elem)
22
+ - [mat3_mul_vec3_elem](#mat3-mul-vec3-elem)
23
+ - [mat4_mul_elem](#mat4-mul-elem)
24
+ - [mat4_mul_vec4_elem](#mat4-mul-vec4-elem)
25
+
26
+ ---
27
+
28
+ ## `rotate2d_x` <Badge type="info" text="v2.0.0" />
29
+
30
+ X component after 2D rotation of `(x, y)` by `angle_deg` (×10000).
31
+
32
+ ```redscript
33
+ fn rotate2d_x(x: int, y: int, angle_deg: int): int
34
+ ```
35
+
36
+ **Parameters**
37
+
38
+ | Parameter | Description |
39
+ |-----------|-------------|
40
+ | `x` | Input X coordinate ×10000 |
41
+ | `y` | Input Y coordinate ×10000 |
42
+ | `angle_deg` | Angle in degrees ×10000 (e.g. `450000` = 45°) |
43
+
44
+ **Returns:** `x*cos(angle) - y*sin(angle)` in ×10000
45
+
46
+ **Example**
47
+
48
+ ```redscript
49
+ let rx: int = rotate2d_x(10000, 0, 900000)
50
+ ```
51
+
52
+ ---
53
+
54
+ ## `rotate2d_y` <Badge type="info" text="v2.0.0" />
55
+
56
+ Y component after 2D rotation of `(x, y)` by `angle_deg` (×10000).
57
+
58
+ ```redscript
59
+ fn rotate2d_y(x: int, y: int, angle_deg: int): int
60
+ ```
61
+
62
+ **Parameters**
63
+
64
+ | Parameter | Description |
65
+ |-----------|-------------|
66
+ | `x` | Input X coordinate ×10000 |
67
+ | `y` | Input Y coordinate ×10000 |
68
+ | `angle_deg` | Angle in degrees ×10000 |
69
+
70
+ **Returns:** `x*sin(angle) + y*cos(angle)` in ×10000
71
+
72
+ ---
73
+
74
+ ## `scale_x` <Badge type="info" text="v2.0.0" />
75
+
76
+ Scale X coordinate by `sx_fx` (×10000).
77
+
78
+ ```redscript
79
+ fn scale_x(x: int, sx_fx: int): int
80
+ ```
81
+
82
+ **Parameters**
83
+
84
+ | Parameter | Description |
85
+ |-----------|-------------|
86
+ | `x` | Input X value ×10000 |
87
+ | `sx_fx` | Scale factor ×10000 (e.g. `20000` = 2×) |
88
+
89
+ **Returns:** `x * sx_fx / 10000`
90
+
91
+ ---
92
+
93
+ ## `scale_y` <Badge type="info" text="v2.0.0" />
94
+
95
+ Scale Y coordinate by `sy_fx` (×10000).
96
+
97
+ ```redscript
98
+ fn scale_y(y: int, sy_fx: int): int
99
+ ```
100
+
101
+ **Parameters**
102
+
103
+ | Parameter | Description |
104
+ |-----------|-------------|
105
+ | `y` | Input Y value ×10000 |
106
+ | `sy_fx` | Scale factor ×10000 |
107
+
108
+ **Returns:** `y * sy_fx / 10000`
109
+
110
+ ---
111
+
112
+ ## `scale_z` <Badge type="info" text="v2.0.0" />
113
+
114
+ Scale Z coordinate by `sz_fx` (×10000).
115
+
116
+ ```redscript
117
+ fn scale_z(z: int, sz_fx: int): int
118
+ ```
119
+
120
+ **Parameters**
121
+
122
+ | Parameter | Description |
123
+ |-----------|-------------|
124
+ | `z` | Input Z value ×10000 |
125
+ | `sz_fx` | Scale factor ×10000 |
126
+
127
+ **Returns:** `z * sz_fx / 10000`
128
+
129
+ ---
130
+
131
+ ## `uniform_scale` <Badge type="info" text="v2.0.0" />
132
+
133
+ Apply a uniform scale factor to a single component.
134
+
135
+ ```redscript
136
+ fn uniform_scale(v: int, s_fx: int): int
137
+ ```
138
+
139
+ **Parameters**
140
+
141
+ | Parameter | Description |
142
+ |-----------|-------------|
143
+ | `v` | Input component value ×10000 |
144
+ | `s_fx` | Uniform scale factor ×10000 |
145
+
146
+ **Returns:** `v * s_fx / 10000`
147
+
148
+ ---
149
+
150
+ ## `rotate_y_x` <Badge type="info" text="v2.0.0" />
151
+
152
+ X component after rotation around the Y axis by `angle_deg` (×10000).
153
+
154
+ ```redscript
155
+ fn rotate_y_x(x: int, z: int, angle_deg: int): int
156
+ ```
157
+
158
+ **Parameters**
159
+
160
+ | Parameter | Description |
161
+ |-----------|-------------|
162
+ | `x` | Input X coordinate ×10000 |
163
+ | `z` | Input Z coordinate ×10000 |
164
+ | `angle_deg` | Angle in degrees ×10000 |
165
+
166
+ **Returns:** `x*cos(angle) + z*sin(angle)` in ×10000
167
+
168
+ ---
169
+
170
+ ## `rotate_y_z` <Badge type="info" text="v2.0.0" />
171
+
172
+ Z component after rotation around the Y axis by `angle_deg` (×10000).
173
+
174
+ ```redscript
175
+ fn rotate_y_z(x: int, z: int, angle_deg: int): int
176
+ ```
177
+
178
+ **Parameters**
179
+
180
+ | Parameter | Description |
181
+ |-----------|-------------|
182
+ | `x` | Input X coordinate ×10000 |
183
+ | `z` | Input Z coordinate ×10000 |
184
+ | `angle_deg` | Angle in degrees ×10000 |
185
+
186
+ **Returns:** `-x*sin(angle) + z*cos(angle)` in ×10000
187
+
188
+ ---
189
+
190
+ ## `rotate_x_y` <Badge type="info" text="v2.0.0" />
191
+
192
+ Y component after rotation around the X axis by `angle_deg` (×10000).
193
+
194
+ ```redscript
195
+ fn rotate_x_y(y: int, z: int, angle_deg: int): int
196
+ ```
197
+
198
+ **Parameters**
199
+
200
+ | Parameter | Description |
201
+ |-----------|-------------|
202
+ | `y` | Input Y coordinate ×10000 |
203
+ | `z` | Input Z coordinate ×10000 |
204
+ | `angle_deg` | Angle in degrees ×10000 |
205
+
206
+ **Returns:** `y*cos(angle) - z*sin(angle)` in ×10000
207
+
208
+ ---
209
+
210
+ ## `rotate_x_z` <Badge type="info" text="v2.0.0" />
211
+
212
+ Z component after rotation around the X axis by `angle_deg` (×10000).
213
+
214
+ ```redscript
215
+ fn rotate_x_z(y: int, z: int, angle_deg: int): int
216
+ ```
217
+
218
+ **Parameters**
219
+
220
+ | Parameter | Description |
221
+ |-----------|-------------|
222
+ | `y` | Input Y coordinate ×10000 |
223
+ | `z` | Input Z coordinate ×10000 |
224
+ | `angle_deg` | Angle in degrees ×10000 |
225
+
226
+ **Returns:** `y*sin(angle) + z*cos(angle)` in ×10000
227
+
228
+ ---
229
+
230
+ ## `quat_sin_half` <Badge type="info" text="v2.0.0" />
231
+
232
+ sin(angle/2) in ×1000 for a Display Entity Y-axis quaternion.
233
+
234
+ ```redscript
235
+ fn quat_sin_half(angle_deg_fx: int): int
236
+ ```
237
+
238
+ **Parameters**
239
+
240
+ | Parameter | Description |
241
+ |-----------|-------------|
242
+ | `angle_deg_fx` | Full rotation angle in degrees ×10000 |
243
+
244
+ **Returns:** `sin(angle/2)` in ×1000
245
+
246
+ ---
247
+
248
+ ## `quat_cos_half` <Badge type="info" text="v2.0.0" />
249
+
250
+ cos(angle/2) in ×1000 for a Display Entity Y-axis quaternion.
251
+
252
+ ```redscript
253
+ fn quat_cos_half(angle_deg_fx: int): int
254
+ ```
255
+
256
+ **Parameters**
257
+
258
+ | Parameter | Description |
259
+ |-----------|-------------|
260
+ | `angle_deg_fx` | Full rotation angle in degrees ×10000 |
261
+
262
+ **Returns:** `cos(angle/2)` in ×1000
263
+
264
+ ---
265
+
266
+ ## `billboard_y` <Badge type="info" text="v2.0.0" />
267
+
268
+ Compute the Y rotation for a billboard that faces the player.
269
+
270
+ ```redscript
271
+ fn billboard_y(player_yaw_fx: int): int
272
+ ```
273
+
274
+ **Parameters**
275
+
276
+ | Parameter | Description |
277
+ |-----------|-------------|
278
+ | `player_yaw_fx` | Player yaw angle ×10000 (from entity NBT `Rotation[0]`) |
279
+
280
+ **Returns:** Billboard Y rotation ×10000 (opposite of player yaw, in [0, 3600000))
281
+
282
+ **Example**
283
+
284
+ ```redscript
285
+ let by: int = billboard_y(player_yaw)
286
+ ```
287
+
288
+ ---
289
+
290
+ ## `lerp_angle` <Badge type="info" text="v2.0.0" />
291
+
292
+ Interpolate between two angles (×10000) taking the shortest arc.
293
+
294
+ Normalises the angular difference to [−1800000, 1800000] before interpolating.
295
+
296
+ ```redscript
297
+ fn lerp_angle(a_fx: int, b_fx: int, t: int): int
298
+ ```
299
+
300
+ **Parameters**
301
+
302
+ | Parameter | Description |
303
+ |-----------|-------------|
304
+ | `a_fx` | Start angle ×10000 |
305
+ | `b_fx` | End angle ×10000 |
306
+ | `t` | Interpolation factor ×10000 (0 = a, 10000 = b) |
307
+
308
+ **Returns:** Interpolated angle ×10000
309
+
310
+ **Example**
311
+
312
+ ```redscript
313
+ let a: int = lerp_angle(0, 3600000, 5000)
314
+ ```
315
+
316
+ ---
317
+
318
+ ## `mat3_mul_elem` <Badge type="info" text="v2.0.0" />
319
+
320
+ Compute element `C[row][col]` of the 3×3 matrix product `A × B`.
321
+
322
+ All matrix values are ×10000 fixed-point. Pass all 18 components of A and B
323
+ individually. `row` and `col` are each in {0, 1, 2}.
324
+
325
+ ```redscript
326
+ fn mat3_mul_elem( a00: int, a01: int, a02: int, a10: int, a11: int, a12: int, a20: int, a21: int, a22: int, b00: int, b01: int, b02: int, b10: int, b11: int, b12: int,
327
+ ```
328
+
329
+ **Parameters**
330
+
331
+ | Parameter | Description |
332
+ |-----------|-------------|
333
+ | `a00` | A[0,0] … a22 A[2,2] (9 elements, row-major) |
334
+ | `b00` | B[0,0] … b22 B[2,2] (9 elements, row-major) |
335
+ | `row` | Target row index (0–2) |
336
+ | `col` | Target column index (0–2) |
337
+
338
+ **Returns:** `C[row][col]` in ×10000
339
+
340
+ ---
341
+
342
+ ## `mat3_mul_vec3_elem` <Badge type="info" text="v2.0.0" />
343
+
344
+ Compute one component of the 3×3 matrix–vector product `A × v`.
345
+
346
+ ```redscript
347
+ fn mat3_mul_vec3_elem( a00: int, a01: int, a02: int, a10: int, a11: int, a12: int, a20: int, a21: int, a22: int, vx: int, vy: int, vz: int, comp: int
348
+ ```
349
+
350
+ **Parameters**
351
+
352
+ | Parameter | Description |
353
+ |-----------|-------------|
354
+ | `a00` | A[0,0] … a22 A[2,2] (9 elements, row-major, ×10000) |
355
+ | `vx` | Vector X ×10000 @param vy Vector Y ×10000 @param vz Vector Z ×10000 |
356
+ | `comp` | Output component index (0=x, 1=y, 2=z) |
357
+
358
+ **Returns:** `(A × v)[comp]` in ×10000
359
+
360
+ ---
361
+
362
+ ## `mat4_mul_elem` <Badge type="info" text="v2.0.0" />
363
+
364
+ Compute element `C[row][col]` of the 4×4 matrix product `A × B`.
365
+
366
+ Row-major layout, all values ×10000. `row` and `col` are each in {0, 1, 2, 3}.
367
+
368
+ ```redscript
369
+ fn mat4_mul_elem( a00: int, a01: int, a02: int, a03: int, a10: int, a11: int, a12: int, a13: int, a20: int, a21: int, a22: int, a23: int, a30: int, a31: int, a32: int, a33: int, b00: int, b01: int, b02: int, b03: int,
370
+ ```
371
+
372
+ **Parameters**
373
+
374
+ | Parameter | Description |
375
+ |-----------|-------------|
376
+ | `a00` | A[0,0] … a33 A[3,3] (16 elements, row-major, ×10000) |
377
+ | `b00` | B[0,0] … b33 B[3,3] (16 elements, row-major, ×10000) |
378
+ | `row` | Target row index (0–3) |
379
+ | `col` | Target column index (0–3) |
380
+
381
+ **Returns:** `C[row][col]` in ×10000
382
+
383
+ ---
384
+
385
+ ## `mat4_mul_vec4_elem` <Badge type="info" text="v2.0.0" />
386
+
387
+ Compute one component of the 4×4 matrix–homogeneous-vector product `A × v`.
388
+
389
+ ```redscript
390
+ fn mat4_mul_vec4_elem( a00: int, a01: int, a02: int, a03: int, a10: int, a11: int, a12: int, a13: int, a20: int, a21: int, a22: int, a23: int, a30: int, a31: int, a32: int, a33: int, vx: int, vy: int, vz: int, vw: int,
391
+ ```
392
+
393
+ **Parameters**
394
+
395
+ | Parameter | Description |
396
+ |-----------|-------------|
397
+ | `a00` | A[0,0] … a33 A[3,3] (16 elements, row-major, ×10000) |
398
+ | `vx` | Vector X ×10000 @param vy Y @param vz Z @param vw W |
399
+ | `comp` | Output component index (0=x, 1=y, 2=z, 3=w) |
400
+
401
+ **Returns:** `(A × v)[comp]` in ×10000
402
+
403
+ ---