Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21 #3480

Merged
merged 20 commits into from
Oct 26, 2024
Merged

1.21 #3480

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/plugins/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/externalTests/fishing.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
23 changes: 17 additions & 6 deletions test/internalTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }

Expand All @@ -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 }

Expand Down
Loading