Reset breaking progress when changing blocks
This commit is contained in:
@@ -36,6 +36,11 @@ export class MultiPlayerGameMode {
|
|||||||
const block_info = EverythingRegistry.get_by_id<BlockRegistry>("blocks", hit.block)!;
|
const block_info = EverythingRegistry.get_by_id<BlockRegistry>("blocks", hit.block)!;
|
||||||
const tool = this.#held_item()?.tool;
|
const tool = this.#held_item()?.tool;
|
||||||
|
|
||||||
|
// looking at another block starts it over
|
||||||
|
const pos = this.destroy_pos;
|
||||||
|
if (!pos || pos.x !== hit.x || pos.y !== hit.y || pos.z !== hit.z) {
|
||||||
|
this.destroy_progress = 0;
|
||||||
|
}
|
||||||
this.destroy_pos = { x: hit.x, y: hit.y, z: hit.z };
|
this.destroy_pos = { x: hit.x, y: hit.y, z: hit.z };
|
||||||
this.destroy_time = block_info.toughness ?? 9999;
|
this.destroy_time = block_info.toughness ?? 9999;
|
||||||
this.destroy_progress += TICK_DELTA * (tool && tool.type === block_info.tool_to_break ? tool.speed : 1);
|
this.destroy_progress += TICK_DELTA * (tool && tool.type === block_info.tool_to_break ? tool.speed : 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user