@lzimul/minecraft-mcp 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/SECURITY.md +21 -0
- package/build/app/server.js +10 -0
- package/build/config/dimensions.js +27 -0
- package/build/config/server-info.js +25 -0
- package/build/config/world-limits.js +6 -0
- package/build/data/blocks.js +17532 -0
- package/build/data/items.js +11194 -0
- package/build/data/version.js +1 -0
- package/build/enums/bounding-box.enum.js +5 -0
- package/build/enums/dimension-type.enum.js +6 -0
- package/build/enums/icon-theme.enum.js +5 -0
- package/build/index.js +4 -0
- package/build/interfaces/block.interface.js +1 -0
- package/build/interfaces/data-entry.interface.js +1 -0
- package/build/interfaces/dimension.interface.js +1 -0
- package/build/interfaces/item.interface.js +1 -0
- package/build/interfaces/placed-block.interface.js +1 -0
- package/build/resources/block-resources.js +17 -0
- package/build/resources/data-resources.js +40 -0
- package/build/resources/dimension-resources.js +54 -0
- package/build/resources/index.js +9 -0
- package/build/resources/item-resources.js +17 -0
- package/build/schemas/block-schema.js +27 -0
- package/build/schemas/coordinate-schema.js +12 -0
- package/build/schemas/dimension-schema.js +6 -0
- package/build/schemas/item-schema.js +28 -0
- package/build/tools/block-tools.js +108 -0
- package/build/tools/index.js +6 -0
- package/build/tools/item-tools.js +43 -0
- package/build/tools/result.js +11 -0
- package/build/world/simulated-dimension.js +36 -0
- package/build/world/world-state.js +16 -0
- package/lib/app/server.d.ts +3 -0
- package/lib/app/server.d.ts.map +1 -0
- package/lib/config/dimensions.d.ts +3 -0
- package/lib/config/dimensions.d.ts.map +1 -0
- package/lib/config/server-info.d.ts +15 -0
- package/lib/config/server-info.d.ts.map +1 -0
- package/lib/config/world-limits.d.ts +7 -0
- package/lib/config/world-limits.d.ts.map +1 -0
- package/lib/data/blocks.d.ts +5 -0
- package/lib/data/blocks.d.ts.map +1 -0
- package/lib/data/items.d.ts +5 -0
- package/lib/data/items.d.ts.map +1 -0
- package/lib/data/version.d.ts +2 -0
- package/lib/data/version.d.ts.map +1 -0
- package/lib/enums/bounding-box.enum.d.ts +5 -0
- package/lib/enums/bounding-box.enum.d.ts.map +1 -0
- package/lib/enums/dimension-type.enum.d.ts +6 -0
- package/lib/enums/dimension-type.enum.d.ts.map +1 -0
- package/lib/enums/icon-theme.enum.d.ts +5 -0
- package/lib/enums/icon-theme.enum.d.ts.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/interfaces/block.interface.d.ts +14 -0
- package/lib/interfaces/block.interface.d.ts.map +1 -0
- package/lib/interfaces/data-entry.interface.d.ts +7 -0
- package/lib/interfaces/data-entry.interface.d.ts.map +1 -0
- package/lib/interfaces/dimension.interface.d.ts +10 -0
- package/lib/interfaces/dimension.interface.d.ts.map +1 -0
- package/lib/interfaces/item.interface.d.ts +8 -0
- package/lib/interfaces/item.interface.d.ts.map +1 -0
- package/lib/interfaces/placed-block.interface.d.ts +8 -0
- package/lib/interfaces/placed-block.interface.d.ts.map +1 -0
- package/lib/resources/block-resources.d.ts +3 -0
- package/lib/resources/block-resources.d.ts.map +1 -0
- package/lib/resources/data-resources.d.ts +21 -0
- package/lib/resources/data-resources.d.ts.map +1 -0
- package/lib/resources/dimension-resources.d.ts +4 -0
- package/lib/resources/dimension-resources.d.ts.map +1 -0
- package/lib/resources/index.d.ts +3 -0
- package/lib/resources/index.d.ts.map +1 -0
- package/lib/resources/item-resources.d.ts +3 -0
- package/lib/resources/item-resources.d.ts.map +1 -0
- package/lib/schemas/block-schema.d.ts +20 -0
- package/lib/schemas/block-schema.d.ts.map +1 -0
- package/lib/schemas/coordinate-schema.d.ts +4 -0
- package/lib/schemas/coordinate-schema.d.ts.map +1 -0
- package/lib/schemas/dimension-schema.d.ts +7 -0
- package/lib/schemas/dimension-schema.d.ts.map +1 -0
- package/lib/schemas/item-schema.d.ts +17 -0
- package/lib/schemas/item-schema.d.ts.map +1 -0
- package/lib/tools/block-tools.d.ts +3 -0
- package/lib/tools/block-tools.d.ts.map +1 -0
- package/lib/tools/index.d.ts +3 -0
- package/lib/tools/index.d.ts.map +1 -0
- package/lib/tools/item-tools.d.ts +3 -0
- package/lib/tools/item-tools.d.ts.map +1 -0
- package/lib/tools/result.d.ts +18 -0
- package/lib/tools/result.d.ts.map +1 -0
- package/lib/world/simulated-dimension.d.ts +14 -0
- package/lib/world/simulated-dimension.d.ts.map +1 -0
- package/lib/world/world-state.d.ts +6 -0
- package/lib/world/world-state.d.ts.map +1 -0
- package/package.json +103 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MINECRAFT_DATA_VERSION = '26.1';
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MINECRAFT_BLOCKS, MINECRAFT_BLOCK_COUNT } from '../data/blocks.js';
|
|
2
|
+
import { MINECRAFT_DATA_VERSION } from '../data/version.js';
|
|
3
|
+
import { registerDataEntryResources, registerDataIndexResource } from './data-resources.js';
|
|
4
|
+
export function registerBlockResources(server) {
|
|
5
|
+
registerDataIndexResource(server, {
|
|
6
|
+
name: 'minecraft/blocks',
|
|
7
|
+
uri: 'lzimul://minecraft/blocks',
|
|
8
|
+
title: 'Minecraft Block List',
|
|
9
|
+
description: `Index of all ${MINECRAFT_BLOCK_COUNT} Minecraft blocks (Java Edition ${MINECRAFT_DATA_VERSION})`,
|
|
10
|
+
entries: MINECRAFT_BLOCKS
|
|
11
|
+
});
|
|
12
|
+
registerDataEntryResources(server, {
|
|
13
|
+
pathPrefix: 'blocks',
|
|
14
|
+
category: 'block',
|
|
15
|
+
entries: MINECRAFT_BLOCKS
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function lazyJsonText(build) {
|
|
2
|
+
let cached = '';
|
|
3
|
+
return () => {
|
|
4
|
+
if (!cached) {
|
|
5
|
+
cached = JSON.stringify(build(), null, 2);
|
|
6
|
+
}
|
|
7
|
+
return cached;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function registerDataIndexResource(server, config) {
|
|
11
|
+
const getText = lazyJsonText(() => config.entries.map(entry => ({
|
|
12
|
+
id: entry.id,
|
|
13
|
+
key: entry.key,
|
|
14
|
+
name: entry.name,
|
|
15
|
+
displayName: entry.displayName
|
|
16
|
+
})));
|
|
17
|
+
server.registerResource(config.name, config.uri, {
|
|
18
|
+
title: config.title,
|
|
19
|
+
description: config.description,
|
|
20
|
+
mimeType: 'application/json'
|
|
21
|
+
}, async (uri) => ({
|
|
22
|
+
contents: [
|
|
23
|
+
{ uri: uri.href, mimeType: 'application/json', text: getText() }
|
|
24
|
+
]
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
export function registerDataEntryResources(server, config) {
|
|
28
|
+
for (const entry of config.entries) {
|
|
29
|
+
const getText = lazyJsonText(() => entry);
|
|
30
|
+
server.registerResource(`minecraft/${config.pathPrefix}/${entry.name}`, `lzimul://minecraft/${config.pathPrefix}/${entry.name}`, {
|
|
31
|
+
title: `${entry.displayName} (${entry.key})`,
|
|
32
|
+
description: `Properties of the Minecraft ${config.category} ${entry.key}`,
|
|
33
|
+
mimeType: 'application/json'
|
|
34
|
+
}, async (uri) => ({
|
|
35
|
+
contents: [
|
|
36
|
+
{ uri: uri.href, mimeType: 'application/json', text: getText() }
|
|
37
|
+
]
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { toBlockInfo } from '../schemas/block-schema.js';
|
|
2
|
+
import { getDimension, listDimensions } from '../world/world-state.js';
|
|
3
|
+
function dimensionState(dimension) {
|
|
4
|
+
const simulated = getDimension(dimension.type);
|
|
5
|
+
return {
|
|
6
|
+
key: dimension.key,
|
|
7
|
+
type: dimension.type,
|
|
8
|
+
displayName: dimension.displayName,
|
|
9
|
+
minY: dimension.minY,
|
|
10
|
+
maxY: dimension.maxY,
|
|
11
|
+
hasSkylight: dimension.hasSkylight,
|
|
12
|
+
modifiedBlockCount: simulated.modifiedBlockCount,
|
|
13
|
+
placedBlocks: simulated.placedBlocks
|
|
14
|
+
.map(placed => ({
|
|
15
|
+
x: placed.x,
|
|
16
|
+
y: placed.y,
|
|
17
|
+
z: placed.z,
|
|
18
|
+
block: toBlockInfo(placed.block)
|
|
19
|
+
}))
|
|
20
|
+
.sort((a, b) => a.x - b.x || a.y - b.y || a.z - b.z)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function registerDimensionIndexResource(server) {
|
|
24
|
+
server.registerResource('minecraft/dimensions', 'lzimul://minecraft/dimensions', {
|
|
25
|
+
title: 'Minecraft Dimension List',
|
|
26
|
+
description: 'Index of the simulated Minecraft dimensions',
|
|
27
|
+
mimeType: 'application/json'
|
|
28
|
+
}, async (uri) => ({
|
|
29
|
+
contents: [
|
|
30
|
+
{
|
|
31
|
+
uri: uri.href,
|
|
32
|
+
mimeType: 'application/json',
|
|
33
|
+
text: JSON.stringify(listDimensions().map(dimensionState), null, 2)
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
export function registerDimensionResources(server) {
|
|
39
|
+
for (const dimension of listDimensions()) {
|
|
40
|
+
server.registerResource(`minecraft/dimensions/${dimension.type}`, `lzimul://minecraft/dimensions/${dimension.type}`, {
|
|
41
|
+
title: `${dimension.displayName} (${dimension.key})`,
|
|
42
|
+
description: `Simulated state of the ${dimension.displayName} dimension`,
|
|
43
|
+
mimeType: 'application/json'
|
|
44
|
+
}, async (uri) => ({
|
|
45
|
+
contents: [
|
|
46
|
+
{
|
|
47
|
+
uri: uri.href,
|
|
48
|
+
mimeType: 'application/json',
|
|
49
|
+
text: JSON.stringify(dimensionState(dimension), null, 2)
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { registerBlockResources } from './block-resources.js';
|
|
2
|
+
import { registerDimensionIndexResource, registerDimensionResources } from './dimension-resources.js';
|
|
3
|
+
import { registerItemResources } from './item-resources.js';
|
|
4
|
+
export function registerResources(server) {
|
|
5
|
+
registerBlockResources(server);
|
|
6
|
+
registerItemResources(server);
|
|
7
|
+
registerDimensionIndexResource(server);
|
|
8
|
+
registerDimensionResources(server);
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MINECRAFT_ITEMS, MINECRAFT_ITEM_COUNT } from '../data/items.js';
|
|
2
|
+
import { MINECRAFT_DATA_VERSION } from '../data/version.js';
|
|
3
|
+
import { registerDataEntryResources, registerDataIndexResource } from './data-resources.js';
|
|
4
|
+
export function registerItemResources(server) {
|
|
5
|
+
registerDataIndexResource(server, {
|
|
6
|
+
name: 'minecraft/items',
|
|
7
|
+
uri: 'lzimul://minecraft/items',
|
|
8
|
+
title: 'Minecraft Item List',
|
|
9
|
+
description: `Index of all ${MINECRAFT_ITEM_COUNT} Minecraft items (Java Edition ${MINECRAFT_DATA_VERSION})`,
|
|
10
|
+
entries: MINECRAFT_ITEMS
|
|
11
|
+
});
|
|
12
|
+
registerDataEntryResources(server, {
|
|
13
|
+
pathPrefix: 'items',
|
|
14
|
+
category: 'item',
|
|
15
|
+
entries: MINECRAFT_ITEMS
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export const blockInfoSchema = z.object({
|
|
3
|
+
key: z.string(),
|
|
4
|
+
name: z.string(),
|
|
5
|
+
displayName: z.string(),
|
|
6
|
+
hardness: z.number(),
|
|
7
|
+
resistance: z.number(),
|
|
8
|
+
diggable: z.boolean(),
|
|
9
|
+
transparent: z.boolean(),
|
|
10
|
+
emitLight: z.number(),
|
|
11
|
+
filterLight: z.number(),
|
|
12
|
+
boundingBox: z.string()
|
|
13
|
+
});
|
|
14
|
+
export function toBlockInfo(block) {
|
|
15
|
+
return {
|
|
16
|
+
key: block.key,
|
|
17
|
+
name: block.name,
|
|
18
|
+
displayName: block.displayName,
|
|
19
|
+
hardness: block.hardness,
|
|
20
|
+
resistance: block.resistance,
|
|
21
|
+
diggable: block.diggable,
|
|
22
|
+
transparent: block.transparent,
|
|
23
|
+
emitLight: block.emitLight,
|
|
24
|
+
filterLight: block.filterLight,
|
|
25
|
+
boundingBox: block.boundingBox
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { WORLD_LIMITS } from '../config/world-limits.js';
|
|
3
|
+
export const horizontalCoordinate = z
|
|
4
|
+
.number()
|
|
5
|
+
.int()
|
|
6
|
+
.min(WORLD_LIMITS.minHorizontal)
|
|
7
|
+
.max(WORLD_LIMITS.maxHorizontal);
|
|
8
|
+
export const verticalCoordinate = z
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.min(WORLD_LIMITS.minVertical)
|
|
12
|
+
.max(WORLD_LIMITS.maxVertical);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export const itemInfoSchema = z.object({
|
|
3
|
+
key: z.string(),
|
|
4
|
+
name: z.string(),
|
|
5
|
+
displayName: z.string(),
|
|
6
|
+
stackSize: z.number(),
|
|
7
|
+
maxDurability: z.number().optional(),
|
|
8
|
+
enchantCategories: z.array(z.string()).optional(),
|
|
9
|
+
repairWith: z.array(z.string()).optional()
|
|
10
|
+
});
|
|
11
|
+
export function toItemInfo(item) {
|
|
12
|
+
const info = {
|
|
13
|
+
key: item.key,
|
|
14
|
+
name: item.name,
|
|
15
|
+
displayName: item.displayName,
|
|
16
|
+
stackSize: item.stackSize
|
|
17
|
+
};
|
|
18
|
+
if (item.maxDurability) {
|
|
19
|
+
info.maxDurability = item.maxDurability;
|
|
20
|
+
}
|
|
21
|
+
if (item.enchantCategories) {
|
|
22
|
+
info.enchantCategories = [...item.enchantCategories];
|
|
23
|
+
}
|
|
24
|
+
if (item.repairWith) {
|
|
25
|
+
info.repairWith = [...item.repairWith];
|
|
26
|
+
}
|
|
27
|
+
return info;
|
|
28
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { getBlockByName } from '../data/blocks.js';
|
|
3
|
+
import { blockInfoSchema, toBlockInfo } from '../schemas/block-schema.js';
|
|
4
|
+
import { horizontalCoordinate, verticalCoordinate } from '../schemas/coordinate-schema.js';
|
|
5
|
+
import { dimensionSchema } from '../schemas/dimension-schema.js';
|
|
6
|
+
import { getDimension } from '../world/world-state.js';
|
|
7
|
+
import { toolError } from './result.js';
|
|
8
|
+
function rangeError(info, x, y, z) {
|
|
9
|
+
return toolError(`Coordinates (${x}, ${y}, ${z}) are out of range in ${info.displayName} (Y: ${info.minY} to ${info.maxY - 1}).`);
|
|
10
|
+
}
|
|
11
|
+
export function registerBlockTools(server) {
|
|
12
|
+
server.registerTool('getBlock', {
|
|
13
|
+
title: 'Get Block',
|
|
14
|
+
description: 'Get the block at the given coordinates in the given dimension, including its properties (name, hardness, light level, etc.). Each dimension has its own world state; unmodified coordinates return air (minecraft:air).',
|
|
15
|
+
inputSchema: z.object({
|
|
16
|
+
x: horizontalCoordinate.describe('X coordinate (-30000000 to 30000000)'),
|
|
17
|
+
y: verticalCoordinate.describe('Y coordinate, within the dimension height range'),
|
|
18
|
+
z: horizontalCoordinate.describe('Z coordinate (-30000000 to 30000000)'),
|
|
19
|
+
dimension: dimensionSchema.describe('Dimension: "overworld" (default), "the_nether" or "the_end"')
|
|
20
|
+
}),
|
|
21
|
+
outputSchema: z.object({
|
|
22
|
+
x: z.number(),
|
|
23
|
+
y: z.number(),
|
|
24
|
+
z: z.number(),
|
|
25
|
+
dimension: z.string(),
|
|
26
|
+
block: blockInfoSchema
|
|
27
|
+
}),
|
|
28
|
+
annotations: {
|
|
29
|
+
readOnlyHint: true,
|
|
30
|
+
idempotentHint: true,
|
|
31
|
+
openWorldHint: false
|
|
32
|
+
}
|
|
33
|
+
}, async ({ x, y, z, dimension: dimensionType }) => {
|
|
34
|
+
const dimension = getDimension(dimensionType);
|
|
35
|
+
if (!dimension.contains(x, y, z)) {
|
|
36
|
+
return rangeError(dimension.info, x, y, z);
|
|
37
|
+
}
|
|
38
|
+
const block = dimension.getBlock(x, y, z);
|
|
39
|
+
return {
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: `Block at (${x}, ${y}, ${z}) in ${dimension.info.displayName} is ${block.displayName} (${block.key})`
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
structuredContent: {
|
|
47
|
+
x,
|
|
48
|
+
y,
|
|
49
|
+
z,
|
|
50
|
+
dimension: dimension.info.key,
|
|
51
|
+
block: toBlockInfo(block)
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
server.registerTool('setBlock', {
|
|
56
|
+
title: 'Set Block',
|
|
57
|
+
description: 'Place a block at the given coordinates in the given dimension and return the replaced block. Each dimension has its own world state. blockType is a block id such as "minecraft:stone" or "stone"; see the resource lzimul://minecraft/blocks for the full list.',
|
|
58
|
+
inputSchema: z.object({
|
|
59
|
+
x: horizontalCoordinate.describe('X coordinate (-30000000 to 30000000)'),
|
|
60
|
+
y: verticalCoordinate.describe('Y coordinate, within the dimension height range'),
|
|
61
|
+
z: horizontalCoordinate.describe('Z coordinate (-30000000 to 30000000)'),
|
|
62
|
+
blockType: z
|
|
63
|
+
.string()
|
|
64
|
+
.min(1)
|
|
65
|
+
.describe('Block id, such as "minecraft:stone"'),
|
|
66
|
+
dimension: dimensionSchema.describe('Dimension: "overworld" (default), "the_nether" or "the_end"')
|
|
67
|
+
}),
|
|
68
|
+
outputSchema: z.object({
|
|
69
|
+
x: z.number(),
|
|
70
|
+
y: z.number(),
|
|
71
|
+
z: z.number(),
|
|
72
|
+
dimension: z.string(),
|
|
73
|
+
block: blockInfoSchema,
|
|
74
|
+
previous: blockInfoSchema
|
|
75
|
+
}),
|
|
76
|
+
annotations: {
|
|
77
|
+
destructiveHint: true,
|
|
78
|
+
idempotentHint: true,
|
|
79
|
+
openWorldHint: false
|
|
80
|
+
}
|
|
81
|
+
}, async ({ x, y, z, blockType, dimension: dimensionType }) => {
|
|
82
|
+
const dimension = getDimension(dimensionType);
|
|
83
|
+
if (!dimension.contains(x, y, z)) {
|
|
84
|
+
return rangeError(dimension.info, x, y, z);
|
|
85
|
+
}
|
|
86
|
+
const block = getBlockByName(blockType);
|
|
87
|
+
if (!block) {
|
|
88
|
+
return toolError(`Unknown block "${blockType}". Use a block id such as "minecraft:stone"; see the resource lzimul://minecraft/blocks for the full list.`);
|
|
89
|
+
}
|
|
90
|
+
const previous = dimension.setBlock(x, y, z, block);
|
|
91
|
+
return {
|
|
92
|
+
content: [
|
|
93
|
+
{
|
|
94
|
+
type: 'text',
|
|
95
|
+
text: `Block set at (${x}, ${y}, ${z}) in ${dimension.info.displayName}: ${previous.displayName} (${previous.key}) -> ${block.displayName} (${block.key})`
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
structuredContent: {
|
|
99
|
+
x,
|
|
100
|
+
y,
|
|
101
|
+
z,
|
|
102
|
+
dimension: dimension.info.key,
|
|
103
|
+
block: toBlockInfo(block),
|
|
104
|
+
previous: toBlockInfo(previous)
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { getItemByName } from '../data/items.js';
|
|
3
|
+
import { itemInfoSchema, toItemInfo } from '../schemas/item-schema.js';
|
|
4
|
+
import { toolError } from './result.js';
|
|
5
|
+
export function registerItemTools(server) {
|
|
6
|
+
server.registerTool('getItem', {
|
|
7
|
+
title: 'Get Item',
|
|
8
|
+
description: 'Get the properties of a Minecraft item by id (stack size, durability, enchantment categories, etc.). See the resource lzimul://minecraft/items for the full list.',
|
|
9
|
+
inputSchema: z.object({
|
|
10
|
+
item: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.describe('Item id, such as "minecraft:diamond_sword" or "diamond_sword"')
|
|
14
|
+
}),
|
|
15
|
+
outputSchema: z.object({
|
|
16
|
+
item: itemInfoSchema
|
|
17
|
+
}),
|
|
18
|
+
annotations: {
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
idempotentHint: true,
|
|
21
|
+
openWorldHint: false
|
|
22
|
+
}
|
|
23
|
+
}, async ({ item: itemId }) => {
|
|
24
|
+
const item = getItemByName(itemId);
|
|
25
|
+
if (!item) {
|
|
26
|
+
return toolError(`Unknown item "${itemId}". Use an item id such as "minecraft:diamond_sword"; see the resource lzimul://minecraft/items for the full list.`);
|
|
27
|
+
}
|
|
28
|
+
const durability = item.maxDurability
|
|
29
|
+
? `, durability ${item.maxDurability}`
|
|
30
|
+
: '';
|
|
31
|
+
return {
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: 'text',
|
|
35
|
+
text: `${item.displayName} (${item.key}): stack size ${item.stackSize}${durability}`
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
structuredContent: {
|
|
39
|
+
item: toItemInfo(item)
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { WORLD_LIMITS } from '../config/world-limits.js';
|
|
2
|
+
import { getBlockByName, MINECRAFT_BLOCKS } from '../data/blocks.js';
|
|
3
|
+
const AIR = getBlockByName('air') ?? MINECRAFT_BLOCKS[0];
|
|
4
|
+
function coordinateKey(x, y, z) {
|
|
5
|
+
return `${x},${y},${z}`;
|
|
6
|
+
}
|
|
7
|
+
export class SimulatedDimension {
|
|
8
|
+
info;
|
|
9
|
+
blocks = new Map();
|
|
10
|
+
constructor(info) {
|
|
11
|
+
this.info = info;
|
|
12
|
+
}
|
|
13
|
+
get modifiedBlockCount() {
|
|
14
|
+
return this.blocks.size;
|
|
15
|
+
}
|
|
16
|
+
get placedBlocks() {
|
|
17
|
+
return [...this.blocks.values()];
|
|
18
|
+
}
|
|
19
|
+
contains(x, y, z) {
|
|
20
|
+
return (y >= this.info.minY &&
|
|
21
|
+
y < this.info.maxY &&
|
|
22
|
+
x >= WORLD_LIMITS.minHorizontal &&
|
|
23
|
+
x <= WORLD_LIMITS.maxHorizontal &&
|
|
24
|
+
z >= WORLD_LIMITS.minHorizontal &&
|
|
25
|
+
z <= WORLD_LIMITS.maxHorizontal);
|
|
26
|
+
}
|
|
27
|
+
getBlock(x, y, z) {
|
|
28
|
+
return this.blocks.get(coordinateKey(x, y, z))?.block ?? AIR;
|
|
29
|
+
}
|
|
30
|
+
setBlock(x, y, z, block) {
|
|
31
|
+
const key = coordinateKey(x, y, z);
|
|
32
|
+
const previous = this.blocks.get(key)?.block ?? AIR;
|
|
33
|
+
this.blocks.set(key, { x, y, z, block });
|
|
34
|
+
return previous;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DIMENSIONS } from '../config/dimensions.js';
|
|
2
|
+
import { SimulatedDimension } from './simulated-dimension.js';
|
|
3
|
+
const dimensions = new Map(DIMENSIONS.map(dimension => [
|
|
4
|
+
dimension.type,
|
|
5
|
+
new SimulatedDimension(dimension)
|
|
6
|
+
]));
|
|
7
|
+
export function getDimension(type) {
|
|
8
|
+
const dimension = dimensions.get(type);
|
|
9
|
+
if (!dimension) {
|
|
10
|
+
throw new Error(`Unknown dimension: ${type}`);
|
|
11
|
+
}
|
|
12
|
+
return dimension;
|
|
13
|
+
}
|
|
14
|
+
export function listDimensions() {
|
|
15
|
+
return DIMENSIONS;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/app/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAMzD,wBAAgB,YAAY,IAAI,SAAS,CAKxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimensions.d.ts","sourceRoot":"","sources":["../../src/config/dimensions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEvE,eAAO,MAAM,UAAU,EAAE,SAAS,UAAU,EAyB3C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EIconTheme } from '../enums/icon-theme.enum.js';
|
|
2
|
+
export declare const SERVER_INFO: {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
version: string;
|
|
7
|
+
websiteUrl: string;
|
|
8
|
+
icons: {
|
|
9
|
+
src: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
sizes: string[];
|
|
12
|
+
theme: EIconTheme;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=server-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-info.d.ts","sourceRoot":"","sources":["../../src/config/server-info.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,eAAO,MAAM,WAAW;;;;;;;;;;;;CAoBvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-limits.d.ts","sourceRoot":"","sources":["../../src/config/world-limits.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;CAKf,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IBlock } from '../interfaces/block.interface.js';
|
|
2
|
+
export declare const MINECRAFT_BLOCKS: readonly IBlock[];
|
|
3
|
+
export declare const MINECRAFT_BLOCK_COUNT: number;
|
|
4
|
+
export declare function getBlockByName(name: string): IBlock | undefined;
|
|
5
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/data/blocks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAiniB7C,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAA0B,CAAC;AAQ7D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IItem } from '../interfaces/item.interface.js';
|
|
2
|
+
export declare const MINECRAFT_ITEMS: readonly IItem[];
|
|
3
|
+
export declare const MINECRAFT_ITEM_COUNT: number;
|
|
4
|
+
export declare function getItemByName(name: string): IItem | undefined;
|
|
5
|
+
//# sourceMappingURL=items.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/data/items.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAE7D,eAAO,MAAM,eAAe,EAAE,SAAS,KAAK,EAg7V3C,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAyB,CAAC;AAQ3D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAE7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/data/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounding-box.enum.d.ts","sourceRoot":"","sources":["../../src/enums/bounding-box.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,KAAK,UAAU;IACf,KAAK,UAAU;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimension-type.enum.d.ts","sourceRoot":"","sources":["../../src/enums/dimension-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,SAAS,cAAc;IACvB,SAAS,eAAe;IACxB,MAAM,YAAY;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-theme.enum.d.ts","sourceRoot":"","sources":["../../src/enums/icon-theme.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;CACd"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EBoundingBox } from '../enums/bounding-box.enum.js';
|
|
2
|
+
import type { IDataEntry } from './data-entry.interface.js';
|
|
3
|
+
export interface IBlock extends IDataEntry {
|
|
4
|
+
readonly hardness: number;
|
|
5
|
+
readonly resistance: number;
|
|
6
|
+
readonly stackSize: number;
|
|
7
|
+
readonly diggable: boolean;
|
|
8
|
+
readonly material: string;
|
|
9
|
+
readonly transparent: boolean;
|
|
10
|
+
readonly emitLight: number;
|
|
11
|
+
readonly filterLight: number;
|
|
12
|
+
readonly boundingBox: EBoundingBox;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=block.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/block.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;CACpC"}
|