Skip to content

Commit

Permalink
1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat committed Jul 2, 2024
1 parent eb9982a commit 9c0244c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ jobs:
java-package: jre
- name: Install Dependencies
run: npm install
- run: cd node_modules && cd minecraft-data && mv minecraft-data minecraft-data-old && git clone -b 1.20.5protocol https://github.com/extremeheat/minecraft-data/ --depth 1 && node bin/generate_data.js
- name: Start Tests
run: npm run mocha_test -- -g ${{ matrix.mcVersion }}v
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.4 (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)
* 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.5)
* 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
21 changes: 11 additions & 10 deletions lib/plugins/breath.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module.exports = inject

function inject (bot) {
if (bot.supportFeature('mcDataHasEntityMetadata')) {
// this is handled inside entities.js. We don't yet have entity metadataKeys for all versions but once we do
// we can delete the numerical checks here and in entities.js https://github.com/extremeheat/mineflayer/blob/eb9982aa04973b0086aac68a2847005d77f01a3d/lib/plugins/entities.js#L469
return
}
bot._client.on('entity_metadata', (packet) => {
if (!bot?.entity?.id === packet?.entityId) return
if (packet?.metadata[1]?.key === 1) {
if (!packet?.metadata[1]?.value) return
bot.oxygenLevel = Math.round(packet.metadata[1].value / 15)
bot.emit('breath')
}
if (packet?.metadata[0]?.key === 1) {
if (!packet?.metadata[0]?.value) return
bot.oxygenLevel = Math.round(packet.metadata[0].value / 15)
bot.emit('breath')
if (bot.entity.id !== packet.entityId) return
for (const metadata of packet.metadata) {
if (metadata.key === 1) {
bot.oxygenLevel = Math.round(packet.metadata[1].value / 15)
bot.emit('breath')
}
}
})
}
5 changes: 5 additions & 0 deletions lib/plugins/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ function inject (bot) {
bot.emit('entityUncrouch', entity)
}
}

// Breathing (formerly in breath.js)
if (metas.air_supply != null) {
bot.oxygenLevel = Math.round(metas.air_supply / 15)
}
} else {
const typeSlot = (bot.supportFeature('itemsAreAlsoBlocks') ? 5 : 6) + (bot.supportFeature('entityMetadataHasLong') ? 1 : 0)
const slot = packet.metadata.find(e => e.type === typeSlot)
Expand Down
9 changes: 7 additions & 2 deletions lib/plugins/fishing.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ function inject (bot) {
if (!lastBobber || fishingTask.done) return

const pos = lastBobber.position
const parts = bot.registry.particlesByName
if (packet.particleId === (parts?.fishing ?? parts.bubble).id && packet.particles === 6 && pos.distanceTo(new Vec3(packet.x, pos.y, packet.z)) <= 1.23) {

const bobberCondition = bot.registry.supportFeature('updatedParticlesPacket')
? ((packet.particle.type === 'fishing' || packet.particle.type === 'bubble') && packet.amount === 6 && pos.distanceTo(new Vec3(packet.x, pos.y, packet.z)) <= 1.23)
// This "(fishing ?? bubble).id" condition doesn't make sense
: (packet.particleId === (bot.registry.particlesByName.fishing ?? bot.registry.particlesByName.bubble).id && packet.particles === 6 && pos.distanceTo(new Vec3(packet.x, pos.y, packet.z)) <= 1.23)

if (bobberCondition) {
bot.activateItem()
lastBobber = undefined
fishingTask.finish()
Expand Down
5 changes: 3 additions & 2 deletions lib/plugins/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function inject (bot, options) {
})

bot._client.on('login', (packet) => {
handleRespawnPacketData(packet)
handleRespawnPacketData(packet.worldState || packet)

bot.game.maxPlayers = packet.maxPlayers
if (packet.enableRespawnScreen) {
Expand All @@ -95,7 +95,8 @@ function inject (bot, options) {
})

bot._client.on('respawn', (packet) => {
handleRespawnPacketData(packet)
// in 1.20.5+ protocol we move the shared data into one WorldState type
handleRespawnPacketData(packet.worldState || packet)
bot.emit('game')
})

Expand Down

0 comments on commit 9c0244c

Please sign in to comment.