Don't use names for item suggestions

This commit is contained in:
2026-09-27 00:45:00 -03:00
parent 8c7ca92891
commit 52587aabf7
5 changed files with 16 additions and 27 deletions
+3 -2
View File
@@ -28,7 +28,7 @@ import type { WorldgenSetup } from "$/common/generation.ts";
import { CYCLE_TICKS, format_clock, time_of_day, TIMES_OF_DAY } from "$/common/time.ts";
import { can_place, can_stand_on, display_name, placement_target } from "$/common/utils.ts";
import { EXHAUSTION, MAX_HEALTH } from "./vitals.ts";
import { item_argument, ModRuntime, run_guarded, type ServerCommandSource } from "./mod_runtime.ts";
import { ModRuntime, run_guarded, type ServerCommandSource } from "./mod_runtime.ts";
import {
argument,
choice,
@@ -36,6 +36,7 @@ import {
CommandError,
type CommandNode,
integer,
item,
literal,
word,
} from "$/common/commands.ts";
@@ -953,7 +954,7 @@ export class GameServer {
};
register(
literal<ServerCommandSource>("give").describe("Gives you an item").then(
argument<string, ServerCommandSource>("item", item_argument())
argument<string, ServerCommandSource>("item", item())
.executes((context) => give(context, 1))
.then(
argument<number, ServerCommandSource>("count", integer(1, MAX_GIVE))
+3 -11
View File
@@ -2,7 +2,7 @@
// see "Server scripts" in MODS.md. parts not built yet throw when used, saying so
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
import { Container as EngineContainer, ItemStack as EngineItemStack } from "$/common/inventory.ts";
import { display_name, get_state_value, set_state_value } from "$/common/utils.ts";
import { get_state_value, set_state_value } from "$/common/utils.ts";
import type {
BlockComponent,
BlockRef,
@@ -375,8 +375,8 @@ export class ModRuntime {
word,
greedy_string,
choice,
item: () => item_argument(),
block: () => block_argument(display_name_of_block),
item: () => item(),
block: () => block_argument(),
player: () => ({
parse: (text: string) => {
const found = game().players().find((p) => p.name === text);
@@ -667,14 +667,6 @@ function simple_command(name: string, command: Command): CommandNode<ServerComma
);
}
export function item_argument() {
return item((id) => display_name(id));
}
function display_name_of_block(id: string) {
return display_name(id);
}
// the engine's item stacks as mods see them: { id, count, data }
export function item_api(stack: EngineItemStack): ItemStack {
return {