mineflayer 4.36.0 → 4.37.0
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 +39 -4
- package/docs/history.md +8 -0
- package/lib/plugins/inventory.js +6 -0
- package/lib/plugins/physics.js +5 -0
- package/package.json +1 -1
package/.github/workflows/ci.yml
CHANGED
|
@@ -32,15 +32,21 @@ jobs:
|
|
|
32
32
|
- id: set-matrix
|
|
33
33
|
run: |
|
|
34
34
|
node -e "
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const v = require('./lib/version').testedVersions;
|
|
36
|
+
const groups = [];
|
|
37
|
+
const SIZE = 4;
|
|
38
|
+
for (let i = 0; i < v.length; i += SIZE) {
|
|
39
|
+
groups.push({ versions: v.slice(i, i + SIZE).join(' ') });
|
|
40
|
+
}
|
|
41
|
+
console.log('matrix='+JSON.stringify({'include': groups}))
|
|
37
42
|
" >> $GITHUB_OUTPUT
|
|
38
43
|
|
|
39
44
|
MinecraftServer:
|
|
40
45
|
needs: PrepareSupportedVersions
|
|
41
46
|
runs-on: ubuntu-latest
|
|
47
|
+
name: MC ${{ matrix.versions }}
|
|
42
48
|
strategy:
|
|
43
|
-
matrix: ${{fromJson(needs.PrepareSupportedVersions.outputs.matrix)}}
|
|
49
|
+
matrix: ${{ fromJson(needs.PrepareSupportedVersions.outputs.matrix) }}
|
|
44
50
|
fail-fast: false
|
|
45
51
|
|
|
46
52
|
steps:
|
|
@@ -58,4 +64,33 @@ jobs:
|
|
|
58
64
|
run: npm install
|
|
59
65
|
|
|
60
66
|
- name: Start Tests
|
|
61
|
-
run:
|
|
67
|
+
run: |
|
|
68
|
+
exit_code=0
|
|
69
|
+
pids=""
|
|
70
|
+
for v in ${{ matrix.versions }}; do
|
|
71
|
+
npm run mocha_test -- --retries 3 -g "${v}v" > "test-${v}.log" 2>&1 &
|
|
72
|
+
pids="$pids $!"
|
|
73
|
+
done
|
|
74
|
+
for pid in $pids; do
|
|
75
|
+
wait $pid || exit_code=$?
|
|
76
|
+
done
|
|
77
|
+
# Print passing versions first, then failing versions last
|
|
78
|
+
for v in ${{ matrix.versions }}; do
|
|
79
|
+
if ! grep -q "failing" "test-${v}.log"; then
|
|
80
|
+
echo ""
|
|
81
|
+
echo "=========================================="
|
|
82
|
+
echo " Results for Minecraft ${v}"
|
|
83
|
+
echo "=========================================="
|
|
84
|
+
cat "test-${v}.log"
|
|
85
|
+
fi
|
|
86
|
+
done
|
|
87
|
+
for v in ${{ matrix.versions }}; do
|
|
88
|
+
if grep -q "failing" "test-${v}.log"; then
|
|
89
|
+
echo ""
|
|
90
|
+
echo "=========================================="
|
|
91
|
+
echo " FAILED: Minecraft ${v}"
|
|
92
|
+
echo "=========================================="
|
|
93
|
+
cat "test-${v}.log"
|
|
94
|
+
fi
|
|
95
|
+
done
|
|
96
|
+
exit $exit_code
|
package/docs/history.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## 4.35.0
|
|
2
2
|
|
|
3
|
+
## 4.37.0
|
|
4
|
+
* [CI: print failed version logs last for easy debugging (#3876)](https://github.com/PrismarineJS/mineflayer/commit/56efbcde16343576533eaa7a08e85b785ae847cd) (thanks @rom1504)
|
|
5
|
+
* [Fix nether test reliability and add set_player_inventory handler (#3874)](https://github.com/PrismarineJS/mineflayer/commit/fd03f0a83e00229344b0624ce5ace9e0303599f3) (thanks @rom1504)
|
|
6
|
+
* [Improve test reliability: reconnect, retry, server console, packet fix (#3873)](https://github.com/PrismarineJS/mineflayer/commit/23f60d2132d49c08d936073d215466a825045933) (thanks @rom1504)
|
|
7
|
+
* [Improve test reliability: server console gamemode, retries, NaN guard (#3871)](https://github.com/PrismarineJS/mineflayer/commit/7af5e2ccf2f7ed1240ea792cb425a20e669618c2) (thanks @rom1504)
|
|
8
|
+
* [CI: run 4 MC versions per job to halve runner pressure (#3870)](https://github.com/PrismarineJS/mineflayer/commit/85a164d86e2b8bac996946ef6fb46d800861c82f) (thanks @rom1504)
|
|
9
|
+
* [Speed up tests: remove sleep(1000) in resetState (#3869)](https://github.com/PrismarineJS/mineflayer/commit/81ecd72bafafc711ee2bc32b19d64f2bd897c4fb) (thanks @rom1504)
|
|
10
|
+
|
|
3
11
|
## 4.36.0
|
|
4
12
|
* [Update CI to Node 24 (#3861)](https://github.com/PrismarineJS/mineflayer/commit/3b05f83d536adb31103c811f7093361ff35449a1) (thanks @rom1504)
|
|
5
13
|
* [Fix publish condition for npm-publish v4 (#3858)](https://github.com/PrismarineJS/mineflayer/commit/ea663478fa1cb4f602735675aebd0c8459c7576d) (thanks @rom1504)
|
package/lib/plugins/inventory.js
CHANGED
|
@@ -728,6 +728,12 @@ function inject (bot, { hideErrors }) {
|
|
|
728
728
|
const newItem = Item.fromNotch(packet.item)
|
|
729
729
|
bot._setSlot(packet.slot, newItem, window)
|
|
730
730
|
})
|
|
731
|
+
// 1.21.9+ uses set_player_inventory for server-initiated inventory changes
|
|
732
|
+
// (e.g. console /give) instead of set_slot
|
|
733
|
+
bot._client.on('set_player_inventory', (packet) => {
|
|
734
|
+
const newItem = Item.fromNotch(packet.contents)
|
|
735
|
+
bot._setSlot(packet.slotId, newItem)
|
|
736
|
+
})
|
|
731
737
|
bot._client.on('window_items', (packet) => {
|
|
732
738
|
const window = packet.windowId === 0 ? bot.inventory : bot.currentWindow
|
|
733
739
|
if (!window || window.id !== packet.windowId) {
|
package/lib/plugins/physics.js
CHANGED
|
@@ -76,6 +76,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
function tickPhysics (now) {
|
|
79
|
+
if (!bot.entity?.position || !Number.isFinite(bot.entity.position.x)) return // entity not ready
|
|
79
80
|
if (bot.blockAt(bot.entity.position) == null) return // check if chunk is unloaded
|
|
80
81
|
if (bot.physicsEnabled && shouldUsePhysics) {
|
|
81
82
|
physics.simulatePlayer(new PlayerState(bot, controlState), world).apply(bot)
|
|
@@ -99,6 +100,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
99
100
|
|
|
100
101
|
function sendPacketPosition (position, onGround) {
|
|
101
102
|
// sends data, no logic
|
|
103
|
+
if (!Number.isFinite(position.x) || !Number.isFinite(position.y) || !Number.isFinite(position.z)) return
|
|
102
104
|
const oldPos = new Vec3(lastSent.x, lastSent.y, lastSent.z)
|
|
103
105
|
lastSent.x = position.x
|
|
104
106
|
lastSent.y = position.y
|
|
@@ -122,6 +124,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
122
124
|
|
|
123
125
|
function sendPacketPositionAndLook (position, yaw, pitch, onGround) {
|
|
124
126
|
// sends data, no logic
|
|
127
|
+
if (!Number.isFinite(position.x) || !Number.isFinite(position.y) || !Number.isFinite(position.z)) return
|
|
125
128
|
const oldPos = new Vec3(lastSent.x, lastSent.y, lastSent.z)
|
|
126
129
|
lastSent.x = position.x
|
|
127
130
|
lastSent.y = position.y
|
|
@@ -153,6 +156,8 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
153
156
|
function updatePosition (now) {
|
|
154
157
|
// Only send updates for 20 ticks after death
|
|
155
158
|
if (isEntityRemoved()) return
|
|
159
|
+
// Don't send position with invalid coordinates (NaN after death)
|
|
160
|
+
if (!Number.isFinite(bot.entity.position.x)) return
|
|
156
161
|
|
|
157
162
|
// Increment the yaw in baby steps so that notchian clients (not the server) can keep up.
|
|
158
163
|
const dYaw = deltaYaw(bot.entity.yaw, lastSentYaw)
|