Improve tools system
This commit is contained in:
+2
-2
@@ -28,11 +28,11 @@ export class MultiPlayerGameMode {
|
||||
// called every tick the attack button is held on a block
|
||||
continue_destroy_block(hit: BlockHitResult) {
|
||||
const block_info = EverythingRegistry.get_by_id<BlockRegistry>("blocks", hit.block)!;
|
||||
const tool_type = this.#held_item()?.tool_type;
|
||||
const tool = this.#held_item()?.tool;
|
||||
|
||||
this.destroy_pos = { x: hit.x, y: hit.y, z: hit.z };
|
||||
this.destroy_time = block_info.toughness ?? 9999;
|
||||
this.destroy_progress += TICK_DELTA * (tool_type === block_info.tool_to_break ? 2 : 1);
|
||||
this.destroy_progress += TICK_DELTA * (tool && tool.type === block_info.tool_to_break ? tool.speed : 1);
|
||||
|
||||
if (this.destroy_progress >= this.destroy_time) {
|
||||
// show it right away, the server decides drops and corrects us if it disagrees
|
||||
|
||||
@@ -29,6 +29,9 @@ export function item_tooltip(item: ItemStack): TooltipLine[] {
|
||||
if (info?.food) {
|
||||
lines.push({ text: `Restores ${info.food.nutrition} hunger`, color: FOOD_COLOR });
|
||||
}
|
||||
if (info?.tool) {
|
||||
lines.push({ text: `Durability: ${info.tool.durability}`, color: LORE_COLOR });
|
||||
}
|
||||
const static_lore = info?.lore;
|
||||
for (const lore of [static_lore, item.lore]) {
|
||||
for (const text of lore?.split("\n") ?? []) {
|
||||
|
||||
Reference in New Issue
Block a user