minecraft-renderer 0.1.60 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/three/entities.ts
CHANGED
|
@@ -903,8 +903,13 @@ export class Entities {
|
|
|
903
903
|
// TODO CLEANUP!
|
|
904
904
|
// Handle special player entity ID for bot entity in third person
|
|
905
905
|
const key = String(entityPlayerId)
|
|
906
|
-
|
|
907
|
-
|
|
906
|
+
// `oneSwing` is a one-shot event, not a persistent state: two swings in a row
|
|
907
|
+
// are both 'oneSwing', so deduping by name would swallow every repeat swing
|
|
908
|
+
// while standing still. Only dedupe the persistent state animations.
|
|
909
|
+
if (animation !== 'oneSwing') {
|
|
910
|
+
if (this.playerPerAnimation[key] === animation) return
|
|
911
|
+
this.playerPerAnimation[key] = animation
|
|
912
|
+
}
|
|
908
913
|
|
|
909
914
|
if (entityPlayerId === 'player_entity' && this.playerEntity?.playerObject) {
|
|
910
915
|
const { playerObject } = this.playerEntity
|
|
@@ -87,7 +87,13 @@ export class WalkingGeneralSwing extends PlayerAnimation {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
swingArm() {
|
|
90
|
-
|
|
90
|
+
// Only (re)start once we're past the halfway point of the current swing, like
|
|
91
|
+
// vanilla EntityLiving.swingArm. Otherwise a burst of `animation` packets
|
|
92
|
+
// (rapid clicks / digging) keeps resetting _swingTime and the arm never
|
|
93
|
+
// completes an arc, looking like a stutter of fast partial swings.
|
|
94
|
+
if (this._swingTime === null || this._swingTime >= this._swingDuration / 2) {
|
|
95
|
+
this._swingTime = 0
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
resetLocomotion() {
|
|
@@ -189,8 +195,6 @@ export class WalkingGeneralSwing extends PlayerAnimation {
|
|
|
189
195
|
const crouchSpeedMul = mix(1, 0.55, crouchBlend)
|
|
190
196
|
const speed = baseSpeed * crouchSpeedMul
|
|
191
197
|
|
|
192
|
-
this._phase += dt * speed * moveBlend
|
|
193
|
-
|
|
194
198
|
this._phase += dt * speed * moveBlend
|
|
195
199
|
this._idlePhase += dt * 1.15
|
|
196
200
|
|
|
@@ -285,17 +289,22 @@ const HitAnimation = {
|
|
|
285
289
|
animate(progress, player, isMovingOrRunning) {
|
|
286
290
|
if (!player?.skin?.rightArm?.rotation) return
|
|
287
291
|
|
|
288
|
-
|
|
289
|
-
|
|
292
|
+
// One swing = one arc. `swing` rises to its peak at the middle of the swing
|
|
293
|
+
// (progress 0.5) and returns to rest at both ends, matching vanilla's
|
|
294
|
+
// `sin(swingProgress * PI)` and the first-person hand. Driving the trig with
|
|
295
|
+
// `progress * 18` previously ran ~3 sine cycles per click, which made other
|
|
296
|
+
// players' arms look like they were swinging several times per hit.
|
|
297
|
+
const swing = Math.sin(progress * Math.PI)
|
|
298
|
+
player.skin.rightArm.rotation.x = -0.4537860552 * 2 - 2 * swing * 0.3
|
|
290
299
|
|
|
291
300
|
if (!isMovingOrRunning) {
|
|
292
301
|
const basicArmRotationZ = 0.01 * Math.PI + 0.06
|
|
293
|
-
player.skin.rightArm.rotation.z = -
|
|
294
|
-
player.skin.body.rotation.y = -
|
|
295
|
-
player.skin.leftArm.rotation.x =
|
|
296
|
-
player.skin.leftArm.rotation.z = -
|
|
297
|
-
player.skin.leftArm.position.z =
|
|
298
|
-
player.skin.leftArm.position.x = 5 -
|
|
302
|
+
player.skin.rightArm.rotation.z = -swing * 0.403 + basicArmRotationZ
|
|
303
|
+
player.skin.body.rotation.y = -swing * 0.06
|
|
304
|
+
player.skin.leftArm.rotation.x = -swing * 0.077
|
|
305
|
+
player.skin.leftArm.rotation.z = -swing * 0.015 + 0.13 - 0.05
|
|
306
|
+
player.skin.leftArm.position.z = swing * 0.3
|
|
307
|
+
player.skin.leftArm.position.x = 5 - swing * 0.05
|
|
299
308
|
}
|
|
300
309
|
},
|
|
301
310
|
}
|