Commit 23f60d2
Improve test reliability: reconnect, retry, server console, packet fix (#3873)
* Fix chatAddPattern test to filter by expected username
The test used once(bot, 'chat') which matches ANY chat message.
Admin messages from /give or /clear in resetState could arrive and
match before the test's tellraw. Now filters for username === 'U9G'.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Use server console for clearInventory give and clear
Now that chatAddPattern test filters by username, server console
admin messages no longer interfere. Server console commands are
more reliable than bot.chat — they work even if the bot is in a
bad state.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Use server console for teleport in resetState
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Reduce resetState operation timeout from 20s to 5s
Operations like gamemode change, clear inventory, and teleport
complete in <1s. A 5s timeout fails faster and lets retries
kick in sooner instead of waiting 20s per failure.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Run example tests last to limit blast radius
Tests that spawn child processes (exampleBee, exampleDigger,
exampleInventory) can crash and disconnect the bot, cascading
to fail all subsequent tests. Running them last ensures they
can only affect each other, not the main test suite.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Auto-reconnect bot after disconnect in runTest
When a test crashes and disconnects the bot (e.g. exampleDigger
child process failure), subsequent tests would cascade-fail.
Now detects !bot.entity and reconnects with a fresh bot instance
before running the next test.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix clearInventory: use bot.chat for /give, server console for /clear
Server console /give doesn't trigger updateSlot on 1.21.9+.
Use bot.chat('/give @A stone 1') for the give (works on all versions)
and wrap.writeServer for /clear (more reliable than chat for clear).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add set_player_inventory handler for 1.21.9+ server commands
MC 1.21.9+ uses a new set_player_inventory packet for server-initiated
inventory changes (e.g. console /give) instead of set_slot. Mineflayer
had no handler for it, so updateSlot events never fired.
This fixes server console /give on 1.21.9+ and also benefits any
user code that relies on inventory updates from server commands.
Also reverts clearInventory to use server console for both give and
clear now that the packet handler is in place.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Trigger CI with set_player_inventory handler
* Fix clearInventory: use bot.chat for /give on all versions
Server console /give doesn't send inventory update packets to the
client on 1.21.9+ (no set_slot nor set_player_inventory). The item
gets added server-side but the client never knows about it.
Use bot.chat('/give @A stone 1') which goes through the player's
command executor and always sends proper set_slot packets.
Keep server console for /clear (which does send set_slot reliably).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Increase /give timeout to 10s for loaded CI runners
The 5s timeout is fine for server console commands but bot.chat
goes through the network stack and can be slower on loaded runners
with 4 MC servers sharing one container.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix clearInventory: use bot.chat for /clear too on 1.21.9+
Server console /clear also doesn't send proper inventory packets on
1.21.9+. Use bot.chat for both /give and /clear, waiting for the
chat message confirmation for /clear.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: rom1504 <rom1504@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7af5e2c commit 23f60d2
4 files changed
Lines changed: 54 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
731 | 737 | | |
732 | 738 | | |
733 | 739 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
127 | 147 | | |
128 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
129 | 152 | | |
130 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
131 | 161 | | |
132 | 162 | | |
133 | 163 | | |
| |||
140 | 170 | | |
141 | 171 | | |
142 | 172 | | |
143 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
144 | 178 | | |
145 | 179 | | |
146 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
148 | 149 | | |
149 | | - | |
| 150 | + | |
150 | 151 | | |
151 | | - | |
| 152 | + | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| |||
0 commit comments