Messy but working chicken
This commit is contained in:
@@ -55,6 +55,7 @@ import {
|
||||
type SavedItemEntity,
|
||||
} from "./entity/item_entity.ts";
|
||||
import { EntityManager } from "./entity/entity_manager.ts";
|
||||
import { create_entity, entity_type_ids } from "./entity/entity_types.ts";
|
||||
import type { SavedEntity } from "./entity/entity.ts";
|
||||
|
||||
// how far from a player's eyes a block can be changed, a bit more than the client's reach
|
||||
@@ -1046,6 +1047,26 @@ export class GameServer {
|
||||
),
|
||||
);
|
||||
|
||||
// TODO: only let operators do this
|
||||
register(
|
||||
literal<ServerCommandSource>("summon").describe("Spawns an entity where you are").then(
|
||||
argument<string, ServerCommandSource>("entity", word())
|
||||
.suggests((partial) =>
|
||||
entity_type_ids().filter((id) => id.startsWith(partial)).map((text) => ({ text }))
|
||||
)
|
||||
.executes((context) => {
|
||||
const id = context.get<string>("entity");
|
||||
const entity = entity_type_ids().includes(id) ? create_entity(this.entities, id) : undefined;
|
||||
if (!entity) throw new CommandError(`There's no entity ${id}`);
|
||||
const player = context.source.server_player;
|
||||
entity.set_position(player.x, player.y, player.z);
|
||||
entity.yaw = entity.head_yaw = player.yaw;
|
||||
this.entities.add_entity(entity);
|
||||
context.source.send_message(`Summoned ${id}`);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
register(
|
||||
literal<ServerCommandSource>("tps").describe("Shows how the game loop keeps up").executes((context) => {
|
||||
if (!this.loop) {
|
||||
|
||||
Reference in New Issue
Block a user