Skip to content

Commit 61fbd3a

Browse files
Backport velocity field changes from 1.21.9+ to older versions (#3839)
* Backport velocity naming changes * Update ci.yml * Update package.json * Update ci.yml * Update package.json * dbg * Remove debug logging --------- Co-authored-by: extremeheat <extreme@protonmail.ch>
1 parent fd00edd commit 61fbd3a

2 files changed

Lines changed: 5 additions & 34 deletions

File tree

lib/plugins/entities.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,7 @@ function inject (bot) {
271271
entity.yaw = conv.fromNotchianYawByte(packet.yaw)
272272
entity.pitch = conv.fromNotchianPitchByte(packet.pitch)
273273
entity.headPitch = conv.fromNotchianPitchByte(packet.headPitch)
274-
275-
let notchVel
276-
if (bot.supportFeature('entityVelocityIsLpVec3')) {
277-
notchVel = new Vec3(packet.velocity.x, packet.velocity.y, packet.velocity.z)
278-
} else {
279-
notchVel = new Vec3(packet.velocityX, packet.velocityY, packet.velocityZ)
280-
}
274+
const notchVel = new Vec3(packet.velocity.x, packet.velocity.y, packet.velocity.z)
281275
entity.velocity.update(conv.fromNotchVelocity(notchVel))
282276
entity.metadata = parseMetadata(packet.metadata, entity.metadata)
283277

@@ -287,12 +281,7 @@ function inject (bot) {
287281
bot._client.on('entity_velocity', (packet) => {
288282
// entity velocity
289283
const entity = fetchEntity(packet.entityId)
290-
let notchVel
291-
if (bot.supportFeature('entityVelocityIsLpVec3')) {
292-
notchVel = new Vec3(packet.velocity.x, packet.velocity.y, packet.velocity.z)
293-
} else {
294-
notchVel = new Vec3(packet.velocityX, packet.velocityY, packet.velocityZ)
295-
}
284+
const notchVel = new Vec3(packet.velocity.x, packet.velocity.y, packet.velocity.z)
296285
entity.velocity.update(conv.fromNotchVelocity(notchVel))
297286
})
298287

test/internalTest.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,6 @@ for (const supportedVersion of mineflayer.testedVersions) {
215215
pitch: 14,
216216
headPitch: 14,
217217
velocity: { x: 15, y: 16, z: 17 },
218-
velocityX: 16,
219-
velocityY: 17,
220-
velocityZ: 18,
221218
metadata: []
222219
})
223220
client.write('entity_effect', {
@@ -688,10 +685,7 @@ for (const supportedVersion of mineflayer.testedVersions) {
688685
yaw: 0,
689686
headPitch: 0,
690687
objectData: 1,
691-
velocity: { x: 0, y: 0, z: 0 },
692-
velocityX: 0,
693-
velocityY: 0,
694-
velocityZ: 0
688+
velocity: { x: 0, y: 0, z: 0 }
695689
})
696690
} else {
697691
client.write('named_entity_spawn', {
@@ -939,10 +933,7 @@ for (const supportedVersion of mineflayer.testedVersions) {
939933
yaw: 0,
940934
headPitch: 0,
941935
objectData: 1,
942-
velocity: { x: 0, y: 0, z: 0 },
943-
velocityX: 0,
944-
velocityY: 0,
945-
velocityZ: 0
936+
velocity: { x: 0, y: 0, z: 0 }
946937
})
947938
} else {
948939
client.write('named_entity_spawn', {
@@ -996,9 +987,6 @@ for (const supportedVersion of mineflayer.testedVersions) {
996987
pitch: 14,
997988
headPitch: 14,
998989
velocity: { x: 15, y: 16, z: 17 },
999-
velocityX: 16,
1000-
velocityY: 17,
1001-
velocityZ: 18,
1002990
metadata: [
1003991
{ type: 0, key: bot.registry.supportFeature('mcDataHasEntityMetadata') ? 'byte' : 0, value: 0 },
1004992
{ type: 0, key: bot.registry.supportFeature('mcDataHasEntityMetadata') ? 'int' : 1, value: 1 }
@@ -1044,10 +1032,7 @@ for (const supportedVersion of mineflayer.testedVersions) {
10441032
yaw: 0,
10451033
headPitch: 0,
10461034
objectData: 1,
1047-
velocity: { x: 0, y: 0, z: 0 },
1048-
velocityX: 0,
1049-
velocityY: 0,
1050-
velocityZ: 0
1035+
velocity: { x: 0, y: 0, z: 0 }
10511036
})
10521037

10531038
const metadataPacket = {
@@ -1186,9 +1171,6 @@ for (const supportedVersion of mineflayer.testedVersions) {
11861171
pitch: 0,
11871172
headPitch: 0,
11881173
velocity: { x: 0, y: 0, z: 0 },
1189-
velocityX: 0,
1190-
velocityY: 0,
1191-
velocityZ: 0,
11921174
metadata: []
11931175
})
11941176

0 commit comments

Comments
 (0)