mineflayer 4.30.0 → 4.32.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/docs/history.md +7 -0
- package/docs/update_to_1_21_5.md +342 -0
- package/lib/loader.js +4 -0
- package/lib/plugins/bed.js +4 -3
- package/lib/plugins/entities.js +2 -0
- package/lib/plugins/game.js +2 -2
- package/lib/plugins/physics.js +23 -8
- package/lib/plugins/rain.js +6 -4
- package/lib/plugins/team.js +52 -39
- package/lib/version.js +1 -1
- package/package.json +5 -5
package/docs/history.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 4.32.0
|
|
2
|
+
* [1.21.6 (#3713)](https://github.com/PrismarineJS/mineflayer/commit/01f537c394fc78bf2e765b28a8b24a30c1d1fd2e) (thanks @extremeheat)
|
|
3
|
+
* [Fix knockback physics crash (#3715)](https://github.com/PrismarineJS/mineflayer/commit/e3f89d17418ece9e9fac4b111d8243dfe1a5d376) (thanks @Omena0)
|
|
4
|
+
|
|
5
|
+
## 4.31.0
|
|
6
|
+
* [Cursor 1 21 5 (#3701)](https://github.com/PrismarineJS/mineflayer/commit/8770129d26a85f9b077d2a8969d45436fa09c3f3) (thanks @rom1504)
|
|
7
|
+
|
|
1
8
|
## 4.30.0
|
|
2
9
|
* [Update player_info handling (#3689)](https://github.com/PrismarineJS/mineflayer/commit/3f2fd6d393bc39167410df5a292759c93c9b249f) (thanks @extremeheat)
|
|
3
10
|
* [Bump @types/node from 22.15.33 to 24.0.6 (#3686)](https://github.com/PrismarineJS/mineflayer/commit/12e50a2e2d0a921d075ebae8aa835437672a2b29) (thanks @dependabot[bot])
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Mineflayer 1.21.5 Support Plan
|
|
2
|
+
|
|
3
|
+
## 🚩 Latest Progress (July 2025)
|
|
4
|
+
|
|
5
|
+
- ✅ **Chunk loading/parsing is now fixed** in both `node_modules` and the local `prismarine-chunk` repo. The fix was applied to `PaletteChunkSection.js` and `BitArrayNoSpan.js`.
|
|
6
|
+
- 🔗 **Local development uses `npm link` to the local prismarine-chunk repo** for immediate testing of fixes.
|
|
7
|
+
- 🛠️ **BitArrayNoSpan.js** now validates the buffer size and logs a warning if it is invalid (e.g., Infinity), preventing crashes.
|
|
8
|
+
- 🤖 **The bot can now spawn and interact with the world** in 1.21.5. Chunk parsing errors are resolved.
|
|
9
|
+
- ✅ **12 tests pass** for 1.21.5, confirming core protocol and chunk logic is working.
|
|
10
|
+
- ❌ **4 tests fail**, but these are due to higher-level Mineflayer/game logic (timeouts, creative set slot, etc.), not chunk/protocol errors.
|
|
11
|
+
- 🚧 **Current blockers:**
|
|
12
|
+
- Creative set slot protocol changes (UntrustedSlot)
|
|
13
|
+
- declare_commands packet parsing (PartialReadError)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Current Status
|
|
18
|
+
|
|
19
|
+
As of July 2025, Mineflayer has partial 1.21.5 support with several critical issues remaining. The version is already listed in `testedVersions` but tests are failing due to protocol changes in 1.21.5.
|
|
20
|
+
|
|
21
|
+
## Key Issues Identified
|
|
22
|
+
|
|
23
|
+
Based on the analysis of pull requests and issues, the main problems for 1.21.5 support are:
|
|
24
|
+
|
|
25
|
+
### 1. Chunk Protocol Changes (✅ FIXED)
|
|
26
|
+
- **Issue**: Network has small changes to chunk format where size is now auto-computed to save a byte
|
|
27
|
+
- **Status**: **RESOLVED** - Fixed size computation formula in prismarine-chunk
|
|
28
|
+
- **Fix Applied**: Changed from `Math.ceil(constants.BLOCK_SECTION_VOLUME * bitsPerValue / 64)` to `Math.ceil(constants.BLOCK_SECTION_VOLUME / Math.floor(64 / bitsPerValue))`
|
|
29
|
+
- **Impact**: Chunk loading now works correctly for 1.21.5
|
|
30
|
+
- **Files Modified**:
|
|
31
|
+
- `prismarine-chunk/src/pc/common/PaletteContainer.js` (both DirectPaletteContainer and IndirectPaletteContainer)
|
|
32
|
+
- **Dependencies**: Updated package.json to point to fixed prismarine-chunk branch
|
|
33
|
+
|
|
34
|
+
### 2. Creative Set Slot Packet Behavior
|
|
35
|
+
- **Issue**: Creative set slot packet behavior is the main breaking change (not working right now)
|
|
36
|
+
- **Status**: Critical issue affecting creative mode functionality
|
|
37
|
+
- **Impact**: `bot.creative.setInventorySlot()` fails
|
|
38
|
+
- **Location**: `lib/plugins/creative.js`
|
|
39
|
+
|
|
40
|
+
### 3. Item Format Changes
|
|
41
|
+
- **Issue**: New concepts of hashed items and unsecure items (related to components)
|
|
42
|
+
- **Status**: Protocol changes need investigation
|
|
43
|
+
- **Impact**: Item handling and inventory management
|
|
44
|
+
- **Dependencies**: minecraft-data and minecraft-protocol updates needed
|
|
45
|
+
|
|
46
|
+
### 4. Entity Metadata Changes
|
|
47
|
+
- **Issue**: Entity metadata may have changed
|
|
48
|
+
- **Status**: Could cause issues with various listeners in mineflayer
|
|
49
|
+
- **Impact**: Entity tracking and interaction
|
|
50
|
+
- **Location**: `lib/plugins/entities.js`
|
|
51
|
+
|
|
52
|
+
## Detailed Action Plan
|
|
53
|
+
|
|
54
|
+
### Phase 1: Dependency Updates and Investigation
|
|
55
|
+
|
|
56
|
+
#### 1.1 Investigate Chunk Protocol Issues
|
|
57
|
+
- **Task**: Manually dump and decode chunk packets to understand the new format
|
|
58
|
+
- **Tools**: Use packet analyzers or debug tools
|
|
59
|
+
- **Expected Outcome**: Identify exact changes in chunk size computation
|
|
60
|
+
- **Files to Modify**: `lib/plugins/blocks.js` (chunk handling)
|
|
61
|
+
|
|
62
|
+
#### 1.2 Analyze Creative Set Slot Issues
|
|
63
|
+
- **Task**: Debug creative set slot packet failures
|
|
64
|
+
- **Method**: Compare packet structure between 1.21.4 and 1.21.5
|
|
65
|
+
- **Files to Modify**: `lib/plugins/creative.js`
|
|
66
|
+
- **Test**: `test/externalTests/creative.js`
|
|
67
|
+
|
|
68
|
+
### Phase 2: Protocol Implementation
|
|
69
|
+
|
|
70
|
+
#### 2.1 Fix Chunk Loading
|
|
71
|
+
```javascript
|
|
72
|
+
// In lib/plugins/blocks.js
|
|
73
|
+
// Update chunk loading logic to handle auto-computed size
|
|
74
|
+
bot._client.on('map_chunk', (packet) => {
|
|
75
|
+
// Handle new chunk format with auto-computed size
|
|
76
|
+
// May need to adjust data parsing based on new format
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### 2.2 Fix Creative Set Slot
|
|
81
|
+
```javascript
|
|
82
|
+
// In lib/plugins/creative.js
|
|
83
|
+
// Update setInventorySlot to handle new packet format
|
|
84
|
+
async function setInventorySlot (slot, item, waitTimeout = 400) {
|
|
85
|
+
// Investigate and fix packet structure changes
|
|
86
|
+
// May need new packet format or different handling
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### 2.3 Update Item Handling
|
|
91
|
+
```javascript
|
|
92
|
+
// In lib/plugins/inventory.js
|
|
93
|
+
// Handle new hashed items and unsecure items concepts
|
|
94
|
+
// Update Item.fromNotch and Item.toNotch methods
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### 2.4 Fix Entity Metadata
|
|
98
|
+
```javascript
|
|
99
|
+
// In lib/plugins/entities.js
|
|
100
|
+
// Update entity metadata parsing for 1.21.5 changes
|
|
101
|
+
bot._client.on('entity_metadata', (packet) => {
|
|
102
|
+
// Handle new metadata format
|
|
103
|
+
})
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Phase 3: Testing and Validation
|
|
107
|
+
|
|
108
|
+
#### 3.1 Create 1.21.5 Specific Tests
|
|
109
|
+
```javascript
|
|
110
|
+
// Add to test/externalTests/
|
|
111
|
+
// Create tests that specifically validate 1.21.5 functionality
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### 3.2 Update Existing Tests
|
|
115
|
+
- **Task**: Fix failing tests for 1.21.5
|
|
116
|
+
- **Focus**: Creative mode, chunk loading, entity handling
|
|
117
|
+
- **Method**: Run `npm run mocha_test -- -g "mineflayer_external 1.21.5v"`
|
|
118
|
+
|
|
119
|
+
#### 3.3 Manual Testing
|
|
120
|
+
- **Task**: Test core functionality manually
|
|
121
|
+
- **Areas**: World loading, inventory management, entity interaction
|
|
122
|
+
- **Tools**: Use examples in `examples/` directory
|
|
123
|
+
|
|
124
|
+
### Phase 4: Documentation and Cleanup
|
|
125
|
+
|
|
126
|
+
#### 4.1 Update Documentation
|
|
127
|
+
- **Task**: Update README and API docs for 1.21.5
|
|
128
|
+
- **Files**: `docs/README.md`, `docs/api.md`
|
|
129
|
+
- **Content**: Document any new features or breaking changes
|
|
130
|
+
|
|
131
|
+
#### 4.2 Update Version Support
|
|
132
|
+
- **Task**: Ensure 1.21.5 is properly listed as supported
|
|
133
|
+
- **Files**: `lib/version.js`, `package.json`
|
|
134
|
+
|
|
135
|
+
## Analysis of Current Fix Status
|
|
136
|
+
|
|
137
|
+
### ✅ **Good News: Fix Already Implemented**
|
|
138
|
+
The [prismarine-chunk PR #289](https://github.com/PrismarineJS/prismarine-chunk/pull/289/files) has already implemented the 1.21.5 chunk protocol fix:
|
|
139
|
+
|
|
140
|
+
**Key Changes in PR #289:**
|
|
141
|
+
1. **Added `noSizePrefix` detection**: Uses `mcData.version['>=']('1.21.5')` to detect 1.21.5+
|
|
142
|
+
2. **Modified chunk reading**: All palette containers now handle the `noSizePrefix` option
|
|
143
|
+
3. **Dynamic size computation**: When `noSizePrefix` is true, size is computed as `Math.ceil(constants.BLOCK_SECTION_VOLUME * bitsPerValue / 64)`
|
|
144
|
+
|
|
145
|
+
### 🔍 **Current Status Check**
|
|
146
|
+
Mineflayer is already using the experimental branches:
|
|
147
|
+
- `prismarine-chunk`: `extremeheat/prismarine-chunk#pc1.21.5` ✅
|
|
148
|
+
- `minecraft-protocol`: `extremeheat/node-minecraft-protocol#pcp1.21.5` ✅
|
|
149
|
+
|
|
150
|
+
### ✅ **Chunk Loading Issue RESOLVED**
|
|
151
|
+
**FIXED**: The chunk loading issue has been resolved by correcting the size computation formula.
|
|
152
|
+
|
|
153
|
+
**Root Cause Analysis:**
|
|
154
|
+
1. ✅ **Fix is implemented**: `noSizePrefix` detection and logic is present in the code
|
|
155
|
+
2. ✅ **Version detection works**: `mcData.version['>=']('1.21.5')` returns `true` correctly
|
|
156
|
+
3. ✅ **Size computation fixed**: Changed from `Math.ceil(constants.BLOCK_SECTION_VOLUME * bitsPerValue / 64)` to `Math.ceil(constants.BLOCK_SECTION_VOLUME / Math.floor(64 / bitsPerValue))`
|
|
157
|
+
4. ✅ **Buffer reading works**: No more "Target offset is beyond the bounds of the internal SmartBuffer data" errors
|
|
158
|
+
|
|
159
|
+
**The Solution:**
|
|
160
|
+
The issue was in the `readBuffer` method in `PaletteContainer.js`. The formula needed to calculate the number of longs based on the actual BitArray logic used in the constructor.
|
|
161
|
+
|
|
162
|
+
## Current Test Status
|
|
163
|
+
|
|
164
|
+
### ✅ **Chunk Loading Fixed**
|
|
165
|
+
- **Status**: Chunk loading now works correctly for 1.21.5
|
|
166
|
+
- **Evidence**: No more "Target offset is beyond the bounds of the internal SmartBuffer data" errors
|
|
167
|
+
- **Next**: Focus on remaining test failures
|
|
168
|
+
|
|
169
|
+
### 🚨 **New Test Failures Identified**
|
|
170
|
+
After fixing chunk loading, new issues emerged:
|
|
171
|
+
|
|
172
|
+
1. **Test Setup Timeout**: "Event message did not fire within timeout of 5000ms" in "before each" hook for "bed"
|
|
173
|
+
2. **Server Shutdown Issues**: "Server shutdown took too long. Killing process."
|
|
174
|
+
3. **Potential Protocol Changes**: Other 1.21.5 protocol changes may be affecting test functionality
|
|
175
|
+
|
|
176
|
+
## Next Priority Issues
|
|
177
|
+
|
|
178
|
+
### 1. **Investigate Test Setup Failures** (High Priority)
|
|
179
|
+
- **Issue**: Tests are timing out during setup phase
|
|
180
|
+
- **Location**: `test/externalTests/plugins/testCommon.js:127:21` - `clearInventory` function
|
|
181
|
+
- **Possible Causes**:
|
|
182
|
+
- Creative set slot packet changes
|
|
183
|
+
- Inventory protocol changes
|
|
184
|
+
- Entity metadata changes
|
|
185
|
+
|
|
186
|
+
### 2. **Debug Creative Set Slot** (High Priority - PROTOCOL CHANGE IDENTIFIED)
|
|
187
|
+
- **Issue**: Creative mode functionality broken due to protocol change
|
|
188
|
+
- **Location**: `lib/plugins/creative.js`
|
|
189
|
+
- **Test**: `test/externalTests/creative.js`
|
|
190
|
+
- **Root Cause**: `set_creative_slot` packet changed from `Slot` to `UntrustedSlot` type
|
|
191
|
+
- **Key Changes**:
|
|
192
|
+
- **1.21.4**: `packet_set_creative_slot.item` type: `Slot`
|
|
193
|
+
- **1.21.5**: `packet_set_creative_slot.item` type: `UntrustedSlot`
|
|
194
|
+
- `UntrustedSlot` has `present` boolean field first
|
|
195
|
+
- Uses `UntrustedSlotComponent` instead of `SlotComponent`
|
|
196
|
+
- New component system with `addedComponentCount` and `removedComponentCount`
|
|
197
|
+
- **Files to Modify**: `lib/plugins/creative.js` (creative set slot handling)
|
|
198
|
+
|
|
199
|
+
### 3. **Check Item Format Changes** (Medium Priority - PROTOCOL CHANGES IDENTIFIED)
|
|
200
|
+
- **Issue**: New hashed items and unsecure items concepts
|
|
201
|
+
- **Location**: `lib/plugins/inventory.js`
|
|
202
|
+
- **Impact**: Item handling and inventory management
|
|
203
|
+
- **Protocol Changes Found**:
|
|
204
|
+
- **New `vec3i` type**: Added for 3D integer vectors
|
|
205
|
+
- **Item component system**: New component-based item system
|
|
206
|
+
- **Component reordering**: Item component IDs have been reordered (e.g., `hide_additional_tooltip` → `tooltip_display`)
|
|
207
|
+
- **New components**: Added `blocks_attacks`, `weapon` components
|
|
208
|
+
- **Entity metadata**: `item_stack` type still uses `Slot` but may have component changes
|
|
209
|
+
|
|
210
|
+
### 4. **Entity Metadata Changes** (Medium Priority - MINIMAL CHANGES)
|
|
211
|
+
- **Issue**: Entity metadata format changes
|
|
212
|
+
- **Location**: `lib/plugins/entities.js`
|
|
213
|
+
- **Impact**: Entity tracking and interaction
|
|
214
|
+
- **Protocol Analysis**:
|
|
215
|
+
- **Good news**: `entity_metadata` packet structure unchanged
|
|
216
|
+
- **Good news**: `item_stack` type in metadata still uses `Slot` (not `UntrustedSlot`)
|
|
217
|
+
- **Minimal impact**: Entity metadata changes appear to be minimal for 1.21.5
|
|
218
|
+
|
|
219
|
+
## Protocol Analysis Summary
|
|
220
|
+
|
|
221
|
+
Based on the [minecraft-data PR #1029](https://github.com/PrismarineJS/minecraft-data/pull/1029/files) analysis, here are the key protocol changes for 1.21.5:
|
|
222
|
+
|
|
223
|
+
### 🔥 **Critical Changes (Blocking Issues)**
|
|
224
|
+
|
|
225
|
+
1. **Creative Set Slot Packet**:
|
|
226
|
+
- **Change**: `packet_set_creative_slot.item` type changed from `Slot` to `UntrustedSlot`
|
|
227
|
+
- **Impact**: Creative mode inventory management completely broken
|
|
228
|
+
- **Fix Required**: Update `lib/plugins/creative.js` to handle `UntrustedSlot` format
|
|
229
|
+
|
|
230
|
+
2. **New Packet Types**:
|
|
231
|
+
- **Added**: `set_test_block` (0x39) and `test_instance_block_action` (0x3c)
|
|
232
|
+
- **Impact**: May affect block interaction tests
|
|
233
|
+
|
|
234
|
+
### 📦 **Item System Changes**
|
|
235
|
+
|
|
236
|
+
1. **Component System**:
|
|
237
|
+
- **New**: `UntrustedSlot` with component-based system
|
|
238
|
+
- **Components**: `addedComponentCount`, `removedComponentCount`, `UntrustedSlotComponent`
|
|
239
|
+
- **Impact**: Item serialization/deserialization needs updates
|
|
240
|
+
|
|
241
|
+
2. **Component Reordering**:
|
|
242
|
+
- **Changed**: Component IDs reordered (e.g., `hide_additional_tooltip` → `tooltip_display`)
|
|
243
|
+
- **Added**: New components like `blocks_attacks`, `weapon`
|
|
244
|
+
|
|
245
|
+
### 🎯 **Minimal Impact Changes**
|
|
246
|
+
|
|
247
|
+
1. **Entity Metadata**:
|
|
248
|
+
- **Status**: Unchanged - still uses `Slot` for `item_stack`
|
|
249
|
+
- **Impact**: Minimal - no changes needed
|
|
250
|
+
|
|
251
|
+
2. **New Types**:
|
|
252
|
+
- **Added**: `vec3i` type for 3D integer vectors
|
|
253
|
+
- **Impact**: May be used in new packets but not critical
|
|
254
|
+
|
|
255
|
+
## Implementation Steps
|
|
256
|
+
```bash
|
|
257
|
+
cd /media/documents/Documents/programmation/interlangage/minecraft/mineflayer
|
|
258
|
+
npm install
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Step 2: Run Current Tests
|
|
262
|
+
```bash
|
|
263
|
+
# Test current 1.21.5 status
|
|
264
|
+
npm run mocha_test -- -g "mineflayer_external 1.21.5v"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Step 3: Investigate Specific Issues
|
|
268
|
+
```bash
|
|
269
|
+
# Debug chunk loading
|
|
270
|
+
DEBUG="minecraft-protocol" npm run mocha_test -- -g "mineflayer_external 1.21.5v.*blocks"
|
|
271
|
+
|
|
272
|
+
# Debug creative mode
|
|
273
|
+
npm run mocha_test -- -g "mineflayer_external 1.21.5v.*creative"
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Step 4: Implement Fixes
|
|
277
|
+
1. Start with chunk protocol fixes
|
|
278
|
+
2. Fix creative set slot issues
|
|
279
|
+
3. Update item handling
|
|
280
|
+
4. Fix entity metadata
|
|
281
|
+
|
|
282
|
+
### Step 5: Validate Fixes
|
|
283
|
+
```bash
|
|
284
|
+
# Run all 1.21.5 tests
|
|
285
|
+
npm run mocha_test -- -g "mineflayer_external 1.21.5v"
|
|
286
|
+
|
|
287
|
+
# Run specific functionality tests
|
|
288
|
+
npm run mocha_test -- -g "mineflayer_external 1.21.5v.*inventory"
|
|
289
|
+
npm run mocha_test -- -g "mineflayer_external 1.21.5v.*entities"
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Success Criteria
|
|
293
|
+
|
|
294
|
+
1. All 1.21.5 tests pass
|
|
295
|
+
2. Core functionality works (world loading, inventory, entities)
|
|
296
|
+
3. Creative mode functions properly
|
|
297
|
+
4. No regressions in other versions
|
|
298
|
+
5. Documentation is updated
|
|
299
|
+
|
|
300
|
+
## Risk Mitigation
|
|
301
|
+
|
|
302
|
+
1. **Backward Compatibility**: Ensure fixes don't break older versions
|
|
303
|
+
2. **Incremental Testing**: Test each fix individually
|
|
304
|
+
3. **Fallback Mechanisms**: Implement fallbacks for protocol changes
|
|
305
|
+
4. **Version Detection**: Use `bot.supportFeature()` for version-specific code
|
|
306
|
+
|
|
307
|
+
## Resources Needed
|
|
308
|
+
|
|
309
|
+
1. **Minecraft 1.21.5 Server**: For testing
|
|
310
|
+
2. **Packet Analyzer**: For debugging protocol changes
|
|
311
|
+
3. **Documentation**: Minecraft 1.21.5 protocol changes
|
|
312
|
+
4. **Time**: 1-2 weeks of focused development
|
|
313
|
+
|
|
314
|
+
## Contributing Guidelines
|
|
315
|
+
|
|
316
|
+
For anyone wanting to contribute to 1.21.5 support:
|
|
317
|
+
|
|
318
|
+
1. **Read the Documentation**: `docs/llm_contribute.md` and `docs/README.md`
|
|
319
|
+
2. **Understand the Test System**: `test/externalTests/`
|
|
320
|
+
3. **Focus on One Issue**: Pick one specific problem to solve
|
|
321
|
+
4. **Test Thoroughly**: Run tests for multiple versions
|
|
322
|
+
5. **Document Changes**: Update relevant documentation
|
|
323
|
+
|
|
324
|
+
## Updated Timeline
|
|
325
|
+
|
|
326
|
+
- **Phase 1**: ✅ COMPLETED (chunk protocol fix)
|
|
327
|
+
- **Phase 2**: 2-3 days (investigate and fix test setup failures)
|
|
328
|
+
- **Phase 3**: 2-3 days (fix creative set slot and other protocol issues)
|
|
329
|
+
- **Phase 4**: 1-2 days (testing and validation)
|
|
330
|
+
- **Phase 5**: 1 day (documentation and cleanup)
|
|
331
|
+
|
|
332
|
+
**Total Estimated Time**: 6-9 days remaining
|
|
333
|
+
|
|
334
|
+
**Note**: Chunk loading is now fixed! Focus is on remaining protocol changes and test failures.
|
|
335
|
+
|
|
336
|
+
## References
|
|
337
|
+
|
|
338
|
+
- [PrismarineJS/prismarine-chunk#289](https://github.com/PrismarineJS/prismarine-chunk/pull/289)
|
|
339
|
+
- [PrismarineJS/mineflayer#3691](https://github.com/PrismarineJS/mineflayer/pull/3691)
|
|
340
|
+
- [PrismarineJS/mineflayer#3641](https://github.com/PrismarineJS/mineflayer/issues/3641)
|
|
341
|
+
- [PrismarineJS/minecraft-data#1029](https://github.com/PrismarineJS/minecraft-data/pull/1029)
|
|
342
|
+
- [PrismarineJS/node-minecraft-protocol#1408](https://github.com/PrismarineJS/node-minecraft-protocol/pull/1408)
|
package/lib/loader.js
CHANGED
|
@@ -74,6 +74,10 @@ function createBot (options = {}) {
|
|
|
74
74
|
const bot = new EventEmitter()
|
|
75
75
|
bot._client = options.client
|
|
76
76
|
bot.end = (reason) => bot._client.end(reason)
|
|
77
|
+
bot._warn = function (...message) {
|
|
78
|
+
if (options.hideErrors) return
|
|
79
|
+
console.warn('[mineflayer]', ...message)
|
|
80
|
+
}
|
|
77
81
|
if (options.logErrors) {
|
|
78
82
|
bot.on('error', err => {
|
|
79
83
|
if (!options.hideErrors) {
|
package/lib/plugins/bed.js
CHANGED
|
@@ -146,9 +146,10 @@ function inject (bot) {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
// We need to register the listener before actually going to sleep to avoid race conditions
|
|
150
|
+
const waitingPromise = waitUntilSleep()
|
|
149
151
|
bot.activateBlock(bedBlock)
|
|
150
|
-
|
|
151
|
-
await waitUntilSleep()
|
|
152
|
+
await waitingPromise
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
|
|
@@ -166,7 +167,7 @@ function inject (bot) {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
bot._client.on('game_state_change', (packet) => {
|
|
169
|
-
if (packet.reason === 0) {
|
|
170
|
+
if (packet.reason === 0 || packet.reason === 'no_respawn_block_available') {
|
|
170
171
|
// occurs when you can't spawn in your bed and your spawn point gets reset
|
|
171
172
|
bot.emit('spawnReset')
|
|
172
173
|
}
|
package/lib/plugins/entities.js
CHANGED
|
@@ -232,6 +232,8 @@ function inject (bot) {
|
|
|
232
232
|
bot.emit('entitySpawn', entity)
|
|
233
233
|
})
|
|
234
234
|
|
|
235
|
+
// spawn_entity_experience_orb packet was removed in 1.21.5+
|
|
236
|
+
// XP orbs are now handled through the general spawn_entity packet
|
|
235
237
|
bot._client.on('spawn_entity_experience_orb', (packet) => {
|
|
236
238
|
const entity = fetchEntity(packet.entityId)
|
|
237
239
|
entity.type = 'orb'
|
package/lib/plugins/game.js
CHANGED
|
@@ -116,10 +116,10 @@ function inject (bot, options) {
|
|
|
116
116
|
})
|
|
117
117
|
|
|
118
118
|
bot._client.on('game_state_change', (packet) => {
|
|
119
|
-
if (packet
|
|
119
|
+
if ((packet.reason === 4 || packet.reason === 'win_game') && packet.gameMode === 1) {
|
|
120
120
|
bot._client.write('client_command', { action: 0 })
|
|
121
121
|
}
|
|
122
|
-
if (packet.reason === 3) {
|
|
122
|
+
if ((packet.reason === 3) || (packet.reason === 'change_game_mode')) {
|
|
123
123
|
bot.game.gameMode = parseGameMode(packet.gameMode)
|
|
124
124
|
bot.emit('game')
|
|
125
125
|
}
|
package/lib/plugins/physics.js
CHANGED
|
@@ -232,7 +232,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
232
232
|
}
|
|
233
233
|
bot._client.write('entity_action', {
|
|
234
234
|
entityId: bot.entity.id,
|
|
235
|
-
actionId: 8,
|
|
235
|
+
actionId: bot.supportFeature('entityActionUsesStringMapper') ? 'start_elytra_flying' : 8,
|
|
236
236
|
jumpBoost: 0
|
|
237
237
|
})
|
|
238
238
|
}
|
|
@@ -247,15 +247,27 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
247
247
|
} else if (control === 'sprint') {
|
|
248
248
|
bot._client.write('entity_action', {
|
|
249
249
|
entityId: bot.entity.id,
|
|
250
|
-
actionId:
|
|
250
|
+
actionId: bot.supportFeature('entityActionUsesStringMapper')
|
|
251
|
+
? (state ? 'start_sprinting' : 'stop_sprinting')
|
|
252
|
+
: (state ? 3 : 4),
|
|
251
253
|
jumpBoost: 0
|
|
252
254
|
})
|
|
253
255
|
} else if (control === 'sneak') {
|
|
254
|
-
bot.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
if (bot.supportFeature('newPlayerInputPacket')) {
|
|
257
|
+
// In 1.21.6+, sneak is handled via player_input packet
|
|
258
|
+
bot._client.write('player_input', {
|
|
259
|
+
inputs: {
|
|
260
|
+
shift: state
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
} else {
|
|
264
|
+
// Legacy entity_action approach for older versions
|
|
265
|
+
bot._client.write('entity_action', {
|
|
266
|
+
entityId: bot.entity.id,
|
|
267
|
+
actionId: state ? 0 : 1,
|
|
268
|
+
jumpBoost: 0
|
|
269
|
+
})
|
|
270
|
+
}
|
|
259
271
|
}
|
|
260
272
|
}
|
|
261
273
|
|
|
@@ -296,7 +308,10 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
296
308
|
// TODO: emit an explosion event with more info
|
|
297
309
|
if (bot.physicsEnabled && bot.game.gameMode !== 'creative') {
|
|
298
310
|
if (explosion.playerKnockback) { // 1.21.3+
|
|
299
|
-
|
|
311
|
+
// Fixes issue #3635
|
|
312
|
+
bot.entity.velocity.x += explosion.playerKnockback.x
|
|
313
|
+
bot.entity.velocity.y += explosion.playerKnockback.y
|
|
314
|
+
bot.entity.velocity.z += explosion.playerKnockback.z
|
|
300
315
|
}
|
|
301
316
|
if ('playerMotionX' in explosion) {
|
|
302
317
|
bot.entity.velocity.x += explosion.playerMotionX
|
package/lib/plugins/rain.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
module.exports = inject
|
|
2
|
+
const states = ['no_respawn_block_available', 'start_raining', 'stop_raining', 'change_game_mode', 'win_game', 'demo_event', 'play_arrow_hit_sound', 'rain_level_change', 'thunder_level_change', 'puffer_fish_sting', 'guardian_elder_effect', 'immediate_respawn', 'limited_crafting', 'level_chunks_load_start']
|
|
2
3
|
|
|
3
4
|
function inject (bot) {
|
|
4
5
|
bot.isRaining = false
|
|
5
6
|
bot.thunderState = 0
|
|
6
7
|
bot.rainState = 0
|
|
7
8
|
bot._client.on('game_state_change', (packet) => {
|
|
8
|
-
|
|
9
|
+
const reason = states[packet.reason] ?? packet.reason
|
|
10
|
+
if (reason === 'start_raining') {
|
|
9
11
|
bot.isRaining = true
|
|
10
12
|
bot.emit('rain')
|
|
11
|
-
} else if (
|
|
13
|
+
} else if (reason === 'stop_raining') {
|
|
12
14
|
bot.isRaining = false
|
|
13
15
|
bot.emit('rain')
|
|
14
|
-
} else if (
|
|
16
|
+
} else if (reason === 'rain_level_change') {
|
|
15
17
|
bot.rainState = packet.gameMode
|
|
16
18
|
bot.emit('weatherUpdate')
|
|
17
|
-
} else if (
|
|
19
|
+
} else if (reason === 'thunder_level_change') {
|
|
18
20
|
bot.thunderState = packet.gameMode
|
|
19
21
|
bot.emit('weatherUpdate')
|
|
20
22
|
}
|
package/lib/plugins/team.js
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
module.exports = inject
|
|
2
2
|
|
|
3
|
+
// TODO: apply this to all versions and rename scoreboard_team -> teams in minecraft-data
|
|
4
|
+
const TEAM_MODES = ['add', 'remove', 'change', 'join', 'leave']
|
|
5
|
+
|
|
3
6
|
function inject (bot) {
|
|
4
7
|
const Team = require('../team')(bot.registry)
|
|
5
8
|
const teams = {}
|
|
6
9
|
|
|
7
10
|
function teamHandler (packet) {
|
|
8
|
-
const { team: teamName,
|
|
11
|
+
const { team: teamName, players = [] } = packet
|
|
12
|
+
const mode = typeof packet.mode === 'number' ? TEAM_MODES[packet.mode] : packet.mode
|
|
13
|
+
|
|
9
14
|
let team = teams[teamName]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
|
|
16
|
+
switch (mode) {
|
|
17
|
+
case 'add':
|
|
18
|
+
team = new Team(
|
|
19
|
+
teamName,
|
|
20
|
+
packet.name,
|
|
21
|
+
packet.friendlyFire,
|
|
22
|
+
packet.nameTagVisibility,
|
|
23
|
+
packet.collisionRule,
|
|
24
|
+
packet.formatting,
|
|
25
|
+
packet.prefix,
|
|
26
|
+
packet.suffix
|
|
27
|
+
)
|
|
28
|
+
for (const player of players) {
|
|
23
29
|
team.add(player)
|
|
24
30
|
bot.teamMap[player] = team
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
team.members.forEach(member => {
|
|
31
|
+
}
|
|
32
|
+
teams[teamName] = team
|
|
33
|
+
bot.emit('teamCreated', teams[teamName])
|
|
34
|
+
break
|
|
35
|
+
|
|
36
|
+
case 'remove':
|
|
37
|
+
if (!team) break
|
|
38
|
+
team.members.forEach((member) => {
|
|
33
39
|
delete bot.teamMap[member]
|
|
34
40
|
})
|
|
35
41
|
delete teams[teamName]
|
|
36
42
|
bot.emit('teamRemoved', teams[teamName])
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
break
|
|
44
|
+
|
|
45
|
+
case 'change':
|
|
46
|
+
if (!team) break
|
|
39
47
|
team.update(
|
|
40
48
|
packet.name,
|
|
41
49
|
packet.friendlyFire,
|
|
@@ -46,23 +54,28 @@ function inject (bot) {
|
|
|
46
54
|
packet.suffix
|
|
47
55
|
)
|
|
48
56
|
bot.emit('teamUpdated', teams[teamName])
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
bot.emit('teamMemberAdded', teams[teamName])
|
|
57
|
+
break
|
|
58
|
+
|
|
59
|
+
case 'join':
|
|
60
|
+
if (!team) break
|
|
61
|
+
for (const player of players) {
|
|
62
|
+
team.add(player)
|
|
63
|
+
bot.teamMap[player] = team
|
|
57
64
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
bot.emit('teamMemberAdded', teams[teamName])
|
|
66
|
+
break
|
|
67
|
+
|
|
68
|
+
case 'leave':
|
|
69
|
+
if (!team) break
|
|
70
|
+
for (const player of players) {
|
|
71
|
+
team.remove(player)
|
|
72
|
+
delete bot.teamMap[player]
|
|
64
73
|
}
|
|
65
|
-
|
|
74
|
+
bot.emit('teamMemberRemoved', teams[teamName])
|
|
75
|
+
break
|
|
76
|
+
|
|
77
|
+
default:
|
|
78
|
+
bot._warn(`Unknown team mode handling team update: ${mode}`)
|
|
66
79
|
}
|
|
67
80
|
}
|
|
68
81
|
|
package/lib/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const testedVersions = ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1', '1.21.3', '1.21.4']
|
|
1
|
+
const testedVersions = ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1', '1.21.3', '1.21.4', '1.21.5', '1.21.6']
|
|
2
2
|
module.exports = {
|
|
3
3
|
|
|
4
4
|
testedVersions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mineflayer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.32.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"minecraft-data": "^3.76.0",
|
|
25
|
-
"minecraft-protocol": "^1.
|
|
25
|
+
"minecraft-protocol": "^1.60.0",
|
|
26
26
|
"prismarine-biome": "^1.1.1",
|
|
27
|
-
"prismarine-block": "^1.
|
|
27
|
+
"prismarine-block": "^1.22.0",
|
|
28
28
|
"prismarine-chat": "^1.7.1",
|
|
29
|
-
"prismarine-chunk": "^1.
|
|
29
|
+
"prismarine-chunk": "^1.39.0",
|
|
30
30
|
"prismarine-entity": "^2.5.0",
|
|
31
|
-
"prismarine-item": "^1.
|
|
31
|
+
"prismarine-item": "^1.17.0",
|
|
32
32
|
"prismarine-nbt": "^2.0.0",
|
|
33
33
|
"prismarine-physics": "^1.9.0",
|
|
34
34
|
"prismarine-recipe": "^1.3.0",
|