Skip to content

Commit 44fad41

Browse files
extremeheatrom1504
andauthored
1.20.6 (#3412)
* 1.20.5 * lint * fix * update registry * update java * add debug * fix * debug * Update testCommon.js * update ci * add protodef AOT compile code * Update protodefCompile.js * Update testCommon.js * pitem, fix `login` event * debug * Update testCommon.js * Update package.json test * Update package.json * update test events * Update testCommon.js * update * fix pitem source * remove some debug logging * update * Fix trade test * remove manual protodef install from ci * remove unnecessary install in ci * change back version.js to support latest version * update deps * remove compile protocol in ci * bump to support 1.20.6 * in tests teleport to overworld to prevent nether test to break the environment * fix respawn in internal tests * use normal tp before 1.14 * lint * fix held item test * fix item drop internal test for 1.20.6 * cleanup --------- Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
1 parent 1c2a5c0 commit 44fad41

22 files changed

Lines changed: 184 additions & 81 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Setup Java JDK
5353
uses: actions/setup-java@v1.4.3
5454
with:
55-
java-version: 17
55+
java-version: 21
5656
java-package: jre
5757
- name: Install Dependencies
5858
run: npm install

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ test/server_*
1010
.vscode
1111
.DS_Store
1212
launcher_accounts.json
13+
data

.gitpod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
tasks:
2-
- command: npm install
2+
- command: npm install && sdk install java

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
1717

1818
## Features
1919

20-
* 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)
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.6)
2121
* Entity knowledge and tracking.
2222
* Block knowledge. You can query the world around you. Milliseconds to find any block.
2323
* Physics and movement - handle all bounding boxes

lib/loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ function createBot (options = {}) {
9595
}).map(key => options.plugins[key])
9696
bot.loadPlugins([...internalPlugins, ...externalPlugins])
9797

98+
options.validateChannelProtocol = false
9899
bot._client = bot._client ?? mc.createClient(options)
99100
bot._client.on('connect', () => {
100101
bot.emit('connect')

lib/particle.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module.exports = loader
55
function loader (registry) {
66
class Particle {
77
constructor (id, position, offset, count = 1, movementSpeed = 0, longDistanceRender = false) {
8-
Object.assign(this, registry.particles[id])
98
this.id = id
9+
Object.assign(this, registry.particles[id] || registry.particlesByName[id])
1010
this.position = position
1111
this.offset = offset
1212
this.count = count
@@ -15,14 +15,26 @@ function loader (registry) {
1515
}
1616

1717
static fromNetwork (packet) {
18-
return new Particle(
19-
packet.particleId,
20-
new Vec3(packet.x, packet.y, packet.z),
21-
new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ),
22-
packet.particles,
23-
packet.particleData,
24-
packet.longDistance
25-
)
18+
if (registry.supportFeature('updatedParticlesPacket')) {
19+
// TODO: We add extra data that's inside packet.particle.data that varies by the particle's .type
20+
return new Particle(
21+
packet.particle.type,
22+
new Vec3(packet.x, packet.y, packet.z),
23+
new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ),
24+
packet.amount,
25+
packet.velocityOffset,
26+
packet.longDistance
27+
)
28+
} else {
29+
return new Particle(
30+
packet.particleId,
31+
new Vec3(packet.x, packet.y, packet.z),
32+
new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ),
33+
packet.particles,
34+
packet.particleData,
35+
packet.longDistance
36+
)
37+
}
2638
}
2739
}
2840

lib/plugins/blocks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
531531
if (bot.supportFeature('dimensionIsAnInt')) {
532532
dimension = packet.dimension
533533
worldName = dimensionToFolderName(dimension)
534+
} else if (bot.supportFeature('spawnRespawnWorldDataField')) { // 1.20.5+
535+
dimension = packet.worldState.dimension
536+
worldName = packet.worldState.name
534537
} else {
535538
dimension = packet.dimension
536539
worldName = /^minecraft:.+/.test(packet.worldName) ? packet.worldName : `minecraft:${packet.worldName}`
@@ -542,6 +545,11 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
542545
if (bot.supportFeature('dimensionIsAnInt')) { // <=1.15.2
543546
if (dimension === packet.dimension) return
544547
dimension = packet.dimension
548+
} else if (bot.supportFeature('spawnRespawnWorldDataField')) { // 1.20.5+
549+
if (dimension === packet.worldState.dimension) return
550+
if (worldName === packet.worldState.name && packet.copyMetadata === true) return // don't unload chunks if in same world and metaData is true
551+
dimension = packet.worldState.dimension
552+
worldName = packet.worldState.name
545553
} else { // >= 1.15.2
546554
if (dimension === packet.dimension) return
547555
if (worldName === packet.worldName && packet.copyMetadata === true) return // don't unload chunks if in same world and metaData is true

lib/plugins/breath.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
module.exports = inject
22

33
function inject (bot) {
4+
if (bot.supportFeature('mcDataHasEntityMetadata')) {
5+
// this is handled inside entities.js. We don't yet have entity metadataKeys for all versions but once we do
6+
// we can delete the numerical checks here and in entities.js https://github.com/extremeheat/mineflayer/blob/eb9982aa04973b0086aac68a2847005d77f01a3d/lib/plugins/entities.js#L469
7+
return
8+
}
49
bot._client.on('entity_metadata', (packet) => {
5-
if (!bot?.entity?.id === packet?.entityId) return
6-
if (packet?.metadata[1]?.key === 1) {
7-
if (!packet?.metadata[1]?.value) return
8-
bot.oxygenLevel = Math.round(packet.metadata[1].value / 15)
9-
bot.emit('breath')
10-
}
11-
if (packet?.metadata[0]?.key === 1) {
12-
if (!packet?.metadata[0]?.value) return
13-
bot.oxygenLevel = Math.round(packet.metadata[0].value / 15)
14-
bot.emit('breath')
10+
if (!bot.entity) return
11+
if (bot.entity.id !== packet.entityId) return
12+
for (const metadata of packet.metadata) {
13+
if (metadata.key === 1) {
14+
bot.oxygenLevel = Math.round(packet.metadata[1].value / 15)
15+
bot.emit('breath')
16+
}
1517
}
1618
})
1719
}

lib/plugins/creative.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ function inject (bot) {
3535
item: Item.toNotch(item)
3636
})
3737

38-
await onceWithCleanup(bot.inventory, `updateSlot:${slot}`, { checkCondition: (oldItem, newItem) => item === null ? newItem === null : newItem?.name === item.name && newItem?.count === item.count && newItem?.metadata === item.metadata })
38+
await onceWithCleanup(bot.inventory, `updateSlot:${slot}`, {
39+
timeout: 5000,
40+
checkCondition: (oldItem, newItem) => item === null ? newItem === null : newItem?.name === item.name && newItem?.count === item.count && newItem?.metadata === item.metadata
41+
})
3942
creativeSlotsUpdates[slot] = false
4043
}
4144

lib/plugins/entities.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,12 @@ function inject (bot) {
470470
bot.emit('entityUncrouch', entity)
471471
}
472472
}
473+
474+
// Breathing (formerly in breath.js)
475+
if (metas.air_supply != null) {
476+
bot.oxygenLevel = Math.round(metas.air_supply / 15)
477+
bot.emit('breath')
478+
}
473479
} else {
474480
const typeSlot = (bot.supportFeature('itemsAreAlsoBlocks') ? 5 : 6) + (bot.supportFeature('entityMetadataHasLong') ? 1 : 0)
475481
const slot = packet.metadata.find(e => e.type === typeSlot)

0 commit comments

Comments
 (0)