@nxg-org/mineflayer-util-plugin 1.9.1 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -0
- package/README_reference.md +53 -0
- package/docs/README.md +115 -0
- package/docs/aabb.md +62 -0
- package/docs/entityFunctions.md +88 -0
- package/docs/filterFunctions.md +98 -0
- package/docs/interceptFunctions.md +40 -0
- package/docs/inventoryFunctions.md +134 -0
- package/docs/movementFunctions.md +58 -0
- package/docs/predictiveFunctions.md +76 -0
- package/docs/rayTracingFunctions.md +63 -0
- package/docs/raycastIterator.md +58 -0
- package/docs/static.md +116 -0
- package/docs/utilFunctions.md +99 -0
- package/lib/calcs/intercept.js +1 -1
- package/lib/movementFunctions.js +15 -10
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>mineflayer-util-plugin</h1>
|
|
3
|
+
<p><strong>Utility helpers for NextGEN Mineflayer bots.</strong></p>
|
|
4
|
+
<p>
|
|
5
|
+
A focused collection of bot helpers for movement, ray tracing, entity math, inventory handling,
|
|
6
|
+
prediction, and reusable geometry utilities.
|
|
7
|
+
</p>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="docs/README.md"><img src="https://img.shields.io/badge/API-Docs-2ea44f?style=for-the-badge" alt="API Docs"></a>
|
|
12
|
+
<a href="examples"><img src="https://img.shields.io/badge/Examples-Available-0969da?style=for-the-badge" alt="Examples"></a>
|
|
13
|
+
<a href="https://github.com/nxg-org/mineflayer-util-plugin/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-GPL--3.0-8a2be2?style=for-the-badge" alt="License"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://ko-fi.com/generel">
|
|
18
|
+
<img src="https://img.shields.io/badge/Support%20the%20project-Ko--fi-ff5f5f?style=for-the-badge&logo=kofi" alt="Support on Ko-fi">
|
|
19
|
+
</a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<blockquote>
|
|
23
|
+
This library exposes the plugin injector at the package root. After injecting it into a Mineflayer bot,
|
|
24
|
+
the helpers are available under <code>bot.util</code>.
|
|
25
|
+
</blockquote>
|
|
26
|
+
|
|
27
|
+
<h2>Quick Start</h2>
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import mineflayer from "mineflayer";
|
|
31
|
+
import inject from "@nxg-org/mineflayer-util-plugin";
|
|
32
|
+
|
|
33
|
+
const bot = mineflayer.createBot({
|
|
34
|
+
host: "localhost",
|
|
35
|
+
username: "UtilityBot"
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
inject(bot);
|
|
39
|
+
|
|
40
|
+
// Helpers are now available under bot.util
|
|
41
|
+
const dir = bot.util.getViewDir();
|
|
42
|
+
const nearest = bot.util.filters.nearestCrystalFilter();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<h2>What Is Included</h2>
|
|
46
|
+
|
|
47
|
+
<table>
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
<th align="left">Module</th>
|
|
51
|
+
<th align="left">Purpose</th>
|
|
52
|
+
<th align="left">Docs</th>
|
|
53
|
+
</tr>
|
|
54
|
+
</thead>
|
|
55
|
+
<tbody>
|
|
56
|
+
<tr>
|
|
57
|
+
<td><code>UtilFunctions</code></td>
|
|
58
|
+
<td>Main aggregator attached to <code>bot.util</code></td>
|
|
59
|
+
<td><a href="docs/utilFunctions.md">docs/utilFunctions.md</a></td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><code>EntityFunctions</code></td>
|
|
63
|
+
<td>Health, distance, and entity metadata helpers</td>
|
|
64
|
+
<td><a href="docs/entityFunctions.md">docs/entityFunctions.md</a></td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td><code>FilterFunctions</code></td>
|
|
68
|
+
<td>Nearest-entity and bot-filtering helpers</td>
|
|
69
|
+
<td><a href="docs/filterFunctions.md">docs/filterFunctions.md</a></td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td><code>InventoryFunctions</code></td>
|
|
73
|
+
<td>Inventory lookups and equip helpers</td>
|
|
74
|
+
<td><a href="docs/inventoryFunctions.md">docs/inventoryFunctions.md</a></td>
|
|
75
|
+
</tr>
|
|
76
|
+
<tr>
|
|
77
|
+
<td><code>MovementFunctions</code></td>
|
|
78
|
+
<td>Synchronized look and movement packet helpers</td>
|
|
79
|
+
<td><a href="docs/movementFunctions.md">docs/movementFunctions.md</a></td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><code>PredictiveFunctions</code></td>
|
|
83
|
+
<td>Explosion damage prediction and world overrides</td>
|
|
84
|
+
<td><a href="docs/predictiveFunctions.md">docs/predictiveFunctions.md</a></td>
|
|
85
|
+
</tr>
|
|
86
|
+
<tr>
|
|
87
|
+
<td><code>RayTraceFunctions</code></td>
|
|
88
|
+
<td>Block and entity ray tracing helpers</td>
|
|
89
|
+
<td><a href="docs/rayTracingFunctions.md">docs/rayTracingFunctions.md</a></td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<td><code>AABB</code>, <code>InterceptFunctions</code>, <code>RaycastIterator</code>, <code>AABBUtils</code>, <code>MathUtils</code>, <code>Task</code></td>
|
|
93
|
+
<td>Public geometry and support utilities exported from the package root</td>
|
|
94
|
+
<td><a href="docs/README.md">docs/README.md</a></td>
|
|
95
|
+
</tr>
|
|
96
|
+
</tbody>
|
|
97
|
+
</table>
|
|
98
|
+
|
|
99
|
+
<h2>Documentation Layout</h2>
|
|
100
|
+
|
|
101
|
+
<p>
|
|
102
|
+
The full API reference lives in <a href="docs/README.md">docs/README.md</a>. Each public function file
|
|
103
|
+
has its own page inside the <code>docs</code> folder so it is easy to browse module by module.
|
|
104
|
+
</p>
|
|
105
|
+
|
|
106
|
+
<h2>Notes</h2>
|
|
107
|
+
|
|
108
|
+
<ul>
|
|
109
|
+
<li>Several helpers are version-sensitive, especially health, armor, and metadata logic.</li>
|
|
110
|
+
<li><code>MovementFunctions</code> listens to bot spawn and move events to keep look synchronization accurate.</li>
|
|
111
|
+
<li><code>PredictiveFunctions</code> uses a predictive world overlay for explosion estimates.</li>
|
|
112
|
+
</ul>
|
|
113
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://avatars.githubusercontent.com/u/79112097?s=200&v=4" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h2 align="center">minecraft-pathfinding :tm:</h2>
|
|
6
|
+
<h4 align="center">A pathfinder to get a Minecraft bot from point A to point B with unnecessarily stylish movement</h4>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://discord.gg/zDzugD3ywn">
|
|
10
|
+
<img src="https://img.shields.io/badge/discord-000000?style=for-the-badge&logo=discord" alt="Discord">
|
|
11
|
+
</a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
> [!WARNING]
|
|
15
|
+
> This pathfinder is still in **HEAVY** development. It is not meant to be used in production. However, you can use the code in `examples` to understand how the pathfinder works.
|
|
16
|
+
|
|
17
|
+
<h3 align="center">Why use this pathfinder?</h3>
|
|
18
|
+
|
|
19
|
+
-----
|
|
20
|
+
|
|
21
|
+
Presently, its execution is better than both Baritone's and mineflayer-pathfinder's. It also follows an entirely different paradigm - each move's execution is split into individual parts, which combined with a modular movement provider/executor/optimizer system, it makes this pathfinder ***extremely*** customizable. So as long as a single movement's execution handles all entry cases (which is possible), it can be immediately integrated into this bot.
|
|
22
|
+
|
|
23
|
+
Examples will be added as the project undergoes more development.
|
|
24
|
+
|
|
25
|
+
<h3 align="center">What is left to be done?</h3>
|
|
26
|
+
|
|
27
|
+
-----
|
|
28
|
+
|
|
29
|
+
**Many** things.
|
|
30
|
+
|
|
31
|
+
- [X] Proper breaking of blocks (Cost + Execution)
|
|
32
|
+
- [X] Water movement
|
|
33
|
+
- [X] Parkour
|
|
34
|
+
- [X] Proper jump sprinting
|
|
35
|
+
- [ ] Offloading the world thread
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
<h3 align="center">API and Examples</h3>
|
|
39
|
+
|
|
40
|
+
-----
|
|
41
|
+
|
|
42
|
+
| Link | Description |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| [API](https://github.com/GenerelSchwerz/minecraft-pathfinding/blob/main/docs/API.md) | The documentation with the available methods and properties. |
|
|
45
|
+
| [Advanced Usage](https://github.com/GenerelSchwerz/minecraft-pathfinding/blob/main/docs/AdvancedUsage.md) | The documentation with the advanced usage of the pathfinder, including the customization of goals and movements. |
|
|
46
|
+
| [Examples](https://github.com/GenerelSchwerz/minecraft-pathfinding/tree/main/examples) | The folder with the examples. |
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<!-- TODO: link my Ko-Fi: -->
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
<!-- preferably do this in a way that's eye-catching.
|
|
53
|
+
https://ko-fi.com/generel -->
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>API Reference</h1>
|
|
3
|
+
<p><strong>Module-by-module documentation for the Mineflayer utility plugin.</strong></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<h2>Public Entry Point</h2>
|
|
7
|
+
|
|
8
|
+
<table>
|
|
9
|
+
<thead>
|
|
10
|
+
<tr>
|
|
11
|
+
<th align="left">Export</th>
|
|
12
|
+
<th align="left">Description</th>
|
|
13
|
+
</tr>
|
|
14
|
+
</thead>
|
|
15
|
+
<tbody>
|
|
16
|
+
<tr>
|
|
17
|
+
<td><code>default inject(bot)</code></td>
|
|
18
|
+
<td>Attaches <code>bot.util</code> and installs the utility wrapper.</td>
|
|
19
|
+
</tr>
|
|
20
|
+
<tr>
|
|
21
|
+
<td><code>AABB</code></td>
|
|
22
|
+
<td>Axis-aligned bounding box helper used across ray tracing and collision math.</td>
|
|
23
|
+
</tr>
|
|
24
|
+
<tr>
|
|
25
|
+
<td><code>InterceptFunctions</code></td>
|
|
26
|
+
<td>Raycast helper that returns both the hit block and the traversal path.</td>
|
|
27
|
+
</tr>
|
|
28
|
+
<tr>
|
|
29
|
+
<td><code>RaycastIterator</code></td>
|
|
30
|
+
<td>Iterator used to step through blocks along a ray.</td>
|
|
31
|
+
</tr>
|
|
32
|
+
<tr>
|
|
33
|
+
<td><code>BlockFace</code></td>
|
|
34
|
+
<td>Enum describing which face a ray intersected.</td>
|
|
35
|
+
</tr>
|
|
36
|
+
<tr>
|
|
37
|
+
<td><code>AABBUtils</code></td>
|
|
38
|
+
<td>Namespace of AABB builders for blocks, entities, and positions.</td>
|
|
39
|
+
</tr>
|
|
40
|
+
<tr>
|
|
41
|
+
<td><code>MathUtils</code></td>
|
|
42
|
+
<td>Angle, velocity, and direction helpers.</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td><code>Task</code></td>
|
|
46
|
+
<td>Typed promise wrapper for cancellable or finishable tasks.</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</tbody>
|
|
49
|
+
</table>
|
|
50
|
+
|
|
51
|
+
<h2>Module Pages</h2>
|
|
52
|
+
|
|
53
|
+
<table>
|
|
54
|
+
<thead>
|
|
55
|
+
<tr>
|
|
56
|
+
<th align="left">Page</th>
|
|
57
|
+
<th align="left">Focus</th>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><a href="utilFunctions.md">utilFunctions.md</a></td>
|
|
63
|
+
<td>Main <code>bot.util</code> wrapper and helper aggregation</td>
|
|
64
|
+
</tr>
|
|
65
|
+
<tr>
|
|
66
|
+
<td><a href="entityFunctions.md">entityFunctions.md</a></td>
|
|
67
|
+
<td>Entity health and distance helpers</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td><a href="filterFunctions.md">filterFunctions.md</a></td>
|
|
71
|
+
<td>Nearest entity and bot filtering helpers</td>
|
|
72
|
+
</tr>
|
|
73
|
+
<tr>
|
|
74
|
+
<td><a href="inventoryFunctions.md">inventoryFunctions.md</a></td>
|
|
75
|
+
<td>Inventory search and equipment helpers</td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td><a href="movementFunctions.md">movementFunctions.md</a></td>
|
|
79
|
+
<td>Look synchronization and teleport packet helpers</td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><a href="predictiveFunctions.md">predictiveFunctions.md</a></td>
|
|
83
|
+
<td>Explosion prediction and simulated block handling</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td><a href="rayTracingFunctions.md">rayTracingFunctions.md</a></td>
|
|
87
|
+
<td>Entity and block ray tracing helpers</td>
|
|
88
|
+
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td><a href="aabb.md">aabb.md</a></td>
|
|
91
|
+
<td>Public <code>AABB</code> geometry class</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td><a href="interceptFunctions.md">interceptFunctions.md</a></td>
|
|
95
|
+
<td>Block raycast wrapper around the iterator</td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td><a href="raycastIterator.md">raycastIterator.md</a></td>
|
|
99
|
+
<td>Ray traversal iterator and face enum</td>
|
|
100
|
+
</tr>
|
|
101
|
+
<tr>
|
|
102
|
+
<td><a href="static.md">static.md</a></td>
|
|
103
|
+
<td><code>AABBUtils</code>, <code>MathUtils</code>, and <code>Task</code></td>
|
|
104
|
+
</tr>
|
|
105
|
+
</tbody>
|
|
106
|
+
</table>
|
|
107
|
+
|
|
108
|
+
<h2>Compatibility Note</h2>
|
|
109
|
+
|
|
110
|
+
<blockquote>
|
|
111
|
+
Some helpers depend on Mineflayer registry details, entity metadata indexes, or version-specific
|
|
112
|
+
equipment slots. If you are targeting multiple Minecraft versions, verify the method behavior against
|
|
113
|
+
the version you ship against.
|
|
114
|
+
</blockquote>
|
|
115
|
+
|
package/docs/aabb.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>AABB</h1>
|
|
3
|
+
<p><code>src/calcs/aabb.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Public axis-aligned bounding box class used throughout the library for collision checks, ray intersection,
|
|
8
|
+
and entity hitbox math.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>Constructor</h2>
|
|
12
|
+
|
|
13
|
+
<pre><code class="language-ts">new AABB(x0, y0, z0, x1, y1, z1)</code></pre>
|
|
14
|
+
|
|
15
|
+
<h2>Useful Methods</h2>
|
|
16
|
+
|
|
17
|
+
<table>
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th align="left">Method</th>
|
|
21
|
+
<th align="left">Description</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody>
|
|
25
|
+
<tr>
|
|
26
|
+
<td><code>minPoint()</code>, <code>maxPoint()</code></td>
|
|
27
|
+
<td>Return the minimum or maximum corner as a <code>Vec3</code>.</td>
|
|
28
|
+
</tr>
|
|
29
|
+
<tr>
|
|
30
|
+
<td><code>distanceToVec(pos)</code></td>
|
|
31
|
+
<td>Returns the shortest distance from the box to a point.</td>
|
|
32
|
+
</tr>
|
|
33
|
+
<tr>
|
|
34
|
+
<td><code>intersectsRay(org, dir)</code></td>
|
|
35
|
+
<td>Returns the first ray intersection point, or <code>null</code>.</td>
|
|
36
|
+
</tr>
|
|
37
|
+
<tr>
|
|
38
|
+
<td><code>intersects(other)</code>, <code>collides(other)</code></td>
|
|
39
|
+
<td>Overlap checks with strict or inclusive bounds.</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<tr>
|
|
42
|
+
<td><code>translateVec(vec)</code>, <code>move(vec)</code>, <code>expand(x, y, z)</code></td>
|
|
43
|
+
<td>Mutating or copy-returning geometry transforms.</td>
|
|
44
|
+
</tr>
|
|
45
|
+
<tr>
|
|
46
|
+
<td><code>toShapeFromMin()</code>, <code>toShapeFromBottomMiddle()</code></td>
|
|
47
|
+
<td>Converts the box into prismarine-world compatible shapes.</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td><code>getCenter()</code></td>
|
|
51
|
+
<td>Returns the center point of the box.</td>
|
|
52
|
+
</tr>
|
|
53
|
+
</tbody>
|
|
54
|
+
</table>
|
|
55
|
+
|
|
56
|
+
<h2>Notes</h2>
|
|
57
|
+
|
|
58
|
+
<ul>
|
|
59
|
+
<li>Most methods mutate the current instance when they are geometry transforms.</li>
|
|
60
|
+
<li>Ray helpers normalize the direction vector internally.</li>
|
|
61
|
+
</ul>
|
|
62
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>EntityFunctions</h1>
|
|
3
|
+
<p><code>src/entityFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Helpers for entity state, health parsing, and distance calculations. Several methods are version-sensitive
|
|
8
|
+
because Minecraft stores metadata differently across releases.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>Constructor</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Signature</th>
|
|
17
|
+
<th align="left">Description</th>
|
|
18
|
+
</tr>
|
|
19
|
+
</thead>
|
|
20
|
+
<tbody>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>new EntityFunctions(bot)</code></td>
|
|
23
|
+
<td>Creates the helper object and selects the health metadata slot based on bot version.</td>
|
|
24
|
+
</tr>
|
|
25
|
+
</tbody>
|
|
26
|
+
</table>
|
|
27
|
+
|
|
28
|
+
<h2>Methods</h2>
|
|
29
|
+
|
|
30
|
+
<table>
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
<th align="left">Method</th>
|
|
34
|
+
<th align="left">Returns</th>
|
|
35
|
+
<th align="left">Description</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr>
|
|
40
|
+
<td><code>isMainHandActive(entity?)</code></td>
|
|
41
|
+
<td><code>boolean</code></td>
|
|
42
|
+
<td>Checks whether the entity metadata indicates main-hand use.</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td><code>isOffHandActive(entity?)</code></td>
|
|
46
|
+
<td><code>boolean</code></td>
|
|
47
|
+
<td>Checks whether the entity metadata indicates off-hand use.</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td><code>getHealth(entity?)</code></td>
|
|
51
|
+
<td><code>number</code></td>
|
|
52
|
+
<td>Returns health from entity metadata, falling back to bot health when needed.</td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td><code>getHealthFromMetadata(metadata)</code></td>
|
|
56
|
+
<td><code>number</code></td>
|
|
57
|
+
<td>Reads health directly from a full metadata array.</td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr>
|
|
60
|
+
<td><code>getHealthChange(packetMetadata, entity)</code></td>
|
|
61
|
+
<td><code>number</code></td>
|
|
62
|
+
<td>Computes health delta from packet metadata versus current entity metadata.</td>
|
|
63
|
+
</tr>
|
|
64
|
+
<tr>
|
|
65
|
+
<td><code>entityDistance(entity)</code></td>
|
|
66
|
+
<td><code>number</code></td>
|
|
67
|
+
<td>Distance between the bot and the target entity.</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td><code>eyeDistanceToEntity(entity)</code></td>
|
|
71
|
+
<td><code>number</code></td>
|
|
72
|
+
<td>Distance from the bot's eye position to the entity's AABB.</td>
|
|
73
|
+
</tr>
|
|
74
|
+
<tr>
|
|
75
|
+
<td><code>eyeDistanceBetweenEntities(first, second)</code></td>
|
|
76
|
+
<td><code>number</code></td>
|
|
77
|
+
<td>Distance from the first entity's eye position to the second entity's AABB.</td>
|
|
78
|
+
</tr>
|
|
79
|
+
</tbody>
|
|
80
|
+
</table>
|
|
81
|
+
|
|
82
|
+
<h2>Notes</h2>
|
|
83
|
+
|
|
84
|
+
<ul>
|
|
85
|
+
<li><code>healthSlot</code> is derived from the bot's Minecraft version.</li>
|
|
86
|
+
<li>Distance helpers use <code>AABBUtils</code> to account for entity hitboxes instead of treating entities as points.</li>
|
|
87
|
+
</ul>
|
|
88
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>FilterFunctions</h1>
|
|
3
|
+
<p><code>src/filterFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Entity filtering helpers centered around Mineflayer's nearest-entity lookup. This module is useful when you
|
|
8
|
+
want to pick targets, ignore your own bots, or search for a specific class of entities.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>State</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Property</th>
|
|
17
|
+
<th align="left">Type</th>
|
|
18
|
+
<th align="left">Purpose</th>
|
|
19
|
+
</tr>
|
|
20
|
+
</thead>
|
|
21
|
+
<tbody>
|
|
22
|
+
<tr>
|
|
23
|
+
<td><code>specificNames</code></td>
|
|
24
|
+
<td><code>string[]</code></td>
|
|
25
|
+
<td>Allowed player names for named-target filtering.</td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td><code>botNames</code></td>
|
|
29
|
+
<td><code>string[]</code></td>
|
|
30
|
+
<td>Names that should be excluded when looking for non-bot players.</td>
|
|
31
|
+
</tr>
|
|
32
|
+
</tbody>
|
|
33
|
+
</table>
|
|
34
|
+
|
|
35
|
+
<h2>Methods</h2>
|
|
36
|
+
|
|
37
|
+
<table>
|
|
38
|
+
<thead>
|
|
39
|
+
<tr>
|
|
40
|
+
<th align="left">Method</th>
|
|
41
|
+
<th align="left">Returns</th>
|
|
42
|
+
<th align="left">Description</th>
|
|
43
|
+
</tr>
|
|
44
|
+
</thead>
|
|
45
|
+
<tbody>
|
|
46
|
+
<tr>
|
|
47
|
+
<td><code>addBotName(name)</code></td>
|
|
48
|
+
<td><code>void</code></td>
|
|
49
|
+
<td>Adds a bot name to the exclusion list.</td>
|
|
50
|
+
</tr>
|
|
51
|
+
<tr>
|
|
52
|
+
<td><code>getNearestEntity(func, ...args)</code></td>
|
|
53
|
+
<td><code>Entity | null</code></td>
|
|
54
|
+
<td>Returns the nearest entity that passes the provided predicate.</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<td><code>static getNearestEntity(bot, func, ...args)</code></td>
|
|
58
|
+
<td><code>Entity | null</code></td>
|
|
59
|
+
<td>Static version of the nearest-entity lookup.</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><code>allButOtherBotsFilter()</code></td>
|
|
63
|
+
<td><code>Entity | null</code></td>
|
|
64
|
+
<td>Finds the nearest player whose username is not in <code>botNames</code>.</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td><code>static allButOtherBotsFilter(bot, ...names)</code></td>
|
|
68
|
+
<td><code>Entity | null</code></td>
|
|
69
|
+
<td>Static helper for the same bot-exclusion lookup.</td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td><code>specificNamesFilter()</code></td>
|
|
73
|
+
<td><code>Entity | null</code></td>
|
|
74
|
+
<td>Finds the nearest player whose username is in <code>specificNames</code>.</td>
|
|
75
|
+
</tr>
|
|
76
|
+
<tr>
|
|
77
|
+
<td><code>static specificNamesFilter(bot, ...names)</code></td>
|
|
78
|
+
<td><code>Entity | null</code></td>
|
|
79
|
+
<td>Static helper for named player lookup.</td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><code>nearestCrystalFilter()</code></td>
|
|
83
|
+
<td><code>Entity | null</code></td>
|
|
84
|
+
<td>Finds the nearest end crystal.</td>
|
|
85
|
+
</tr>
|
|
86
|
+
<tr>
|
|
87
|
+
<td><code>static nearestCrystalFilter(bot)</code></td>
|
|
88
|
+
<td><code>Entity | null</code></td>
|
|
89
|
+
<td>Static helper for finding the nearest end crystal.</td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<td><code>crystalAtPosition(position)</code></td>
|
|
93
|
+
<td><code>Entity | null</code></td>
|
|
94
|
+
<td>Finds a crystal whose translated position matches the supplied block position.</td>
|
|
95
|
+
</tr>
|
|
96
|
+
</tbody>
|
|
97
|
+
</table>
|
|
98
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>InterceptFunctions</h1>
|
|
3
|
+
<p><code>src/calcs/intercept.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Higher-level raycast wrapper that records the traversal path and returns the first intersected block.
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<h2>Methods</h2>
|
|
11
|
+
|
|
12
|
+
<table>
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<th align="left">Method</th>
|
|
16
|
+
<th align="left">Returns</th>
|
|
17
|
+
<th align="left">Description</th>
|
|
18
|
+
</tr>
|
|
19
|
+
</thead>
|
|
20
|
+
<tbody>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>check(from, to)</code></td>
|
|
23
|
+
<td><code>BlockAndIterations</code></td>
|
|
24
|
+
<td>Convenience wrapper that computes direction and range before raycasting.</td>
|
|
25
|
+
</tr>
|
|
26
|
+
<tr>
|
|
27
|
+
<td><code>raycast(from, direction, range)</code></td>
|
|
28
|
+
<td><code>BlockAndIterations</code></td>
|
|
29
|
+
<td>Steps through the ray and returns the hit block, traversal iterations, and intersection point.</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</tbody>
|
|
32
|
+
</table>
|
|
33
|
+
|
|
34
|
+
<h2>Notes</h2>
|
|
35
|
+
|
|
36
|
+
<ul>
|
|
37
|
+
<li>The returned iteration list is useful for debugging or visualizing traversal.</li>
|
|
38
|
+
<li>This helper uses <code>RaycastIterator</code> internally.</li>
|
|
39
|
+
</ul>
|
|
40
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>InventoryFunctions</h1>
|
|
3
|
+
<p><code>src/inventoryFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Inventory and equipment helpers for Mineflayer bots. The class wraps item lookup, hand access, and a couple
|
|
8
|
+
of equip flows that try to keep the bot from getting stuck.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>State</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Property</th>
|
|
17
|
+
<th align="left">Type</th>
|
|
18
|
+
<th align="left">Purpose</th>
|
|
19
|
+
</tr>
|
|
20
|
+
</thead>
|
|
21
|
+
<tbody>
|
|
22
|
+
<tr>
|
|
23
|
+
<td><code>usingMainHand</code></td>
|
|
24
|
+
<td><code>boolean</code></td>
|
|
25
|
+
<td>Tracks whether the main hand is being used.</td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td><code>usingOffHand</code></td>
|
|
29
|
+
<td><code>boolean</code></td>
|
|
30
|
+
<td>Tracks whether the off hand is being used.</td>
|
|
31
|
+
</tr>
|
|
32
|
+
<tr>
|
|
33
|
+
<td><code>equippingMainHand</code></td>
|
|
34
|
+
<td><code>boolean</code></td>
|
|
35
|
+
<td>Internal flag for main-hand equip flow.</td>
|
|
36
|
+
</tr>
|
|
37
|
+
<tr>
|
|
38
|
+
<td><code>equippingOffHand</code></td>
|
|
39
|
+
<td><code>boolean</code></td>
|
|
40
|
+
<td>Internal flag for off-hand equip flow.</td>
|
|
41
|
+
</tr>
|
|
42
|
+
<tr>
|
|
43
|
+
<td><code>equippingOtherSlot</code></td>
|
|
44
|
+
<td><code>boolean</code></td>
|
|
45
|
+
<td>Internal flag for non-hand equip flow.</td>
|
|
46
|
+
</tr>
|
|
47
|
+
</tbody>
|
|
48
|
+
</table>
|
|
49
|
+
|
|
50
|
+
<h2>Getters</h2>
|
|
51
|
+
|
|
52
|
+
<table>
|
|
53
|
+
<thead>
|
|
54
|
+
<tr>
|
|
55
|
+
<th align="left">Getter</th>
|
|
56
|
+
<th align="left">Returns</th>
|
|
57
|
+
<th align="left">Description</th>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<tbody>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><code>equipmentSlots</code></td>
|
|
63
|
+
<td><code>EquipmentDestination[]</code></td>
|
|
64
|
+
<td>Returns the list of supported equipment destinations for the current bot version.</td>
|
|
65
|
+
</tr>
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
68
|
+
|
|
69
|
+
<h2>Methods</h2>
|
|
70
|
+
|
|
71
|
+
<table>
|
|
72
|
+
<thead>
|
|
73
|
+
<tr>
|
|
74
|
+
<th align="left">Method</th>
|
|
75
|
+
<th align="left">Returns</th>
|
|
76
|
+
<th align="left">Description</th>
|
|
77
|
+
</tr>
|
|
78
|
+
</thead>
|
|
79
|
+
<tbody>
|
|
80
|
+
<tr>
|
|
81
|
+
<td><code>getAllItems()</code></td>
|
|
82
|
+
<td><code>Item[]</code></td>
|
|
83
|
+
<td>Returns inventory items plus equipped items.</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td><code>getAllItemsExceptCurrent(current)</code></td>
|
|
87
|
+
<td><code>Item[]</code></td>
|
|
88
|
+
<td>Returns inventory and equipment items except the specified slot.</td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td><code>getHandWithItem(offhand?)</code></td>
|
|
92
|
+
<td><code>Item | null</code></td>
|
|
93
|
+
<td>Returns the item currently in the requested hand.</td>
|
|
94
|
+
</tr>
|
|
95
|
+
<tr>
|
|
96
|
+
<td><code>getHand(offhand = false)</code></td>
|
|
97
|
+
<td><code>"hand" | "off-hand"</code></td>
|
|
98
|
+
<td>Returns the correct equipment destination for a hand flag.</td>
|
|
99
|
+
</tr>
|
|
100
|
+
<tr>
|
|
101
|
+
<td><code>findItemByID(itemId, metadata?)</code></td>
|
|
102
|
+
<td><code>Item | null</code></td>
|
|
103
|
+
<td>Finds the first matching item by numeric ID and optional metadata.</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td><code>findItem(name, metadata?)</code></td>
|
|
107
|
+
<td><code>Item | null</code></td>
|
|
108
|
+
<td>Finds the first matching item by name and optional metadata.</td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td><code>has(name, metadata?)</code></td>
|
|
112
|
+
<td><code>boolean</code></td>
|
|
113
|
+
<td>Alias for a boolean item existence check.</td>
|
|
114
|
+
</tr>
|
|
115
|
+
<tr>
|
|
116
|
+
<td><code>equipItemRaw(item, dest)</code></td>
|
|
117
|
+
<td><code>Promise<boolean></code></td>
|
|
118
|
+
<td>Equips an item unless it is already in the destination slot.</td>
|
|
119
|
+
</tr>
|
|
120
|
+
<tr>
|
|
121
|
+
<td><code>customEquip(item, destination, retries = 1)</code></td>
|
|
122
|
+
<td><code>Promise<boolean></code></td>
|
|
123
|
+
<td>Retries equip and attempts to clear the cursor if the equip flow gets stuck.</td>
|
|
124
|
+
</tr>
|
|
125
|
+
</tbody>
|
|
126
|
+
</table>
|
|
127
|
+
|
|
128
|
+
<h2>Notes</h2>
|
|
129
|
+
|
|
130
|
+
<ul>
|
|
131
|
+
<li><code>findItemByID</code> and <code>findItem</code> only check metadata when the metadata argument is truthy.</li>
|
|
132
|
+
<li><code>equipmentSlots</code> omits off-hand on versions that do not support it.</li>
|
|
133
|
+
</ul>
|
|
134
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>MovementFunctions</h1>
|
|
3
|
+
<p><code>src/movementFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Movement and orientation helpers that keep Mineflayer's internal state and the client's rotation packets
|
|
8
|
+
in sync. This module is useful when you need a precise look packet, a synchronized look call, or a simple
|
|
9
|
+
packet-level teleport helper.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<h2>Methods</h2>
|
|
13
|
+
|
|
14
|
+
<table>
|
|
15
|
+
<thead>
|
|
16
|
+
<tr>
|
|
17
|
+
<th align="left">Method</th>
|
|
18
|
+
<th align="left">Returns</th>
|
|
19
|
+
<th align="left">Description</th>
|
|
20
|
+
</tr>
|
|
21
|
+
</thead>
|
|
22
|
+
<tbody>
|
|
23
|
+
<tr>
|
|
24
|
+
<td><code>lookSync(yaw, pitch, force = true, epsilon)</code></td>
|
|
25
|
+
<td><code>Promise<void></code></td>
|
|
26
|
+
<td>Calls <code>bot.look</code> and waits until the bot's rotation is actually synced.</td>
|
|
27
|
+
</tr>
|
|
28
|
+
<tr>
|
|
29
|
+
<td><code>lookAtSync(pos, force = true, epsilon)</code></td>
|
|
30
|
+
<td><code>Promise<void></code></td>
|
|
31
|
+
<td>Computes yaw and pitch from a position and then runs <code>lookSync</code>.</td>
|
|
32
|
+
</tr>
|
|
33
|
+
<tr>
|
|
34
|
+
<td><code>forceLook(yaw, pitch, update = false, onGround?)</code></td>
|
|
35
|
+
<td><code>void</code></td>
|
|
36
|
+
<td>Sends a raw look packet directly to the client connection.</td>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr>
|
|
39
|
+
<td><code>forceLookAt(pos, update = false, onGround?)</code></td>
|
|
40
|
+
<td><code>void</code></td>
|
|
41
|
+
<td>Computes a look direction from a position and sends the packet directly.</td>
|
|
42
|
+
</tr>
|
|
43
|
+
<tr>
|
|
44
|
+
<td><code>lazyTeleport(endPos, steps = 1, update = false)</code></td>
|
|
45
|
+
<td><code>void</code></td>
|
|
46
|
+
<td>Walks through a sequence of position packets toward the destination.</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</tbody>
|
|
49
|
+
</table>
|
|
50
|
+
|
|
51
|
+
<h2>Behavior Notes</h2>
|
|
52
|
+
|
|
53
|
+
<ul>
|
|
54
|
+
<li>The constructor listens for <code>spawn</code> and <code>move</code> events to track the last sent rotation.</li>
|
|
55
|
+
<li><code>lookSync</code> waits for the bot's state to match the requested yaw and pitch before resolving.</li>
|
|
56
|
+
<li><code>lazyTeleport</code> stops if a sampled block is missing, which keeps it from blindly walking into unloaded space.</li>
|
|
57
|
+
</ul>
|
|
58
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>PredictiveFunctions</h1>
|
|
3
|
+
<p><code>src/predictiveFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Explosion-damage prediction helpers backed by a predictive world overlay. This module is geared toward
|
|
8
|
+
estimating damage against the bot or another entity without needing to wait for live-world updates.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>State</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Property</th>
|
|
17
|
+
<th align="left">Type</th>
|
|
18
|
+
<th align="left">Purpose</th>
|
|
19
|
+
</tr>
|
|
20
|
+
</thead>
|
|
21
|
+
<tbody>
|
|
22
|
+
<tr>
|
|
23
|
+
<td><code>world</code></td>
|
|
24
|
+
<td><code>PredictiveWorld</code></td>
|
|
25
|
+
<td>Overlay world used for simulated block placement and removal.</td>
|
|
26
|
+
</tr>
|
|
27
|
+
</tbody>
|
|
28
|
+
</table>
|
|
29
|
+
|
|
30
|
+
<h2>Methods</h2>
|
|
31
|
+
|
|
32
|
+
<table>
|
|
33
|
+
<thead>
|
|
34
|
+
<tr>
|
|
35
|
+
<th align="left">Method</th>
|
|
36
|
+
<th align="left">Returns</th>
|
|
37
|
+
<th align="left">Description</th>
|
|
38
|
+
</tr>
|
|
39
|
+
</thead>
|
|
40
|
+
<tbody>
|
|
41
|
+
<tr>
|
|
42
|
+
<td><code>getDamageWithEffects(damage, effects)</code></td>
|
|
43
|
+
<td><code>number</code></td>
|
|
44
|
+
<td>Applies resistance-style potion effects to incoming damage.</td>
|
|
45
|
+
</tr>
|
|
46
|
+
<tr>
|
|
47
|
+
<td><code>placeBlocks(blocks)</code></td>
|
|
48
|
+
<td><code>void</code></td>
|
|
49
|
+
<td>Adds predicted blocks to the overlay world.</td>
|
|
50
|
+
</tr>
|
|
51
|
+
<tr>
|
|
52
|
+
<td><code>removePredictedBlocks(positions, force = false)</code></td>
|
|
53
|
+
<td><code>void</code></td>
|
|
54
|
+
<td>Removes predicted blocks from the overlay world.</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<td><code>selfExplosionDamage(sourcePos, power, rawDamages = false)</code></td>
|
|
58
|
+
<td><code>number</code></td>
|
|
59
|
+
<td>Estimates explosion damage dealt to the bot.</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><code>getExplosionDamage(targetEntity, sourcePos, power, rawDamages = false)</code></td>
|
|
63
|
+
<td><code>number</code></td>
|
|
64
|
+
<td>Estimates explosion damage dealt to another entity.</td>
|
|
65
|
+
</tr>
|
|
66
|
+
</tbody>
|
|
67
|
+
</table>
|
|
68
|
+
|
|
69
|
+
<h2>Notes</h2>
|
|
70
|
+
|
|
71
|
+
<ul>
|
|
72
|
+
<li>Damage calculations are version-aware for armor and effect indexes.</li>
|
|
73
|
+
<li>Raw damage mode skips the post-processing modifiers that depend on armor, enchantments, and effects.</li>
|
|
74
|
+
<li>The module samples exposure through raycasts, so results are only as exact as the current world and overlay state.</li>
|
|
75
|
+
</ul>
|
|
76
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>RayTraceFunctions</h1>
|
|
3
|
+
<p><code>src/rayTracingFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Ray tracing helpers for blocks and entities. These methods combine world raycasts with AABB checks so you
|
|
8
|
+
can identify the hit target, hit face, and intersection point.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>Types</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Type</th>
|
|
17
|
+
<th align="left">Meaning</th>
|
|
18
|
+
</tr>
|
|
19
|
+
</thead>
|
|
20
|
+
<tbody>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>EntityRaycastReturn</code></td>
|
|
23
|
+
<td>A block or entity augmented with <code>intersect</code> and <code>face</code>.</td>
|
|
24
|
+
</tr>
|
|
25
|
+
</tbody>
|
|
26
|
+
</table>
|
|
27
|
+
|
|
28
|
+
<h2>Methods</h2>
|
|
29
|
+
|
|
30
|
+
<table>
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
<th align="left">Method</th>
|
|
34
|
+
<th align="left">Returns</th>
|
|
35
|
+
<th align="left">Description</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr>
|
|
40
|
+
<td><code>entityRaytrace(startPos, dir, maxDistance = 3.5, matcher?)</code></td>
|
|
41
|
+
<td><code>EntityRaycastReturn | null</code></td>
|
|
42
|
+
<td>Raytraces against loaded entities after building AABBs from the bot's entity list.</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td><code>entityRaytraceRaw(startPos, dir, aabbMap, maxDistance = 3.5, matcher?)</code></td>
|
|
46
|
+
<td><code>EntityRaycastReturn | null</code></td>
|
|
47
|
+
<td>Low-level entity raytrace that accepts a prepared AABB map.</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td><code>entityAtEntityCursor(entity, maxDistance = 3.5)</code></td>
|
|
51
|
+
<td><code>Entity | null</code></td>
|
|
52
|
+
<td>Returns the entity under another entity's cursor direction, if any.</td>
|
|
53
|
+
</tr>
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
56
|
+
|
|
57
|
+
<h2>Notes</h2>
|
|
58
|
+
|
|
59
|
+
<ul>
|
|
60
|
+
<li>Entity raytracing first performs a world raycast and then compares against entity hitboxes.</li>
|
|
61
|
+
<li>The returned object is augmented in-place with <code>intersect</code> and <code>face</code> when a hit is found.</li>
|
|
62
|
+
</ul>
|
|
63
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>RaycastIterator</h1>
|
|
3
|
+
<p><code>src/calcs/iterators.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Iterator for stepping through world blocks along a ray. This is the low-level traversal primitive used by
|
|
8
|
+
the raycast and intercept helpers.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>Related Export</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Export</th>
|
|
17
|
+
<th align="left">Description</th>
|
|
18
|
+
</tr>
|
|
19
|
+
</thead>
|
|
20
|
+
<tbody>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>BlockFace</code></td>
|
|
23
|
+
<td>Enum describing which face was crossed or intersected.</td>
|
|
24
|
+
</tr>
|
|
25
|
+
</tbody>
|
|
26
|
+
</table>
|
|
27
|
+
|
|
28
|
+
<h2>Methods</h2>
|
|
29
|
+
|
|
30
|
+
<table>
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
<th align="left">Method</th>
|
|
34
|
+
<th align="left">Returns</th>
|
|
35
|
+
<th align="left">Description</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr>
|
|
40
|
+
<td><code>intersect(shapes, offset)</code></td>
|
|
41
|
+
<td><code>Intersection | null</code></td>
|
|
42
|
+
<td>Checks the current ray against a list of translated block or entity shapes.</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td><code>next()</code></td>
|
|
46
|
+
<td><code>{ x; y; z; face } | null</code></td>
|
|
47
|
+
<td>Advances to the next traversed block along the ray.</td>
|
|
48
|
+
</tr>
|
|
49
|
+
</tbody>
|
|
50
|
+
</table>
|
|
51
|
+
|
|
52
|
+
<h2>Notes</h2>
|
|
53
|
+
|
|
54
|
+
<ul>
|
|
55
|
+
<li>Construct the iterator with a start position, direction vector, and maximum distance.</li>
|
|
56
|
+
<li><code>intersect</code> reports the first matching shape hit for the current cell.</li>
|
|
57
|
+
</ul>
|
|
58
|
+
|
package/docs/static.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Static Utilities</h1>
|
|
3
|
+
<p><code>src/static/*</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Public utility namespaces and helpers exported from the package root.
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<h2>AABBUtils</h2>
|
|
11
|
+
|
|
12
|
+
<table>
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<th align="left">Helper</th>
|
|
16
|
+
<th align="left">Description</th>
|
|
17
|
+
</tr>
|
|
18
|
+
</thead>
|
|
19
|
+
<tbody>
|
|
20
|
+
<tr>
|
|
21
|
+
<td><code>getBlockAABB(block, height = 1)</code></td>
|
|
22
|
+
<td>Creates a world-space AABB for a block.</td>
|
|
23
|
+
</tr>
|
|
24
|
+
<tr>
|
|
25
|
+
<td><code>getBlockPosAABB(blockPos, height = 1)</code></td>
|
|
26
|
+
<td>Creates an AABB from a block position vector.</td>
|
|
27
|
+
</tr>
|
|
28
|
+
<tr>
|
|
29
|
+
<td><code>getEntityAABB(entity)</code></td>
|
|
30
|
+
<td>Returns a version-aware AABB for an entity.</td>
|
|
31
|
+
</tr>
|
|
32
|
+
<tr>
|
|
33
|
+
<td><code>getPlayerAABB(entity)</code></td>
|
|
34
|
+
<td>Creates a player-shaped AABB and translates it to the entity position.</td>
|
|
35
|
+
</tr>
|
|
36
|
+
<tr>
|
|
37
|
+
<td><code>getPlayerAABBRaw(position, height = 1.8)</code></td>
|
|
38
|
+
<td>Creates a player-shaped AABB from a raw position.</td>
|
|
39
|
+
</tr>
|
|
40
|
+
<tr>
|
|
41
|
+
<td><code>getEntityAABBRaw(entity)</code></td>
|
|
42
|
+
<td>Creates an entity AABB from raw position, height, and width values.</td>
|
|
43
|
+
</tr>
|
|
44
|
+
</tbody>
|
|
45
|
+
</table>
|
|
46
|
+
|
|
47
|
+
<h2>MathUtils</h2>
|
|
48
|
+
|
|
49
|
+
<table>
|
|
50
|
+
<thead>
|
|
51
|
+
<tr>
|
|
52
|
+
<th align="left">Helper</th>
|
|
53
|
+
<th align="left">Description</th>
|
|
54
|
+
</tr>
|
|
55
|
+
</thead>
|
|
56
|
+
<tbody>
|
|
57
|
+
<tr>
|
|
58
|
+
<td><code>toNotchianYaw</code>, <code>toNotchianPitch</code></td>
|
|
59
|
+
<td>Convert radians to Notchian packet angles.</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><code>fromNotchianYaw</code>, <code>fromNotchianPitch</code></td>
|
|
63
|
+
<td>Convert Notchian packet angles back to radians.</td>
|
|
64
|
+
</tr>
|
|
65
|
+
<tr>
|
|
66
|
+
<td><code>euclideanMod</code></td>
|
|
67
|
+
<td>Positive modulo helper.</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td><code>pointToYawAndPitch(bot, point)</code></td>
|
|
71
|
+
<td>Returns the yaw and pitch needed to face a point.</td>
|
|
72
|
+
</tr>
|
|
73
|
+
<tr>
|
|
74
|
+
<td><code>dirToYawAndPitch(dir)</code></td>
|
|
75
|
+
<td>Returns yaw and pitch from a direction vector.</td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td><code>getYaw(origin, destination)</code></td>
|
|
79
|
+
<td>Returns the yaw between two points on the XZ plane.</td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><code>getViewDir(pitch, yaw)</code></td>
|
|
83
|
+
<td>Returns a unit view direction vector.</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td><code>yawPitchAndSpeedToDir(yaw, pitch, speed)</code></td>
|
|
87
|
+
<td>Returns a direction vector scaled by speed.</td>
|
|
88
|
+
</tr>
|
|
89
|
+
</tbody>
|
|
90
|
+
</table>
|
|
91
|
+
|
|
92
|
+
<h2>Task</h2>
|
|
93
|
+
|
|
94
|
+
<table>
|
|
95
|
+
<thead>
|
|
96
|
+
<tr>
|
|
97
|
+
<th align="left">Helper</th>
|
|
98
|
+
<th align="left">Description</th>
|
|
99
|
+
</tr>
|
|
100
|
+
</thead>
|
|
101
|
+
<tbody>
|
|
102
|
+
<tr>
|
|
103
|
+
<td><code>new Task()</code></td>
|
|
104
|
+
<td>Creates a cancellable promise wrapper.</td>
|
|
105
|
+
</tr>
|
|
106
|
+
<tr>
|
|
107
|
+
<td><code>Task.createTask()</code></td>
|
|
108
|
+
<td>Factory for a new task.</td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td><code>Task.createDoneTask()</code></td>
|
|
112
|
+
<td>Returns an already-finished task object.</td>
|
|
113
|
+
</tr>
|
|
114
|
+
</tbody>
|
|
115
|
+
</table>
|
|
116
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>UtilFunctions</h1>
|
|
3
|
+
<p><code>src/utilFunctions.ts</code></p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
The main wrapper exposed as <code>bot.util</code>. It bundles the feature-specific helper classes into a
|
|
8
|
+
single entry point so callers can work with one namespace instead of instantiating helpers manually.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h2>Constructor</h2>
|
|
12
|
+
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<th align="left">Signature</th>
|
|
17
|
+
<th align="left">Description</th>
|
|
18
|
+
</tr>
|
|
19
|
+
</thead>
|
|
20
|
+
<tbody>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><code>new UtilFunctions(bot)</code></td>
|
|
23
|
+
<td>Creates the helper bundle for a Mineflayer bot.</td>
|
|
24
|
+
</tr>
|
|
25
|
+
</tbody>
|
|
26
|
+
</table>
|
|
27
|
+
|
|
28
|
+
<h2>Properties</h2>
|
|
29
|
+
|
|
30
|
+
<table>
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
<th align="left">Property</th>
|
|
34
|
+
<th align="left">Type</th>
|
|
35
|
+
<th align="left">Purpose</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr>
|
|
40
|
+
<td><code>inv</code></td>
|
|
41
|
+
<td><code>InventoryFunctions</code></td>
|
|
42
|
+
<td>Inventory helpers.</td>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td><code>move</code></td>
|
|
46
|
+
<td><code>MovementFunctions</code></td>
|
|
47
|
+
<td>Movement and look synchronization helpers.</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<td><code>entity</code></td>
|
|
51
|
+
<td><code>EntityFunctions</code></td>
|
|
52
|
+
<td>Entity math and metadata helpers.</td>
|
|
53
|
+
</tr>
|
|
54
|
+
<tr>
|
|
55
|
+
<td><code>predict</code></td>
|
|
56
|
+
<td><code>PredictiveFunctions</code></td>
|
|
57
|
+
<td>Damage prediction and simulated world helpers.</td>
|
|
58
|
+
</tr>
|
|
59
|
+
<tr>
|
|
60
|
+
<td><code>filters</code></td>
|
|
61
|
+
<td><code>FilterFunctions</code></td>
|
|
62
|
+
<td>Nearest entity filtering helpers.</td>
|
|
63
|
+
</tr>
|
|
64
|
+
<tr>
|
|
65
|
+
<td><code>raytrace</code></td>
|
|
66
|
+
<td><code>RayTraceFunctions</code></td>
|
|
67
|
+
<td>Block and entity ray tracing helpers.</td>
|
|
68
|
+
</tr>
|
|
69
|
+
</tbody>
|
|
70
|
+
</table>
|
|
71
|
+
|
|
72
|
+
<h2>Methods</h2>
|
|
73
|
+
|
|
74
|
+
<table>
|
|
75
|
+
<thead>
|
|
76
|
+
<tr>
|
|
77
|
+
<th align="left">Method</th>
|
|
78
|
+
<th align="left">Returns</th>
|
|
79
|
+
<th align="left">Description</th>
|
|
80
|
+
</tr>
|
|
81
|
+
</thead>
|
|
82
|
+
<tbody>
|
|
83
|
+
<tr>
|
|
84
|
+
<td><code>getViewDir()</code></td>
|
|
85
|
+
<td><code>Vec3</code></td>
|
|
86
|
+
<td>Returns the bot's current look direction as a vector.</td>
|
|
87
|
+
</tr>
|
|
88
|
+
</tbody>
|
|
89
|
+
</table>
|
|
90
|
+
|
|
91
|
+
<h2>Example</h2>
|
|
92
|
+
|
|
93
|
+
<pre><code class="language-ts">inject(bot);
|
|
94
|
+
|
|
95
|
+
const viewDir = bot.util.getViewDir();
|
|
96
|
+
const nearestPlayer = bot.util.filters.getNearestEntity(
|
|
97
|
+
(entity) => entity.type === "player"
|
|
98
|
+
);</code></pre>
|
|
99
|
+
|
package/lib/calcs/intercept.js
CHANGED
|
@@ -36,7 +36,7 @@ class InterceptFunctions {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
pos = iter.next();
|
|
39
|
-
if (
|
|
39
|
+
if ((iterations.length >= 1000 && iterations.length % 1000 === 0)) {
|
|
40
40
|
// console.trace("too much");
|
|
41
41
|
console.log(from, direction, range, iterations, block, position, pos);
|
|
42
42
|
}
|
package/lib/movementFunctions.js
CHANGED
|
@@ -32,6 +32,10 @@ function deltaRad(a, b) {
|
|
|
32
32
|
delta -= tau;
|
|
33
33
|
return delta;
|
|
34
34
|
}
|
|
35
|
+
function getHorizontalCollision(bot) {
|
|
36
|
+
var _a;
|
|
37
|
+
return !!((_a = bot.entity.horizontalCollision) !== null && _a !== void 0 ? _a : bot.entity.isCollidedHorizontally);
|
|
38
|
+
}
|
|
35
39
|
class MovementFunctions {
|
|
36
40
|
constructor(bot) {
|
|
37
41
|
this.bot = bot;
|
|
@@ -39,7 +43,7 @@ class MovementFunctions {
|
|
|
39
43
|
this.lastSentPitch = NaN;
|
|
40
44
|
this.pendingLookSync = null;
|
|
41
45
|
this.trackSentRotation = this.captureSentRotation.bind(this);
|
|
42
|
-
this.
|
|
46
|
+
this.bot.on("spawn", this.trackSentRotation); // should clear the sent rotation when the bot respawns,
|
|
43
47
|
this.bot.on("move", this.trackSentRotation);
|
|
44
48
|
}
|
|
45
49
|
captureSentRotation() {
|
|
@@ -83,8 +87,10 @@ class MovementFunctions {
|
|
|
83
87
|
const activeRequest = { yaw, pitch, epsilon };
|
|
84
88
|
const sync = this.waitForLookSync(yaw, pitch, epsilon);
|
|
85
89
|
try {
|
|
90
|
+
console.time("lookSync");
|
|
86
91
|
yield this.bot.look(yaw, pitch, force);
|
|
87
92
|
yield sync;
|
|
93
|
+
console.timeEnd("lookSync");
|
|
88
94
|
}
|
|
89
95
|
catch (error) {
|
|
90
96
|
if (((_a = this.pendingLookSync) === null || _a === void 0 ? void 0 : _a.yaw) === activeRequest.yaw &&
|
|
@@ -103,8 +109,13 @@ class MovementFunctions {
|
|
|
103
109
|
});
|
|
104
110
|
}
|
|
105
111
|
forceLook(yaw, pitch, update = false, onGround) {
|
|
106
|
-
const
|
|
107
|
-
|
|
112
|
+
const packet = { yaw: static_1.MathUtils.toNotchianYaw(yaw), pitch: static_1.MathUtils.toNotchianPitch(pitch) };
|
|
113
|
+
packet.onGround = onGround !== null && onGround !== void 0 ? onGround : this.bot.entity.onGround;
|
|
114
|
+
packet.flags = {
|
|
115
|
+
onGround: packet.onGround,
|
|
116
|
+
hasHorizontalCollision: getHorizontalCollision(this.bot),
|
|
117
|
+
};
|
|
118
|
+
this.bot._client.write("look", packet);
|
|
108
119
|
if (update) {
|
|
109
120
|
this.bot.look(yaw, pitch, true);
|
|
110
121
|
this.bot.entity.pitch = pitch;
|
|
@@ -113,13 +124,7 @@ class MovementFunctions {
|
|
|
113
124
|
}
|
|
114
125
|
forceLookAt(pos, update = false, onGround) {
|
|
115
126
|
const { yaw, pitch } = static_1.MathUtils.pointToYawAndPitch(this.bot, pos);
|
|
116
|
-
|
|
117
|
-
this.bot._client.write("look", Object.assign(Object.assign({}, nyp), { onGround: onGround !== null && onGround !== void 0 ? onGround : this.bot.entity.onGround }));
|
|
118
|
-
if (update) {
|
|
119
|
-
this.bot.look(yaw, pitch, true);
|
|
120
|
-
this.bot.entity.pitch = pitch;
|
|
121
|
-
this.bot.entity.yaw = yaw;
|
|
122
|
-
}
|
|
127
|
+
return this.forceLook(yaw, pitch, update, onGround);
|
|
123
128
|
}
|
|
124
129
|
lazyTeleport(endPos, steps = 1, update = false) {
|
|
125
130
|
for (const pos of interpolate(this.bot.entity.position, endPos, steps)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxg-org/mineflayer-util-plugin",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "mineflayer utils for NextGEN mineflayer plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mineflayer",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"types": "lib/index.d.ts",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^17.0.4",
|
|
19
|
-
"mineflayer": "
|
|
19
|
+
"mineflayer": "link:C:\\Users\\owner\\Documents\\github\\mineflayer",
|
|
20
20
|
"prismarine-block": "^1.23.0",
|
|
21
21
|
"prismarine-entity": "^2.6.0",
|
|
22
22
|
"prismarine-item": "^1.18.0",
|