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.
- package/.github/workflows/ci.yml +1 -0
- package/README.md +119 -313
- package/README.zh.md +118 -314
- package/ROADMAP.md +5 -5
- package/dist/data/impl_test/function/counter/get.mcfunction +5 -0
- package/dist/data/impl_test/function/counter/inc.mcfunction +7 -0
- package/dist/data/impl_test/function/counter/new.mcfunction +4 -0
- package/dist/data/impl_test/function/load.mcfunction +1 -0
- package/dist/data/impl_test/function/test_impl.mcfunction +10 -0
- package/dist/data/minecraft/tags/function/load.json +5 -0
- package/dist/data/playground/function/load.mcfunction +1 -0
- package/dist/data/playground/function/start.mcfunction +4 -0
- package/dist/data/playground/function/start__say_macro_t1.mcfunction +1 -0
- package/dist/data/playground/function/stop.mcfunction +5 -0
- package/dist/data/playground/function/stop__say_macro_t0.mcfunction +1 -0
- package/dist/data/stdlib_queue8_test/function/__queue_append_apply.mcfunction +4 -0
- package/dist/data/stdlib_queue8_test/function/__queue_peek_apply.mcfunction +4 -0
- package/dist/data/stdlib_queue8_test/function/__queue_size_raw_apply.mcfunction +4 -0
- package/dist/data/stdlib_queue8_test/function/load.mcfunction +1 -0
- package/dist/data/stdlib_queue8_test/function/queue_clear.mcfunction +6 -0
- package/dist/data/stdlib_queue8_test/function/queue_empty__merge_1.mcfunction +5 -0
- package/dist/data/stdlib_queue8_test/function/queue_empty__then_0.mcfunction +5 -0
- package/dist/data/stdlib_queue8_test/function/queue_peek__merge_1.mcfunction +13 -0
- package/dist/data/stdlib_queue8_test/function/queue_peek__then_0.mcfunction +5 -0
- package/dist/data/stdlib_queue8_test/function/queue_pop__merge_1.mcfunction +15 -0
- package/dist/data/stdlib_queue8_test/function/queue_pop__then_0.mcfunction +5 -0
- package/dist/data/stdlib_queue8_test/function/queue_push__const_11.mcfunction +6 -0
- package/dist/data/stdlib_queue8_test/function/queue_push__const_22.mcfunction +6 -0
- package/dist/data/stdlib_queue8_test/function/queue_size.mcfunction +13 -0
- package/dist/data/stdlib_queue8_test/function/test_queue_push_and_size.mcfunction +13 -0
- package/dist/data/test/function/load.mcfunction +1 -0
- package/dist/data/test/function/say_at.mcfunction +6 -0
- package/dist/data/test/function/test.mcfunction +4 -0
- package/dist/pack.mcmeta +6 -0
- package/dist/package.json +1 -1
- package/dist/src/__tests__/formatter-extra.test.d.ts +7 -0
- package/dist/src/__tests__/formatter-extra.test.js +123 -0
- package/dist/src/__tests__/global-vars.test.d.ts +13 -0
- package/dist/src/__tests__/global-vars.test.js +156 -0
- package/dist/src/__tests__/lint/new-rules.test.d.ts +9 -0
- package/dist/src/__tests__/lint/new-rules.test.js +402 -0
- package/dist/src/__tests__/lsp-rename.test.d.ts +8 -0
- package/dist/src/__tests__/lsp-rename.test.js +157 -0
- package/dist/src/__tests__/mc-integration/say-fstring.test.d.ts +11 -0
- package/dist/src/__tests__/mc-integration/say-fstring.test.js +220 -0
- package/dist/src/__tests__/mc-integration/stdlib-coverage-2.test.js +1 -1
- package/dist/src/__tests__/mc-integration/stdlib-coverage-3.test.js +1 -1
- package/dist/src/__tests__/mc-integration/stdlib-coverage-4.test.js +1 -1
- package/dist/src/__tests__/mc-integration/stdlib-coverage-5.test.js +1 -1
- package/dist/src/__tests__/mc-integration/stdlib-coverage-6.test.js +1 -1
- package/dist/src/__tests__/mc-integration/stdlib-coverage-7.test.js +1 -1
- package/dist/src/__tests__/mc-integration/stdlib-coverage-8.test.js +1 -1
- package/dist/src/__tests__/mc-syntax.test.js +4 -1
- package/dist/src/__tests__/monomorphize-coverage.test.d.ts +9 -0
- package/dist/src/__tests__/monomorphize-coverage.test.js +204 -0
- package/dist/src/__tests__/optimizer-cse.test.d.ts +7 -0
- package/dist/src/__tests__/optimizer-cse.test.js +226 -0
- package/dist/src/__tests__/parser.test.js +4 -13
- package/dist/src/__tests__/repl-server-extra.test.js +6 -7
- package/dist/src/__tests__/repl-server.test.js +5 -7
- package/dist/src/__tests__/stdlib/queue.test.js +6 -6
- package/dist/src/cli.js +0 -0
- package/dist/src/lexer/index.js +2 -1
- package/dist/src/lint/index.d.ts +12 -5
- package/dist/src/lint/index.js +730 -5
- package/dist/src/lsp/main.js +0 -0
- package/dist/src/mc-test/client.d.ts +21 -0
- package/dist/src/mc-test/client.js +34 -0
- package/dist/src/mir/lower.js +108 -6
- package/dist/src/optimizer/interprocedural.js +37 -2
- package/dist/src/parser/decl-parser.d.ts +19 -0
- package/dist/src/parser/decl-parser.js +323 -0
- package/dist/src/parser/expr-parser.d.ts +46 -0
- package/dist/src/parser/expr-parser.js +759 -0
- package/dist/src/parser/index.d.ts +8 -129
- package/dist/src/parser/index.js +13 -2262
- package/dist/src/parser/stmt-parser.d.ts +28 -0
- package/dist/src/parser/stmt-parser.js +577 -0
- package/dist/src/parser/type-parser.d.ts +20 -0
- package/dist/src/parser/type-parser.js +257 -0
- package/dist/src/parser/utils.d.ts +34 -0
- package/dist/src/parser/utils.js +141 -0
- package/docs/dev/README-mc-integration-tests.md +141 -0
- package/docs/lint-rules.md +162 -0
- package/docs/stdlib/bigint.md +2 -0
- package/editors/vscode/README.md +63 -41
- package/editors/vscode/out/extension.js +1881 -1776
- package/editors/vscode/out/lsp-server.js +4257 -3651
- package/editors/vscode/package-lock.json +3 -3
- package/editors/vscode/package.json +1 -1
- package/examples/loops-demo.mcrs +87 -0
- package/package.json +1 -1
- package/redscript-docs/docs/en/stdlib/advanced.md +629 -0
- package/redscript-docs/docs/en/stdlib/bigint.md +316 -0
- package/redscript-docs/docs/en/stdlib/bits.md +292 -0
- package/redscript-docs/docs/en/stdlib/bossbar.md +177 -0
- package/redscript-docs/docs/en/stdlib/calculus.md +289 -0
- package/redscript-docs/docs/en/stdlib/color.md +353 -0
- package/redscript-docs/docs/en/stdlib/combat.md +88 -0
- package/redscript-docs/docs/en/stdlib/cooldown.md +82 -0
- package/redscript-docs/docs/en/stdlib/dialog.md +155 -0
- package/redscript-docs/docs/en/stdlib/easing.md +558 -0
- package/redscript-docs/docs/en/stdlib/ecs.md +475 -0
- package/redscript-docs/docs/en/stdlib/effects.md +324 -0
- package/redscript-docs/docs/en/stdlib/events.md +3 -0
- package/redscript-docs/docs/en/stdlib/expr.md +45 -0
- package/redscript-docs/docs/en/stdlib/fft.md +141 -0
- package/redscript-docs/docs/en/stdlib/geometry.md +430 -0
- package/redscript-docs/docs/en/stdlib/graph.md +259 -0
- package/redscript-docs/docs/en/stdlib/heap.md +185 -0
- package/redscript-docs/docs/en/stdlib/interactions.md +179 -0
- package/redscript-docs/docs/en/stdlib/inventory.md +97 -0
- package/redscript-docs/docs/en/stdlib/linalg.md +557 -0
- package/redscript-docs/docs/en/stdlib/list.md +559 -0
- package/redscript-docs/docs/en/stdlib/map.md +140 -0
- package/redscript-docs/docs/en/stdlib/math.md +193 -0
- package/redscript-docs/docs/en/stdlib/math_hp.md +149 -0
- package/redscript-docs/docs/en/stdlib/matrix.md +403 -0
- package/redscript-docs/docs/en/stdlib/mobs.md +965 -0
- package/redscript-docs/docs/en/stdlib/noise.md +244 -0
- package/redscript-docs/docs/en/stdlib/ode.md +253 -0
- package/redscript-docs/docs/en/stdlib/parabola.md +342 -0
- package/redscript-docs/docs/en/stdlib/particles.md +311 -0
- package/redscript-docs/docs/en/stdlib/pathfind.md +255 -0
- package/redscript-docs/docs/en/stdlib/physics.md +493 -0
- package/redscript-docs/docs/en/stdlib/player.md +78 -0
- package/redscript-docs/docs/en/stdlib/quaternion.md +673 -0
- package/redscript-docs/docs/en/stdlib/queue.md +134 -0
- package/redscript-docs/docs/en/stdlib/random.md +223 -0
- package/redscript-docs/docs/en/stdlib/result.md +143 -0
- package/redscript-docs/docs/en/stdlib/scheduler.md +183 -0
- package/redscript-docs/docs/en/stdlib/set_int.md +190 -0
- package/redscript-docs/docs/en/stdlib/sets.md +101 -0
- package/redscript-docs/docs/en/stdlib/signal.md +400 -0
- package/redscript-docs/docs/en/stdlib/sort.md +104 -0
- package/redscript-docs/docs/en/stdlib/spawn.md +147 -0
- package/redscript-docs/docs/en/stdlib/state.md +142 -0
- package/redscript-docs/docs/en/stdlib/strings.md +154 -0
- package/redscript-docs/docs/en/stdlib/tags.md +3451 -0
- package/redscript-docs/docs/en/stdlib/teams.md +153 -0
- package/redscript-docs/docs/en/stdlib/timer.md +246 -0
- package/redscript-docs/docs/en/stdlib/vec.md +158 -0
- package/redscript-docs/docs/en/stdlib/world.md +298 -0
- package/redscript-docs/docs/zh/stdlib/advanced.md +615 -0
- package/redscript-docs/docs/zh/stdlib/bigint.md +316 -0
- package/redscript-docs/docs/zh/stdlib/bits.md +292 -0
- package/redscript-docs/docs/zh/stdlib/bossbar.md +170 -0
- package/redscript-docs/docs/zh/stdlib/calculus.md +287 -0
- package/redscript-docs/docs/zh/stdlib/color.md +353 -0
- package/redscript-docs/docs/zh/stdlib/combat.md +88 -0
- package/redscript-docs/docs/zh/stdlib/cooldown.md +84 -0
- package/redscript-docs/docs/zh/stdlib/dialog.md +152 -0
- package/redscript-docs/docs/zh/stdlib/easing.md +558 -0
- package/redscript-docs/docs/zh/stdlib/ecs.md +472 -0
- package/redscript-docs/docs/zh/stdlib/effects.md +324 -0
- package/redscript-docs/docs/zh/stdlib/events.md +3 -0
- package/redscript-docs/docs/zh/stdlib/expr.md +37 -0
- package/redscript-docs/docs/zh/stdlib/fft.md +128 -0
- package/redscript-docs/docs/zh/stdlib/geometry.md +430 -0
- package/redscript-docs/docs/zh/stdlib/graph.md +259 -0
- package/redscript-docs/docs/zh/stdlib/heap.md +185 -0
- package/redscript-docs/docs/zh/stdlib/interactions.md +160 -0
- package/redscript-docs/docs/zh/stdlib/inventory.md +94 -0
- package/redscript-docs/docs/zh/stdlib/linalg.md +543 -0
- package/redscript-docs/docs/zh/stdlib/list.md +561 -0
- package/redscript-docs/docs/zh/stdlib/map.md +132 -0
- package/redscript-docs/docs/zh/stdlib/math.md +193 -0
- package/redscript-docs/docs/zh/stdlib/math_hp.md +143 -0
- package/redscript-docs/docs/zh/stdlib/matrix.md +396 -0
- package/redscript-docs/docs/zh/stdlib/mobs.md +965 -0
- package/redscript-docs/docs/zh/stdlib/noise.md +244 -0
- package/redscript-docs/docs/zh/stdlib/ode.md +243 -0
- package/redscript-docs/docs/zh/stdlib/parabola.md +337 -0
- package/redscript-docs/docs/zh/stdlib/particles.md +307 -0
- package/redscript-docs/docs/zh/stdlib/pathfind.md +255 -0
- package/redscript-docs/docs/zh/stdlib/physics.md +493 -0
- package/redscript-docs/docs/zh/stdlib/player.md +78 -0
- package/redscript-docs/docs/zh/stdlib/quaternion.md +669 -0
- package/redscript-docs/docs/zh/stdlib/queue.md +124 -0
- package/redscript-docs/docs/zh/stdlib/random.md +222 -0
- package/redscript-docs/docs/zh/stdlib/result.md +147 -0
- package/redscript-docs/docs/zh/stdlib/scheduler.md +173 -0
- package/redscript-docs/docs/zh/stdlib/set_int.md +180 -0
- package/redscript-docs/docs/zh/stdlib/sets.md +107 -0
- package/redscript-docs/docs/zh/stdlib/signal.md +373 -0
- package/redscript-docs/docs/zh/stdlib/sort.md +104 -0
- package/redscript-docs/docs/zh/stdlib/spawn.md +142 -0
- package/redscript-docs/docs/zh/stdlib/state.md +134 -0
- package/redscript-docs/docs/zh/stdlib/strings.md +107 -0
- package/redscript-docs/docs/zh/stdlib/tags.md +3451 -0
- package/redscript-docs/docs/zh/stdlib/teams.md +150 -0
- package/redscript-docs/docs/zh/stdlib/timer.md +254 -0
- package/redscript-docs/docs/zh/stdlib/vec.md +158 -0
- package/redscript-docs/docs/zh/stdlib/world.md +289 -0
- package/src/__tests__/formatter-extra.test.ts +139 -0
- package/src/__tests__/global-vars.test.ts +171 -0
- package/src/__tests__/lint/new-rules.test.ts +437 -0
- package/src/__tests__/lsp-rename.test.ts +171 -0
- package/src/__tests__/mc-integration/say-fstring.test.ts +211 -0
- package/src/__tests__/mc-integration/stdlib-coverage-2.test.ts +1 -1
- package/src/__tests__/mc-integration/stdlib-coverage-3.test.ts +1 -1
- package/src/__tests__/mc-integration/stdlib-coverage-4.test.ts +1 -1
- package/src/__tests__/mc-integration/stdlib-coverage-5.test.ts +1 -1
- package/src/__tests__/mc-integration/stdlib-coverage-6.test.ts +1 -1
- package/src/__tests__/mc-integration/stdlib-coverage-7.test.ts +1 -1
- package/src/__tests__/mc-integration/stdlib-coverage-8.test.ts +1 -1
- package/src/__tests__/mc-syntax.test.ts +3 -0
- package/src/__tests__/monomorphize-coverage.test.ts +220 -0
- package/src/__tests__/optimizer-cse.test.ts +250 -0
- package/src/__tests__/parser.test.ts +4 -13
- package/src/__tests__/repl-server-extra.test.ts +6 -6
- package/src/__tests__/repl-server.test.ts +5 -6
- package/src/__tests__/stdlib/queue.test.ts +6 -6
- package/src/lexer/index.ts +2 -1
- package/src/lint/index.ts +713 -5
- package/src/mc-test/client.ts +40 -0
- package/src/mir/lower.ts +111 -2
- package/src/optimizer/interprocedural.ts +40 -2
- package/src/parser/decl-parser.ts +349 -0
- package/src/parser/expr-parser.ts +838 -0
- package/src/parser/index.ts +17 -2558
- package/src/parser/stmt-parser.ts +585 -0
- package/src/parser/type-parser.ts +276 -0
- package/src/parser/utils.ts +173 -0
- package/src/stdlib/queue.mcrs +19 -6
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Parabola
|
|
2
|
+
|
|
3
|
+
> Auto-generated from `src/stdlib/parabola.mcrs` — do not edit manually.
|
|
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
|
+
Minecraft gravity per tick in ×10000 fixed-point (≈ 0.08 × 10000 = 800).
|
|
29
|
+
|
|
30
|
+
```redscript
|
|
31
|
+
fn parabola_gravity(): int
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Returns:** `800`
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## `parabola_gravity_half` <Badge type="info" text="v2.0.0" />
|
|
39
|
+
|
|
40
|
+
Half of Minecraft gravity per tick (used for displacement formula).
|
|
41
|
+
|
|
42
|
+
```redscript
|
|
43
|
+
fn parabola_gravity_half(): int
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Returns:** `400`
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## `parabola_vx` <Badge type="info" text="v2.0.0" />
|
|
51
|
+
|
|
52
|
+
Compute the initial X velocity needed to reach `dx` blocks in `ticks` ticks.
|
|
53
|
+
|
|
54
|
+
```redscript
|
|
55
|
+
fn parabola_vx(dx: int, ticks: int): int
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Parameters**
|
|
59
|
+
|
|
60
|
+
| Parameter | Description |
|
|
61
|
+
|-----------|-------------|
|
|
62
|
+
| `dx` | Horizontal X displacement in blocks |
|
|
63
|
+
| `ticks` | Flight time in ticks |
|
|
64
|
+
|
|
65
|
+
**Returns:** Initial X velocity ×10000 (`dx * 10000 / ticks`), or `0` if `ticks ≤ 0`
|
|
66
|
+
|
|
67
|
+
**Example**
|
|
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
|
+
Compute the initial Y velocity needed to reach height `dy` in `ticks` ticks.
|
|
78
|
+
|
|
79
|
+
```redscript
|
|
80
|
+
fn parabola_vy(dy: int, ticks: int): int
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Parameters**
|
|
84
|
+
|
|
85
|
+
| Parameter | Description |
|
|
86
|
+
|-----------|-------------|
|
|
87
|
+
| `dy` | Vertical displacement in blocks (positive = up) |
|
|
88
|
+
| `ticks` | Flight time in ticks |
|
|
89
|
+
|
|
90
|
+
**Returns:** Initial Y velocity ×10000, or `0` if `ticks ≤ 0`
|
|
91
|
+
|
|
92
|
+
**Example**
|
|
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
|
+
Compute the initial Z velocity needed to reach `dz` blocks in `ticks` ticks.
|
|
103
|
+
|
|
104
|
+
```redscript
|
|
105
|
+
fn parabola_vz(dz: int, ticks: int): int
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Parameters**
|
|
109
|
+
|
|
110
|
+
| Parameter | Description |
|
|
111
|
+
|-----------|-------------|
|
|
112
|
+
| `dz` | Horizontal Z displacement in blocks |
|
|
113
|
+
| `ticks` | Flight time in ticks |
|
|
114
|
+
|
|
115
|
+
**Returns:** Initial Z velocity ×10000, or `0` if `ticks ≤ 0`
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## `parabola_speed_xz` <Badge type="info" text="v2.0.0" />
|
|
120
|
+
|
|
121
|
+
Compute the horizontal speed `sqrt(vx² + vz²)` needed to reach `(dx, dz)` in `ticks` ticks.
|
|
122
|
+
|
|
123
|
+
```redscript
|
|
124
|
+
fn parabola_speed_xz(dx: int, dz: int, ticks: int): int
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Parameters**
|
|
128
|
+
|
|
129
|
+
| Parameter | Description |
|
|
130
|
+
|-----------|-------------|
|
|
131
|
+
| `dx` | X displacement in blocks |
|
|
132
|
+
| `dz` | Z displacement in blocks |
|
|
133
|
+
| `ticks` | Flight time in ticks |
|
|
134
|
+
|
|
135
|
+
**Returns:** Horizontal launch speed ×10000, or `0` if `ticks ≤ 0`
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## `parabola_x` <Badge type="info" text="v2.0.0" />
|
|
140
|
+
|
|
141
|
+
X position at tick `t` given initial X velocity `vx0` ×10000.
|
|
142
|
+
|
|
143
|
+
```redscript
|
|
144
|
+
fn parabola_x(vx0: int, t: int): int
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Parameters**
|
|
148
|
+
|
|
149
|
+
| Parameter | Description |
|
|
150
|
+
|-----------|-------------|
|
|
151
|
+
| `vx0` | Initial X velocity ×10000 |
|
|
152
|
+
| `t` | Elapsed ticks |
|
|
153
|
+
|
|
154
|
+
**Returns:** X displacement in blocks (`vx0 * t / 10000`)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## `parabola_y` <Badge type="info" text="v2.0.0" />
|
|
159
|
+
|
|
160
|
+
Y position at tick `t` given initial Y velocity `vy0` ×10000.
|
|
161
|
+
|
|
162
|
+
```redscript
|
|
163
|
+
fn parabola_y(vy0: int, t: int): int
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Parameters**
|
|
167
|
+
|
|
168
|
+
| Parameter | Description |
|
|
169
|
+
|-----------|-------------|
|
|
170
|
+
| `vy0` | Initial Y velocity ×10000 |
|
|
171
|
+
| `t` | Elapsed ticks |
|
|
172
|
+
|
|
173
|
+
**Returns:** Y displacement in blocks (positive = up)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## `parabola_z` <Badge type="info" text="v2.0.0" />
|
|
178
|
+
|
|
179
|
+
Z position at tick `t` given initial Z velocity `vz0` ×10000.
|
|
180
|
+
|
|
181
|
+
```redscript
|
|
182
|
+
fn parabola_z(vz0: int, t: int): int
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Parameters**
|
|
186
|
+
|
|
187
|
+
| Parameter | Description |
|
|
188
|
+
|-----------|-------------|
|
|
189
|
+
| `vz0` | Initial Z velocity ×10000 |
|
|
190
|
+
| `t` | Elapsed ticks |
|
|
191
|
+
|
|
192
|
+
**Returns:** Z displacement in blocks
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## `parabola_flight_time` <Badge type="info" text="v2.0.0" />
|
|
197
|
+
|
|
198
|
+
Estimate the tick when the projectile returns to launch height (`y = 0`).
|
|
199
|
+
|
|
200
|
+
Formula: `t = 2 × vy0 / gravity`. Returns `0` for non-positive initial velocity.
|
|
201
|
+
|
|
202
|
+
```redscript
|
|
203
|
+
fn parabola_flight_time(vy0: int): int
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Parameters**
|
|
207
|
+
|
|
208
|
+
| Parameter | Description |
|
|
209
|
+
|-----------|-------------|
|
|
210
|
+
| `vy0` | Initial Y velocity ×10000 |
|
|
211
|
+
|
|
212
|
+
**Returns:** Flight time in ticks, or `0` if `vy0 ≤ 0`
|
|
213
|
+
|
|
214
|
+
**Example**
|
|
215
|
+
|
|
216
|
+
```redscript
|
|
217
|
+
let t: int = parabola_flight_time(8000)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## `parabola_max_height` <Badge type="info" text="v2.0.0" />
|
|
223
|
+
|
|
224
|
+
Maximum height (in blocks) above the launch point.
|
|
225
|
+
|
|
226
|
+
```redscript
|
|
227
|
+
fn parabola_max_height(vy0: int): int
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Parameters**
|
|
231
|
+
|
|
232
|
+
| Parameter | Description |
|
|
233
|
+
|-----------|-------------|
|
|
234
|
+
| `vy0` | Initial Y velocity ×10000 |
|
|
235
|
+
|
|
236
|
+
**Returns:** Apex height in blocks, or `0` if `vy0 ≤ 0`
|
|
237
|
+
|
|
238
|
+
**Example**
|
|
239
|
+
|
|
240
|
+
```redscript
|
|
241
|
+
let h: int = parabola_max_height(8000)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## `parabola_step_vx` <Badge type="info" text="v2.0.0" />
|
|
247
|
+
|
|
248
|
+
Apply drag to the X velocity for one tick.
|
|
249
|
+
|
|
250
|
+
```redscript
|
|
251
|
+
fn parabola_step_vx(vx: int, drag: int): int
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Parameters**
|
|
255
|
+
|
|
256
|
+
| Parameter | Description |
|
|
257
|
+
|-----------|-------------|
|
|
258
|
+
| `vx` | Current X velocity ×10000 |
|
|
259
|
+
| `drag` | Drag factor ×10000 (e.g. `9900` = 0.99 for arrows) |
|
|
260
|
+
|
|
261
|
+
**Returns:** New X velocity ×10000
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## `parabola_step_vy` <Badge type="info" text="v2.0.0" />
|
|
266
|
+
|
|
267
|
+
Apply gravity and then drag to the Y velocity for one tick.
|
|
268
|
+
|
|
269
|
+
```redscript
|
|
270
|
+
fn parabola_step_vy(vy: int, drag: int): int
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Parameters**
|
|
274
|
+
|
|
275
|
+
| Parameter | Description |
|
|
276
|
+
|-----------|-------------|
|
|
277
|
+
| `vy` | Current Y velocity ×10000 |
|
|
278
|
+
| `drag` | Drag factor ×10000 |
|
|
279
|
+
|
|
280
|
+
**Returns:** New Y velocity ×10000 after `(vy - gravity) * drag`
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## `parabola_step_vz` <Badge type="info" text="v2.0.0" />
|
|
285
|
+
|
|
286
|
+
Apply drag to the Z velocity for one tick.
|
|
287
|
+
|
|
288
|
+
```redscript
|
|
289
|
+
fn parabola_step_vz(vz: int, drag: int): int
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Parameters**
|
|
293
|
+
|
|
294
|
+
| Parameter | Description |
|
|
295
|
+
|-----------|-------------|
|
|
296
|
+
| `vz` | Current Z velocity ×10000 |
|
|
297
|
+
| `drag` | Drag factor ×10000 |
|
|
298
|
+
|
|
299
|
+
**Returns:** New Z velocity ×10000
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## `parabola_ticks_for_range` <Badge type="info" text="v2.0.0" />
|
|
304
|
+
|
|
305
|
+
Estimate the number of ticks to reach a horizontal range using average arrow speed.
|
|
306
|
+
|
|
307
|
+
Heuristic: `t ≈ range × 10000 / 8000` (assumes ≈ 0.8 blocks/tick horizontal).
|
|
308
|
+
For precise aiming, use `parabola_vx/vy/vz` with a chosen tick count.
|
|
309
|
+
|
|
310
|
+
```redscript
|
|
311
|
+
fn parabola_ticks_for_range(range: int): int
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Parameters**
|
|
315
|
+
|
|
316
|
+
| Parameter | Description |
|
|
317
|
+
|-----------|-------------|
|
|
318
|
+
| `range` | Horizontal distance in blocks |
|
|
319
|
+
|
|
320
|
+
**Returns:** Estimated ticks (minimum 1)
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## `parabola_in_range` <Badge type="info" text="v2.0.0" />
|
|
325
|
+
|
|
326
|
+
Check whether a target is within horizontal range.
|
|
327
|
+
|
|
328
|
+
```redscript
|
|
329
|
+
fn parabola_in_range(dx: int, dz: int, max_range: int): int
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Parameters**
|
|
333
|
+
|
|
334
|
+
| Parameter | Description |
|
|
335
|
+
|-----------|-------------|
|
|
336
|
+
| `dx` | X displacement to target in blocks |
|
|
337
|
+
| `dz` | Z displacement to target in blocks |
|
|
338
|
+
| `max_range` | Maximum range in blocks |
|
|
339
|
+
|
|
340
|
+
**Returns:** `1` if `dist(dx, dz) ≤ max_range`, otherwise `0`
|
|
341
|
+
|
|
342
|
+
---
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# Particles
|
|
2
|
+
|
|
3
|
+
> Auto-generated from `src/stdlib/particles.mcrs` — do not edit manually.
|
|
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
|
+
Spawns heart particles at a block position.
|
|
28
|
+
|
|
29
|
+
```redscript
|
|
30
|
+
fn hearts_at(x: int, y: int, z: int)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Parameters**
|
|
34
|
+
|
|
35
|
+
| Parameter | Description |
|
|
36
|
+
|-----------|-------------|
|
|
37
|
+
| `x` | X coordinate |
|
|
38
|
+
| `y` | Y coordinate |
|
|
39
|
+
| `z` | Z coordinate |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## `flames`
|
|
44
|
+
|
|
45
|
+
Spawns flame particles at a block position.
|
|
46
|
+
|
|
47
|
+
```redscript
|
|
48
|
+
fn flames(x: int, y: int, z: int)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Parameters**
|
|
52
|
+
|
|
53
|
+
| Parameter | Description |
|
|
54
|
+
|-----------|-------------|
|
|
55
|
+
| `x` | X coordinate |
|
|
56
|
+
| `y` | Y coordinate |
|
|
57
|
+
| `z` | Z coordinate |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## `smoke`
|
|
62
|
+
|
|
63
|
+
Spawns large smoke particles at a block position.
|
|
64
|
+
|
|
65
|
+
```redscript
|
|
66
|
+
fn smoke(x: int, y: int, z: int)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Parameters**
|
|
70
|
+
|
|
71
|
+
| Parameter | Description |
|
|
72
|
+
|-----------|-------------|
|
|
73
|
+
| `x` | X coordinate |
|
|
74
|
+
| `y` | Y coordinate |
|
|
75
|
+
| `z` | Z coordinate |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## `explosion_effect`
|
|
80
|
+
|
|
81
|
+
Spawns an explosion particle at a block position.
|
|
82
|
+
|
|
83
|
+
```redscript
|
|
84
|
+
fn explosion_effect(x: int, y: int, z: int)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Parameters**
|
|
88
|
+
|
|
89
|
+
| Parameter | Description |
|
|
90
|
+
|-----------|-------------|
|
|
91
|
+
| `x` | X coordinate |
|
|
92
|
+
| `y` | Y coordinate |
|
|
93
|
+
| `z` | Z coordinate |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## `sparkles_at`
|
|
98
|
+
|
|
99
|
+
Spawns enchantment sparkles at a block position.
|
|
100
|
+
|
|
101
|
+
```redscript
|
|
102
|
+
fn sparkles_at(x: int, y: int, z: int)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Parameters**
|
|
106
|
+
|
|
107
|
+
| Parameter | Description |
|
|
108
|
+
|-----------|-------------|
|
|
109
|
+
| `x` | X coordinate |
|
|
110
|
+
| `y` | Y coordinate |
|
|
111
|
+
| `z` | Z coordinate |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## `angry_at`
|
|
116
|
+
|
|
117
|
+
Spawns angry villager particles at a block position.
|
|
118
|
+
|
|
119
|
+
```redscript
|
|
120
|
+
fn angry_at(x: int, y: int, z: int)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Parameters**
|
|
124
|
+
|
|
125
|
+
| Parameter | Description |
|
|
126
|
+
|-----------|-------------|
|
|
127
|
+
| `x` | X coordinate |
|
|
128
|
+
| `y` | Y coordinate |
|
|
129
|
+
| `z` | Z coordinate |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## `happy_at`
|
|
134
|
+
|
|
135
|
+
Spawns happy villager particles at a block position.
|
|
136
|
+
|
|
137
|
+
```redscript
|
|
138
|
+
fn happy_at(x: int, y: int, z: int)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Parameters**
|
|
142
|
+
|
|
143
|
+
| Parameter | Description |
|
|
144
|
+
|-----------|-------------|
|
|
145
|
+
| `x` | X coordinate |
|
|
146
|
+
| `y` | Y coordinate |
|
|
147
|
+
| `z` | Z coordinate |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## `portal_effect`
|
|
152
|
+
|
|
153
|
+
Spawns portal particles at a block position.
|
|
154
|
+
|
|
155
|
+
```redscript
|
|
156
|
+
fn portal_effect(x: int, y: int, z: int)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Parameters**
|
|
160
|
+
|
|
161
|
+
| Parameter | Description |
|
|
162
|
+
|-----------|-------------|
|
|
163
|
+
| `x` | X coordinate |
|
|
164
|
+
| `y` | Y coordinate |
|
|
165
|
+
| `z` | Z coordinate |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## `totem_at`
|
|
170
|
+
|
|
171
|
+
Spawns totem particles at a block position.
|
|
172
|
+
|
|
173
|
+
```redscript
|
|
174
|
+
fn totem_at(x: int, y: int, z: int)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Parameters**
|
|
178
|
+
|
|
179
|
+
| Parameter | Description |
|
|
180
|
+
|-----------|-------------|
|
|
181
|
+
| `x` | X coordinate |
|
|
182
|
+
| `y` | Y coordinate |
|
|
183
|
+
| `z` | Z coordinate |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## `end_sparkles_at`
|
|
188
|
+
|
|
189
|
+
Spawns end rod particles at a block position.
|
|
190
|
+
|
|
191
|
+
```redscript
|
|
192
|
+
fn end_sparkles_at(x: int, y: int, z: int)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Parameters**
|
|
196
|
+
|
|
197
|
+
| Parameter | Description |
|
|
198
|
+
|-----------|-------------|
|
|
199
|
+
| `x` | X coordinate |
|
|
200
|
+
| `y` | Y coordinate |
|
|
201
|
+
| `z` | Z coordinate |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## `particle_at_fx`
|
|
206
|
+
|
|
207
|
+
Spawns a particle at a fixed-point position expressed as blocks ×100.
|
|
208
|
+
This helper emits a raw command so sub-block coordinates are preserved.
|
|
209
|
+
|
|
210
|
+
```redscript
|
|
211
|
+
fn particle_at_fx(x_fx: int, y_fx: int, z_fx: int, particle: string)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Parameters**
|
|
215
|
+
|
|
216
|
+
| Parameter | Description |
|
|
217
|
+
|-----------|-------------|
|
|
218
|
+
| `x_fx` | X coordinate in blocks ×100 |
|
|
219
|
+
| `y_fx` | Y coordinate in blocks ×100 |
|
|
220
|
+
| `z_fx` | Z coordinate in blocks ×100 |
|
|
221
|
+
| `particle` | Particle ID such as `minecraft:flame` |
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## `draw_line_2d`
|
|
226
|
+
|
|
227
|
+
Draws a straight 2D particle line using linear interpolation.
|
|
228
|
+
Coordinates are fixed-point blocks ×100; `z` is also passed in ×100.
|
|
229
|
+
|
|
230
|
+
```redscript
|
|
231
|
+
fn draw_line_2d(x0: int, y0: int, x1: int, y1: int, steps: int, z: int, particle: string)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Parameters**
|
|
235
|
+
|
|
236
|
+
| Parameter | Description |
|
|
237
|
+
|-----------|-------------|
|
|
238
|
+
| `x0` | Start X in blocks ×100 |
|
|
239
|
+
| `y0` | Start Y in blocks ×100 |
|
|
240
|
+
| `x1` | End X in blocks ×100 |
|
|
241
|
+
| `y1` | End Y in blocks ×100 |
|
|
242
|
+
| `steps` | Number of interpolation steps |
|
|
243
|
+
| `z` | Z plane in blocks ×100 |
|
|
244
|
+
| `particle` | Particle ID such as `minecraft:dust` |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## `draw_circle`
|
|
249
|
+
|
|
250
|
+
Draws a circle in the XZ plane using `cos_fixed` and `sin_fixed`.
|
|
251
|
+
Center coordinates are whole blocks; radius is blocks ×100.
|
|
252
|
+
|
|
253
|
+
```redscript
|
|
254
|
+
fn draw_circle(cx: int, cy: int, cz: int, r: int, steps: int, particle: string)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Parameters**
|
|
258
|
+
|
|
259
|
+
| Parameter | Description |
|
|
260
|
+
|-----------|-------------|
|
|
261
|
+
| `cx` | Center X in blocks |
|
|
262
|
+
| `cy` | Center Y in blocks |
|
|
263
|
+
| `cz` | Center Z in blocks |
|
|
264
|
+
| `r` | Radius in blocks ×100 |
|
|
265
|
+
| `steps` | Number of particle samples around the circle |
|
|
266
|
+
| `particle` | Particle ID such as `minecraft:end_rod` |
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## `draw_helix`
|
|
271
|
+
|
|
272
|
+
Draws a helix spiral with configurable radius, height, and turns.
|
|
273
|
+
Center coordinates are whole blocks; radius is blocks ×100.
|
|
274
|
+
|
|
275
|
+
```redscript
|
|
276
|
+
fn draw_helix(cx: int, cy_start: int, cz: int, r: int, height: int, rotations: int, steps: int, particle: string)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Parameters**
|
|
280
|
+
|
|
281
|
+
| Parameter | Description |
|
|
282
|
+
|-----------|-------------|
|
|
283
|
+
| `cx` | Center X in blocks |
|
|
284
|
+
| `cy_start` | Starting Y coordinate in blocks |
|
|
285
|
+
| `cz` | Center Z in blocks |
|
|
286
|
+
| `r` | Radius in blocks ×100 |
|
|
287
|
+
| `height` | Total helix height in blocks |
|
|
288
|
+
| `rotations` | Number of full turns |
|
|
289
|
+
| `steps` | Number of particle samples |
|
|
290
|
+
| `particle` | Particle ID such as `minecraft:portal` |
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## `particle_dot`
|
|
295
|
+
|
|
296
|
+
Spawns exactly one particle at integer block coordinates.
|
|
297
|
+
|
|
298
|
+
```redscript
|
|
299
|
+
fn particle_dot(x: int, y: int, z: int, particle: string)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**Parameters**
|
|
303
|
+
|
|
304
|
+
| Parameter | Description |
|
|
305
|
+
|-----------|-------------|
|
|
306
|
+
| `x` | X coordinate in whole blocks |
|
|
307
|
+
| `y` | Y coordinate in whole blocks |
|
|
308
|
+
| `z` | Z coordinate in whole blocks |
|
|
309
|
+
| `particle` | Particle ID such as `minecraft:flame` |
|
|
310
|
+
|
|
311
|
+
---
|