diff --git a/docs/README.md b/docs/README.md index 7accc69c0..284fa69d1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md) ## Features - * Supports Minecraft 1.8 to 1.20.5 (1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20 upto 1.20.6) + * Supports Minecraft 1.8 to 1.21 (1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, and 1.21) * Entity knowledge and tracking. * Block knowledge. You can query the world around you. Milliseconds to find any block. * Physics and movement - handle all bounding boxes diff --git a/lib/plugins/chat.js b/lib/plugins/chat.js index 9522223c6..ce92cc9c5 100644 --- a/lib/plugins/chat.js +++ b/lib/plugins/chat.js @@ -118,10 +118,11 @@ function inject (bot, options) { target: data.targetName ? JSON.parse(data.targetName) : undefined, content: message ? JSON.parse(message) : { text: data.plainMessage } } - msg = ChatMessage.fromNetwork(data.type, parameters) + const registryIndex = data.type.registryIndex ? data.type.registryIndex : data.type + msg = ChatMessage.fromNetwork(registryIndex, parameters) if (data.unsignedContent) { - msg.unsigned = ChatMessage.fromNetwork(data.type, { sender: parameters.sender, target: parameters.target, content: JSON.parse(data.unsignedContent) }) + msg.unsigned = ChatMessage.fromNetwork(registryIndex, { sender: parameters.sender, target: parameters.target, content: JSON.parse(data.unsignedContent) }) } } else { msg = ChatMessage.fromNotch(message) diff --git a/lib/plugins/inventory.js b/lib/plugins/inventory.js index 0277f3fef..42eab1d50 100644 --- a/lib/plugins/inventory.js +++ b/lib/plugins/inventory.js @@ -122,7 +122,8 @@ function inject (bot, { hideErrors }) { }) } else if (bot.supportFeature('useItemWithOwnPacket')) { bot._client.write('use_item', { - hand: offHand ? 1 : 0 + hand: offHand ? 1 : 0, + rotation: { x: 0, y: 0 } }) } } diff --git a/lib/version.js b/lib/version.js index 755db7285..291917cb0 100644 --- a/lib/version.js +++ b/lib/version.js @@ -1,4 +1,4 @@ -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'] +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'] module.exports = { testedVersions, diff --git a/package.json b/package.json index eef358235..46d5a27b1 100644 --- a/package.json +++ b/package.json @@ -22,17 +22,17 @@ "license": "MIT", "dependencies": { "minecraft-data": "^3.76.0", - "minecraft-protocol": "^1.49.0", + "minecraft-protocol": "^1.50.0", "prismarine-biome": "^1.1.1", "prismarine-block": "^1.17.0", "prismarine-chat": "^1.7.1", - "prismarine-chunk": "^1.34.0", + "prismarine-chunk": "^1.36.0", "prismarine-entity": "^2.3.0", "prismarine-item": "^1.15.0", "prismarine-nbt": "^2.0.0", - "prismarine-physics": "^1.8.0", + "prismarine-physics": "^1.9.0", "prismarine-recipe": "^1.3.0", - "prismarine-registry": "^1.8.0", + "prismarine-registry": "^1.10.0", "prismarine-windows": "^2.9.0", "prismarine-world": "^3.6.0", "protodef": "1.17.0", @@ -43,7 +43,7 @@ "@types/node": "^22.1.0", "doctoc": "^2.0.1", "minecraft-wrap": "^1.3.0", - "mineflayer": "file:.", + "mineflayer": "file:", "mocha": "^10.0.0", "protodef-yaml": "^1.5.3", "standard": "^17.0.0", diff --git a/test/externalTests/fishing.js b/test/externalTests/fishing.js index c0348c77d..cad7dc427 100644 --- a/test/externalTests/fishing.js +++ b/test/externalTests/fishing.js @@ -1,7 +1,7 @@ module.exports = () => async (bot) => { const Item = require('prismarine-item')(bot.registry) - bot.test.sayEverywhere('/fill ~-5 ~-1 ~-5 ~5 ~-1 ~5 water') + bot.test.sayEverywhere('/fill ~-10 ~-1 ~-10 ~10 ~-1 ~10 water') await bot.test.setInventorySlot(36, new Item(bot.registry.itemsByName.fishing_rod.id, 1, 0)) await bot.lookAt(bot.entity.position) // dont force the position bot.fish() diff --git a/test/internalTest.js b/test/internalTest.js index 4c930d650..2f74e03d1 100644 --- a/test/internalTest.js +++ b/test/internalTest.js @@ -58,7 +58,6 @@ for (const supportedVersion of mineflayer.testedVersions) { // 25565 - local server, 25566 - proxy server port: 25567 }) - console.log('Server Codec', server.registryCodec) server.on('listening', () => { bot = mineflayer.createBot({ username: 'player', @@ -130,7 +129,19 @@ for (const supportedVersion of mineflayer.testedVersions) { const uuid = 'd3527a0b-bc03-45d5-a878-2aafdd8c8a43' // random const networkName = chatText('gary') - if (registry.supportFeature('useChatSessions')) { + if (registry.supportFeature('incrementedChatType')) { + client.write('player_chat', { + plainMessage: 'hello', + filterType: 0, + type: { registryIndex: 1 }, + networkName, + previousMessages: [], + senderUuid: uuid, + timestamp: Date.now(), + index: 0, + salt: 0n + }) + } else if (registry.supportFeature('useChatSessions')) { client.write('player_chat', { plainMessage: 'hello', filterType: 0, @@ -909,9 +920,9 @@ for (const supportedVersion of mineflayer.testedVersions) { const zombieId = entities.zombie ? entities.zombie.id : entities.Zombie.id let bedBlock - if (mineflayer.supportFeature('oneBlockForSeveralVariations', version.majorVersion)) { + if (bot.supportFeature('oneBlockForSeveralVariations', version.majorVersion)) { bedBlock = blocks.bed - } else if (mineflayer.supportFeature('blockSchemeIsFlat', version.majorVersion)) { + } else if (bot.supportFeature('blockSchemeIsFlat', version.majorVersion)) { bedBlock = blocks.red_bed } const bedId = bedBlock.id @@ -945,7 +956,7 @@ for (const supportedVersion of mineflayer.testedVersions) { chunk.setBlockType(beds[bed].foot, bedId) } - if (mineflayer.supportFeature('blockStateId', version.majorVersion)) { + if (bot.supportFeature('blockStateId', version.majorVersion)) { chunk.setBlockStateId(beds[0].foot, 3 + bedBlock.minStateId) // { facing: north, occupied: false, part: foot } chunk.setBlockStateId(beds[0].head, 2 + bedBlock.minStateId) // { facing:north, occupied: false, part: head } @@ -957,7 +968,7 @@ for (const supportedVersion of mineflayer.testedVersions) { chunk.setBlockStateId(beds[3].foot, 11 + bedBlock.minStateId) // { facing: west, occupied: false, part: foot } chunk.setBlockStateId(beds[3].head, 10 + bedBlock.minStateId) // { facing: west, occupied: false, part: head } - } else if (mineflayer.supportFeature('blockMetadata', version.majorVersion)) { + } else if (bot.supportFeature('blockMetadata', version.majorVersion)) { chunk.setBlockData(beds[0].foot, 2) // { facing: north, occupied: false, part: foot } chunk.setBlockData(beds[0].head, 10) // { facing:north, occupied: false, part: head }