Improve tools system

This commit is contained in:
2026-09-29 17:54:17 -03:00
parent ad7f34a99e
commit 8fe581ea93
39 changed files with 225 additions and 49 deletions
+4 -2
View File
@@ -540,14 +540,16 @@ export class GameServer {
}
// breaks a block the way breaking it by hand does: its components' on_break, then what it drops. without the
// right tool (or without a player) blocks that need one drop nothing
// right tool of a high enough tier (or without a player) blocks that need one drop nothing
destroy_block(x: number, y: number, z: number, player?: ServerPlayer) {
const info = this.world.get_block_info(x, y, z);
if (!info) {
return;
}
const held = EverythingRegistry.get<ItemRegistry>("items", player?.held_item?.type_id ?? "");
const drops = info.drop_table && (!info.requires_tool || held?.tool_type === info.tool_to_break);
const tool = held?.tool;
const right_tool = tool !== undefined && tool.type === info.tool_to_break && tool.tier >= (info.tool_tier ?? 0);
const drops = info.drop_table && (!info.requires_tool || right_tool);
this.set_block(x, y, z, AIR_ID, player);
if (drops) {
this.pop_item(x, y, z, new ItemStack(info.drop_table!));
+2 -2
View File
@@ -490,12 +490,12 @@ export class ModRuntime {
max_stack: (id) => {
const item = EverythingRegistry.get<ItemRegistry>("items", id);
if (!item) throw new Error(`unknown item ${id}`);
return item.max_stack ?? 64;
return item.max_stack ?? (item.tool ? 1 : 64);
},
tool: (id) => {
const item = EverythingRegistry.get<ItemRegistry>("items", id);
if (!item) throw new Error(`unknown item ${id}`);
return item.tool_type;
return item.tool?.type;
},
},
recipes: {