Hitting !!
This commit is contained in:
@@ -60,6 +60,9 @@ export class LocalPlayer extends Player {
|
||||
health = 20;
|
||||
food = 20;
|
||||
saturation = 5;
|
||||
// the attack speed attribute the server sent, and when they last attacked or switched slots, for the indicator
|
||||
attack_speed = 4;
|
||||
last_attack = -Infinity;
|
||||
|
||||
// blocks per second, peaks about 1.25 blocks up with the entity's gravity and drag
|
||||
jump_force = 9.23;
|
||||
@@ -81,6 +84,13 @@ export class LocalPlayer extends Player {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
// like the server's ServerPlayer.attack_strength, from real time so the indicator fills smoothly: 0 right after
|
||||
// attacking, 1 after 20 / attack_speed ticks
|
||||
attack_strength(): number {
|
||||
const ticks = (performance.now() - this.last_attack) / 50;
|
||||
return Math.min(1, Math.max(0, (ticks + 0.5) / (20 / this.attack_speed)));
|
||||
}
|
||||
|
||||
tick() {
|
||||
this.#apply_input(this.client.screen ? NO_INPUT : this.#read_input());
|
||||
this.#prev_eye_height = this.eye_height;
|
||||
|
||||
Reference in New Issue
Block a user