@zardoy/flying-squid 0.0.121 → 0.0.123

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.
@@ -153,11 +153,16 @@ const server = async function (serv, options) {
153
153
  };
154
154
  const generationModule = generations_1.default[generation.name] ? generations_1.default[generation.name] : require(generation.name);
155
155
  const genOpts = generation.options;
156
- const originalGenerator = typeof options.chunkTemplate === 'string'
157
- ? (0, template_1.makeTemplateGenerator)(options.chunkTemplate, generationOptions, options.blockMap)
158
- : typeof genOpts.chunkTemplate === 'string'
159
- ? (0, template_1.makeTemplateGenerator)(genOpts.chunkTemplate, generationOptions, genOpts.blockMap)
160
- : generationModule(generationOptions);
156
+ const templateStr = typeof options.chunkTemplate === 'string' ? options.chunkTemplate
157
+ : typeof genOpts.chunkTemplate === 'string' ? genOpts.chunkTemplate
158
+ : undefined;
159
+ const templateBlockMap = options.blockMap ?? genOpts.blockMap;
160
+ const originalGenerator = templateStr !== undefined
161
+ ? (0, template_1.makeTemplateGenerator)(templateStr, generationOptions, templateBlockMap)
162
+ : generationModule(generationOptions);
163
+ if (templateStr !== undefined) {
164
+ serv.spawnPoint = (0, template_1.getTemplateSpawnPoint)(generationOptions);
165
+ }
161
166
  serv.overworldOriginalGenerator = originalGenerator;
162
167
  serv.overworld = new World((chunkX, chunkZ) => {
163
168
  return serv.overworldGeneratorOverride ? serv.overworldGeneratorOverride(chunkX, chunkZ, generationOptions) : originalGenerator(chunkX, chunkZ, generationOptions);
@@ -1,3 +1,4 @@
1
+ import { Vec3 } from 'vec3';
1
2
  /**
2
3
  * Default single-character → Minecraft block-name mapping used by the
3
4
  * chunk-template generator. Users can override any entry (or add new ones)
@@ -48,18 +49,29 @@ export interface LayerData {
48
49
  * "Y0: 16C | 16C Y1: C14AC | C14AC"
49
50
  */
50
51
  export declare function parseTemplate(templateStr: string): LayerData[];
52
+ /**
53
+ * Returns the deterministic spawn point for a chunk-template world.
54
+ * The player is placed one block above the Y0 floor (`baseY + 1`) at a
55
+ * fixed 10-block inset from the template's (0, 0) corner.
56
+ */
57
+ export declare function getTemplateSpawnPoint(options: any): Vec3;
51
58
  /**
52
59
  * Returns a `(chunkX, chunkZ) => Chunk` generator that paints the decoded
53
- * template structure into the world starting at (0, Y, 0).
60
+ * template structure into the world starting at (0, baseY, 0).
61
+ *
62
+ * A stone block is guaranteed directly below the spawn position so the
63
+ * player always has something solid to land on regardless of what the
64
+ * template has at that cell.
54
65
  *
55
- * Chunks that do not overlap the structure are still returned but contain
56
- * only air + full sky-light (compatible with every generator contract).
66
+ * Chunks that do not overlap the structure are returned as empty (air +
67
+ * full sky-light), compatible with every generator contract.
57
68
  *
58
69
  * @param templateStr Encoded template string (see parseTemplate).
59
70
  * @param options generationOptions forwarded from world.ts
60
- * (must include `version`, and may include `minY` /
61
- * `worldHeight`).
62
- * @param userBlockMap Optional extra / override mappings on top of
63
- * DEFAULT_BLOCK_MAP. char → Minecraft block name.
71
+ * (must include `version`; may include `minY`,
72
+ * `worldHeight`, `baseY`).
73
+ * @param userBlockMap Optional extra / override char→name mappings on top
74
+ * of DEFAULT_BLOCK_MAP. Accepts a string
75
+ * (`"C=cobblestone, G=glass"`) or a plain object.
64
76
  */
65
77
  export declare function makeTemplateGenerator(templateStr: string, options: any, userBlockMap?: Record<string, string> | string): (chunkX: number, chunkZ: number) => any;
@@ -4,8 +4,10 @@ exports.DEFAULT_BLOCK_MAP = void 0;
4
4
  exports.parseBlockMap = parseBlockMap;
5
5
  exports.decodeRLE = decodeRLE;
6
6
  exports.parseTemplate = parseTemplate;
7
+ exports.getTemplateSpawnPoint = getTemplateSpawnPoint;
7
8
  exports.makeTemplateGenerator = makeTemplateGenerator;
8
9
  const vec3_1 = require("vec3");
10
+ const templateExamples_1 = require("./templateExamples");
9
11
  /**
10
12
  * Default single-character → Minecraft block-name mapping used by the
11
13
  * chunk-template generator. Users can override any entry (or add new ones)
@@ -38,6 +40,13 @@ exports.DEFAULT_BLOCK_MAP = {
38
40
  Q: 'quartz_block',
39
41
  U: 'sea_lantern',
40
42
  V: 'stone_slab',
43
+ // Lowercase additions — natural / map-starter blocks
44
+ g: 'grass_block',
45
+ l: 'oak_leaves',
46
+ c: 'chest',
47
+ w: 'water',
48
+ v: 'lava',
49
+ s: 'sand',
41
50
  };
42
51
  // ---------------------------------------------------------------------------
43
52
  // Block-map parser
@@ -126,25 +135,43 @@ function parseTemplate(templateStr) {
126
135
  // ---------------------------------------------------------------------------
127
136
  // Chunk generator factory
128
137
  // ---------------------------------------------------------------------------
138
+ /** X/Z offset inward from the (0, 0) corner used as the template spawn. */
139
+ const SPAWN_OFFSET = 10;
140
+ /**
141
+ * Returns the deterministic spawn point for a chunk-template world.
142
+ * The player is placed one block above the Y0 floor (`baseY + 1`) at a
143
+ * fixed 10-block inset from the template's (0, 0) corner.
144
+ */
145
+ function getTemplateSpawnPoint(options) {
146
+ const baseY = options.baseY ?? 64;
147
+ return new vec3_1.Vec3(SPAWN_OFFSET, baseY + 1, SPAWN_OFFSET);
148
+ }
129
149
  /**
130
150
  * Returns a `(chunkX, chunkZ) => Chunk` generator that paints the decoded
131
- * template structure into the world starting at (0, Y, 0).
151
+ * template structure into the world starting at (0, baseY, 0).
152
+ *
153
+ * A stone block is guaranteed directly below the spawn position so the
154
+ * player always has something solid to land on regardless of what the
155
+ * template has at that cell.
132
156
  *
133
- * Chunks that do not overlap the structure are still returned but contain
134
- * only air + full sky-light (compatible with every generator contract).
157
+ * Chunks that do not overlap the structure are returned as empty (air +
158
+ * full sky-light), compatible with every generator contract.
135
159
  *
136
160
  * @param templateStr Encoded template string (see parseTemplate).
137
161
  * @param options generationOptions forwarded from world.ts
138
- * (must include `version`, and may include `minY` /
139
- * `worldHeight`).
140
- * @param userBlockMap Optional extra / override mappings on top of
141
- * DEFAULT_BLOCK_MAP. char → Minecraft block name.
162
+ * (must include `version`; may include `minY`,
163
+ * `worldHeight`, `baseY`).
164
+ * @param userBlockMap Optional extra / override char→name mappings on top
165
+ * of DEFAULT_BLOCK_MAP. Accepts a string
166
+ * (`"C=cobblestone, G=glass"`) or a plain object.
142
167
  */
143
168
  function makeTemplateGenerator(templateStr, options, userBlockMap) {
144
169
  /* eslint-disable @typescript-eslint/no-require-imports */
145
170
  const Chunk = require('prismarine-chunk')(options.version);
146
171
  const mcData = require('minecraft-data')(options.version);
147
172
  /* eslint-enable @typescript-eslint/no-require-imports */
173
+ // Resolve `[example_name]` shorthand to the full template string.
174
+ templateStr = (0, templateExamples_1.resolveTemplate)(templateStr);
148
175
  const minY = options.minY ?? 0;
149
176
  const worldHeight = options.worldHeight ?? 256;
150
177
  const baseY = options.baseY ?? 64;
@@ -186,6 +213,16 @@ function makeTemplateGenerator(templateStr, options, userBlockMap) {
186
213
  }
187
214
  }
188
215
  }
216
+ // Guarantee a solid block directly below the spawn position so the player
217
+ // always has something to land on, but defer to whatever the template
218
+ // intended at that exact cell (e.g. skyblock places grass there).
219
+ const spawnPlatformKey = `${SPAWN_OFFSET},${baseY},${SPAWN_OFFSET}`;
220
+ if (!blockGrid.has(spawnPlatformKey)) {
221
+ const spawnPlatformId = theFlattening
222
+ ? mcData.blocksByName.stone.minStateId
223
+ : mcData.blocksByName.stone.id;
224
+ blockGrid.set(spawnPlatformKey, spawnPlatformId);
225
+ }
189
226
  return (chunkX, chunkZ) => {
190
227
  const chunk = new Chunk({ minY, worldHeight });
191
228
  // Full sky-light (standard for surface/flat worlds)
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Built-in `chunkTemplate` examples. Reference one from config with:
3
+ *
4
+ * "chunkTemplate": "[castle]" // case-insensitive
5
+ * "chunkTemplate": "[pirate_ship]"
6
+ * "chunkTemplate": "[skyscraper]"
7
+ *
8
+ * Each template uses the strict `Y<n>: row | row | …` format documented on
9
+ * `parseTemplate`. All builds start at world Y `baseY` (default 64) and
10
+ * extend upward. Default `blockMap` is assumed (C=cobblestone, M=mossy,
11
+ * G=glass, R=red_wool, D=dark_oak_planks, I=iron_block, S=stone, B=bricks,
12
+ * W=oak_planks, Y=gold_block, T=stone_bricks, Q=quartz_block, H=sandstone,
13
+ * U=sea_lantern, F=oak_log, …).
14
+ */
15
+ export declare const TEMPLATE_EXAMPLES: Record<string, string>;
16
+ /**
17
+ * If `templateStr` is exactly `[name]` (whitespace tolerated), return the
18
+ * matching built-in example; otherwise return `templateStr` unchanged.
19
+ *
20
+ * Throws when the example name is not registered.
21
+ */
22
+ export declare function resolveTemplate(templateStr: string): string;
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ /**
3
+ * Built-in `chunkTemplate` examples. Reference one from config with:
4
+ *
5
+ * "chunkTemplate": "[castle]" // case-insensitive
6
+ * "chunkTemplate": "[pirate_ship]"
7
+ * "chunkTemplate": "[skyscraper]"
8
+ *
9
+ * Each template uses the strict `Y<n>: row | row | …` format documented on
10
+ * `parseTemplate`. All builds start at world Y `baseY` (default 64) and
11
+ * extend upward. Default `blockMap` is assumed (C=cobblestone, M=mossy,
12
+ * G=glass, R=red_wool, D=dark_oak_planks, I=iron_block, S=stone, B=bricks,
13
+ * W=oak_planks, Y=gold_block, T=stone_bricks, Q=quartz_block, H=sandstone,
14
+ * U=sea_lantern, F=oak_log, …).
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TEMPLATE_EXAMPLES = void 0;
18
+ exports.resolveTemplate = resolveTemplate;
19
+ // ---------------------------------------------------------------------------
20
+ // CASTLE — 16×16×16 Classic medieval keep with corner towers, gate, banners.
21
+ // ---------------------------------------------------------------------------
22
+ const CASTLE = `
23
+ Y0: 4C4M4C4M | 4M8C4M | 4C4M4C4M | 4M8C4M | 4C4M4C4M | 4M8C4M | 4C4M4C4M | 4M8C4M
24
+ | 4C4M4C4M | 4M8C4M | 4C4M4C4M | 4M8C4M | 4C4M4C4M | 4M8C4M | 4C4M4C4M | 4M8C4M
25
+ Y1: 16C | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC
26
+ | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | 16C
27
+ Y2: 16C | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC
28
+ | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | 16C
29
+ Y3: 16C | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC
30
+ | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | 16C
31
+ Y4: 16C | C14AC | 6C4G6C | C14AC | C14AC | C14AC | C14AC | C14AC
32
+ | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | 6C4G6C | 16C
33
+ Y5: 16C | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC
34
+ | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | 16C
35
+ Y6: 16C | C14AC | 6C4G6C | C14AC | C14AC | C14AC | C14AC | C14AC
36
+ | C14AC | C14AC | C14AC | C14AC | C14AC | C14AC | 6C4G6C | 16C
37
+ Y7: CACACACACACACACA | C14AC | C14AC | C14AC | 16A | 16A | 16A | 16A
38
+ | 16A | 16A | 16A | 16A | C14AC | C14AC | C14AC | CACACACACACACACA
39
+ Y8: 4C8A4C | 4C8A4C | 4C8A4C | 4C8A4C | 8A8A | 8A8A | 8A8A | 8A8A
40
+ | 8A8A | 8A8A | 8A8A | 8A8A | 4C8A4C | 4C8A4C | 4C8A4C | 4C8A4C
41
+ Y9: 4C8A4C | C2AC8AC2AC | C2AC8AC2AC | 4C8A4C | 16A | 16A | 16A | 16A
42
+ | 16A | 16A | 16A | 16A | 4C8A4C | C2AC8AC2AC | C2AC8AC2AC | 4C8A4C
43
+ Y10: 4C8A4C | C2AC8AC2AC | C2AC8AC2AC | 4C8A4C | 16A | 16A | 16A | 16A
44
+ | 16A | 16A | 16A | 16A | 4C8A4C | C2AC8AC2AC | C2AC8AC2AC | 4C8A4C
45
+ Y11: 4C8A4C | CGC1AC8ACGC | CGC1AC8ACGC | 4C8A4C | 16A | 16A | 16A | 16A
46
+ | 16A | 16A | 16A | 16A | 4C8A4C | CGC1AC8ACGC | CGC1AC8ACGC | 4C8A4C
47
+ Y12: 4C8A4C | C2AC8AC2AC | C2AC8AC2AC | 4C8A4C | 16A | 16A | 16A | 16A
48
+ | 16A | 16A | 16A | 16A | 4C8A4C | C2AC8AC2AC | C2AC8AC2AC | 4C8A4C
49
+ Y13: CACA8ACACA | 4C8A4C | 4C8A4C | CACA8ACACA | 16A | 16A | 16A | 16A
50
+ | 16A | 16A | 16A | 16A | CACA8ACACA | 4C8A4C | 4C8A4C | CACA8ACACA
51
+ Y14: 4C8A4C | 4C8A4C | 4C8A4C | 4C8A4C | 16A | 16A | 16A | 16A
52
+ | 16A | 16A | 16A | 16A | 4C8A4C | 4C8A4C | 4C8A4C | 4C8A4C
53
+ Y15: CRCC8ACCRC | 4C8A4C | 4C8A4C | CRCC8ACCRC | 16A | 16A | 16A | 16A
54
+ | 16A | 16A | 16A | 16A | CRCC8ACCRC | 4C8A4C | 4C8A4C | CRCC8ACCRC
55
+ `;
56
+ // ---------------------------------------------------------------------------
57
+ // PYRAMID — 20×20×11 Stepped Egyptian pyramid, sandstone, gold capstone.
58
+ // ---------------------------------------------------------------------------
59
+ const PYRAMID = `
60
+ Y0: 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H
61
+ | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H
62
+ Y1: 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H
63
+ | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H | 20H
64
+ Y2: 20A | 20A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A
65
+ | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A
66
+ | 2A16H2A | 2A16H2A | 20A | 20A
67
+ Y3: 20A | 20A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A
68
+ | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A | 2A16H2A
69
+ | 2A16H2A | 2A16H2A | 20A | 20A
70
+ Y4: 20A | 20A | 20A | 20A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A
71
+ | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A
72
+ | 20A | 20A | 20A | 20A
73
+ Y5: 20A | 20A | 20A | 20A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A
74
+ | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A | 4A12H4A
75
+ | 20A | 20A | 20A | 20A
76
+ Y6: 20A | 20A | 20A | 20A | 20A | 20A | 6A8H6A | 6A8H6A
77
+ | 6A8H6A | 6A8H6A | 6A8H6A | 6A8H6A | 6A8H6A | 6A8H6A | 20A | 20A
78
+ | 20A | 20A | 20A | 20A
79
+ Y7: 20A | 20A | 20A | 20A | 20A | 20A | 6A8H6A | 6A8H6A
80
+ | 6A8H6A | 6A8H6A | 6A8H6A | 6A8H6A | 6A8H6A | 6A8H6A | 20A | 20A
81
+ | 20A | 20A | 20A | 20A
82
+ Y8: 20A | 20A | 20A | 20A | 20A | 20A | 20A | 20A
83
+ | 8A4H8A | 8A4H8A | 8A4H8A | 8A4H8A | 20A | 20A | 20A | 20A
84
+ | 20A | 20A | 20A | 20A
85
+ Y9: 20A | 20A | 20A | 20A | 20A | 20A | 20A | 20A
86
+ | 8A4H8A | 8A4H8A | 8A4H8A | 8A4H8A | 20A | 20A | 20A | 20A
87
+ | 20A | 20A | 20A | 20A
88
+ Y10: 20A | 20A | 20A | 20A | 20A | 20A | 20A | 20A | 20A
89
+ | 9A2Y9A | 9A2Y9A | 20A | 20A | 20A | 20A | 20A | 20A | 20A | 20A | 20A
90
+ `;
91
+ // ---------------------------------------------------------------------------
92
+ // ROCKET — 9×9×27 Saturn-V-style rocket: iron pad, fins, quartz body
93
+ // with windows + red bands, tapered nose, tiny red flame tip.
94
+ // ---------------------------------------------------------------------------
95
+ const ROCKET = `
96
+ Y0: 9I | 9I | 9I | 9I | 9I | 9I | 9I | 9I | 9I
97
+ Y1: 4AR4A | 4AR4A | 2A5I2A | 2A5I2A | 2R5I2R | 2A5I2A | 2A5I2A | 4AR4A | 4AR4A
98
+ Y2: 9A | 9A | 2A5I2A | 2A5I2A | 2A5I2A | 2A5I2A | 2A5I2A | 9A | 9A
99
+ Y3: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
100
+ Y4: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
101
+ Y5: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
102
+ Y6: 9A | 9A | 2A5R2A | 2A5R2A | 2A5R2A | 2A5R2A | 2A5R2A | 9A | 9A
103
+ Y7: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
104
+ Y8: 9A | 9A | 2AQQGQQ2A | 2A5Q2A | 2AGQQQG2A | 2A5Q2A | 2AQQGQQ2A | 9A | 9A
105
+ Y9: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
106
+ Y10: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
107
+ Y11: 9A | 9A | 2A5R2A | 2A5R2A | 2A5R2A | 2A5R2A | 2A5R2A | 9A | 9A
108
+ Y12: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
109
+ Y13: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
110
+ Y14: 9A | 9A | 2AQQGQQ2A | 2A5Q2A | 2AGQQQG2A | 2A5Q2A | 2AQQGQQ2A | 9A | 9A
111
+ Y15: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
112
+ Y16: 9A | 9A | 2A5R2A | 2A5R2A | 2A5R2A | 2A5R2A | 2A5R2A | 9A | 9A
113
+ Y17: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
114
+ Y18: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
115
+ Y19: 9A | 9A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 2A5Q2A | 9A | 9A
116
+ Y20: 9A | 9A | 9A | 3A3Q3A | 3A3Q3A | 3A3Q3A | 9A | 9A | 9A
117
+ Y21: 9A | 9A | 9A | 3A3Q3A | 3A3Q3A | 3A3Q3A | 9A | 9A | 9A
118
+ Y22: 9A | 9A | 9A | 3A3Q3A | 3A3Q3A | 3A3Q3A | 9A | 9A | 9A
119
+ Y23: 9A | 9A | 9A | 9A | 4AY4A | 9A | 9A | 9A | 9A
120
+ Y24: 9A | 9A | 9A | 9A | 4AY4A | 9A | 9A | 9A | 9A
121
+ Y25: 9A | 9A | 9A | 9A | 4AR4A | 9A | 9A | 9A | 9A
122
+ Y26: 9A | 9A | 9A | 9A | 4AR4A | 9A | 9A | 9A | 9A
123
+ `;
124
+ // ---------------------------------------------------------------------------
125
+ // LIGHTHOUSE — 7×7×24 Stone base, alternating red/white bands, gallery
126
+ // railing, glass lantern room with sea-lantern light, stepped roof point.
127
+ // ---------------------------------------------------------------------------
128
+ const LIGHTHOUSE = `
129
+ Y0: 7S | 7S | 7S | 7S | 7S | 7S | 7S
130
+ Y1: 7S | 7S | 7S | 7S | 7S | 7S | 7S
131
+ Y2: 7A | A5SA | A5SA | A5SA | A5SA | A5SA | 7A
132
+ Y3: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
133
+ Y4: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
134
+ Y5: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
135
+ Y6: 7A | A5QA | A5QA | A5QA | A5QA | A5QA | 7A
136
+ Y7: 7A | A5QA | A5QA | A5QA | A5QA | A5QA | 7A
137
+ Y8: 7A | A5QA | A5QA | A5QA | A5QA | A5QA | 7A
138
+ Y9: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
139
+ Y10: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
140
+ Y11: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
141
+ Y12: 7A | A5QA | A5QA | A5QA | A5QA | A5QA | 7A
142
+ Y13: 7A | A5QA | A5QA | A5QA | A5QA | A5QA | 7A
143
+ Y14: 7A | A5QA | A5QA | A5QA | A5QA | A5QA | 7A
144
+ Y15: 7S | 7S | 7S | 7S | 7S | 7S | 7S
145
+ Y16: 7S | S5AS | S5AS | S5AS | S5AS | S5AS | 7S
146
+ Y17: 7A | A5GA | A5GA | A5GA | A5GA | A5GA | 7A
147
+ Y18: 7A | A5GA | A5GA | AG3UGA | A5GA | A5GA | 7A
148
+ Y19: 7A | A5GA | A5GA | A5GA | A5GA | A5GA | 7A
149
+ Y20: 7R | 7R | 7R | 7R | 7R | 7R | 7R
150
+ Y21: 7A | A5RA | A5RA | A5RA | A5RA | A5RA | 7A
151
+ Y22: 7A | 7A | 2A3R2A | 2A3R2A | 2A3R2A | 7A | 7A
152
+ Y23: 7A | 7A | 7A | 3AR3A | 7A | 7A | 7A
153
+ `;
154
+ // ---------------------------------------------------------------------------
155
+ // SKYSCRAPER — 12×12×25 Iron-framed glass tower, full floor plate every
156
+ // 4 levels, tapered profile (12→10→8→6→4→2), red spire on top.
157
+ // ---------------------------------------------------------------------------
158
+ const SKYSCRAPER = `
159
+ Y0: 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I
160
+ Y1: I10GI | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | I10GI
161
+ Y2: I10GI | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | I10GI
162
+ Y3: I10GI | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | G10AG | I10GI
163
+ Y4: 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I | 12I
164
+ Y5: 12A | AI8GIA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AI8GIA | 12A
165
+ Y6: 12A | AI8GIA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AI8GIA | 12A
166
+ Y7: 12A | AI8GIA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AG8AGA | AI8GIA | 12A
167
+ Y8: 12A | A10IA | A10IA | A10IA | A10IA | A10IA | A10IA | A10IA | A10IA | A10IA | A10IA | 12A
168
+ Y9: 12A | 12A | 2AI6GI2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AI6GI2A | 12A | 12A
169
+ Y10: 12A | 12A | 2AI6GI2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AI6GI2A | 12A | 12A
170
+ Y11: 12A | 12A | 2AI6GI2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AG6AG2A | 2AI6GI2A | 12A | 12A
171
+ Y12: 12A | 12A | 2A8I2A | 2A8I2A | 2A8I2A | 2A8I2A | 2A8I2A | 2A8I2A | 2A8I2A | 2A8I2A | 12A | 12A
172
+ Y13: 12A | 12A | 12A | 3AI4GI3A | 3AG4AG3A | 3AG4AG3A | 3AG4AG3A | 3AG4AG3A | 3AI4GI3A | 12A | 12A | 12A
173
+ Y14: 12A | 12A | 12A | 3AI4GI3A | 3AG4AG3A | 3AG4AG3A | 3AG4AG3A | 3AG4AG3A | 3AI4GI3A | 12A | 12A | 12A
174
+ Y15: 12A | 12A | 12A | 3AI4GI3A | 3AG4AG3A | 3AG4AG3A | 3AG4AG3A | 3AG4AG3A | 3AI4GI3A | 12A | 12A | 12A
175
+ Y16: 12A | 12A | 12A | 3A6I3A | 3A6I3A | 3A6I3A | 3A6I3A | 3A6I3A | 3A6I3A | 12A | 12A | 12A
176
+ Y17: 12A | 12A | 12A | 12A | 4AI2GI4A | 4AG2AG4A | 4AG2AG4A | 4AI2GI4A | 12A | 12A | 12A | 12A
177
+ Y18: 12A | 12A | 12A | 12A | 4AI2GI4A | 4AG2AG4A | 4AG2AG4A | 4AI2GI4A | 12A | 12A | 12A | 12A
178
+ Y19: 12A | 12A | 12A | 12A | 4AI2GI4A | 4AG2AG4A | 4AG2AG4A | 4AI2GI4A | 12A | 12A | 12A | 12A
179
+ Y20: 12A | 12A | 12A | 12A | 4A4I4A | 4A4I4A | 4A4I4A | 4A4I4A | 12A | 12A | 12A | 12A
180
+ Y21: 12A | 12A | 12A | 12A | 12A | 5A2I5A | 5A2I5A | 12A | 12A | 12A | 12A | 12A
181
+ Y22: 12A | 12A | 12A | 12A | 12A | 5A2R5A | 5A2R5A | 12A | 12A | 12A | 12A | 12A
182
+ Y23: 12A | 12A | 12A | 12A | 12A | 5AR6A | 12A | 12A | 12A | 12A | 12A | 12A
183
+ Y24: 12A | 12A | 12A | 12A | 12A | 5AR6A | 12A | 12A | 12A | 12A | 12A | 12A
184
+ `;
185
+ // ---------------------------------------------------------------------------
186
+ // PIRATE_SHIP — 15×7×14 Wooden hull with raised bow/stern, deck planks,
187
+ // central mast (oak log), white square sail, red pirate flag on top.
188
+ // ---------------------------------------------------------------------------
189
+ const PIRATE_SHIP = `
190
+ Y0: 15D | 15D | 15D | 15D | 15D | 15D | 15D
191
+ Y1: 15D | D13AD | D13AD | D13AD | D13AD | D13AD | 15D
192
+ Y2: 15D | D13AD | D13AD | D13AD | D13AD | D13AD | 15D
193
+ Y3: 15W | 15W | 15W | 15W | 15W | 15W | 15W
194
+ Y4: 15D | D13AD | D13AD | D13AD | D13AD | D13AD | 15D
195
+ Y5: 15D | D13AD | D13AD | D13AD | D13AD | D13AD | 15D
196
+ Y6: 15A | 15A | 15A | 7AF7A | 15A | 15A | 15A
197
+ Y7: 15A | 15A | 15A | 3A4QF4Q3A | 15A | 15A | 15A
198
+ Y8: 15A | 15A | 15A | 3A4QF4Q3A | 15A | 15A | 15A
199
+ Y9: 15A | 15A | 15A | 3A4QF4Q3A | 15A | 15A | 15A
200
+ Y10: 15A | 15A | 15A | 7AF7A | 15A | 15A | 15A
201
+ Y11: 15A | 15A | 6A3W6A | 6AWFW6A | 6A3W6A | 15A | 15A
202
+ Y12: 15A | 15A | 15A | 7AF7A | 15A | 15A | 15A
203
+ Y13: 15A | 15A | 15A | 7AR7A | 15A | 15A | 15A
204
+ `;
205
+ // ===========================================================================
206
+ // MAP STARTERS — minimal worlds for survival challenges. Sized so the 5×5
207
+ // (or 7×7) island sits centred on the fixed spawn at world (10, baseY+1, 10).
208
+ // ===========================================================================
209
+ // ---------------------------------------------------------------------------
210
+ // SKYBLOCK — classic floating dirt/grass island (5×5) with an oak tree at
211
+ // one corner and a starter chest on the opposite corner. Player spawns on
212
+ // top of the grass at the centre.
213
+ // ---------------------------------------------------------------------------
214
+ const SKYBLOCK = `
215
+ Y0: 13A | 13A | 13A | 13A | 13A | 13A | 13A | 13A
216
+ | 8A5g | 8A5g | 8A5g | 8A5g | 8A5g
217
+ Y1: 13A | 13A | 13A | 13A | 13A | 13A | 13A | 13A
218
+ | 8AF4A | 13A | 13A | 13A | 12Ac
219
+ Y2: 13A | 13A | 13A | 13A | 13A | 13A | 13A | 13A
220
+ | 8AF4A | 13A | 13A | 13A | 13A
221
+ Y3: 13A | 13A | 13A | 13A | 13A | 13A
222
+ | 6A5l2A | 6A5l2A | 6A2lF2l2A | 6A5l2A | 6A5l2A | 13A | 13A
223
+ Y4: 13A | 13A | 13A | 13A | 13A | 13A
224
+ | 6A5l2A | 6A5l2A | 6A2lF2l2A | 6A5l2A | 6A5l2A | 13A | 13A
225
+ Y5: 13A | 13A | 13A | 13A | 13A | 13A | 13A
226
+ | 7A3l3A | 7AlFl3A | 7A3l3A | 13A | 13A | 13A
227
+ Y6: 13A | 13A | 13A | 13A | 13A | 13A | 13A | 13A
228
+ | 8Al4A | 13A | 13A | 13A | 13A
229
+ `;
230
+ // ---------------------------------------------------------------------------
231
+ // VOID_PLATFORM — a single 5×5 obsidian pad floating in the void. Bring
232
+ // your own blocks. Good for creative / build servers.
233
+ // ---------------------------------------------------------------------------
234
+ const VOID_PLATFORM = `
235
+ Y0: 13A | 13A | 13A | 13A | 13A | 13A | 13A | 13A
236
+ | 8A5O | 8A5O | 8A5O | 8A5O | 8A5O
237
+ `;
238
+ // ---------------------------------------------------------------------------
239
+ // ONE_BLOCK — a single stone block at spawn. Mine it. See what happens.
240
+ // (The auto spawn-platform safety covers the same cell, so this is mostly
241
+ // a demonstration of the smallest possible template.)
242
+ // ---------------------------------------------------------------------------
243
+ const ONE_BLOCK = `
244
+ Y0: 11A | 11A | 11A | 11A | 11A | 11A | 11A | 11A | 11A | 11A | 10AS
245
+ `;
246
+ // ---------------------------------------------------------------------------
247
+ // Registry — keys are normalised to lowercase by `resolveTemplate`.
248
+ // ---------------------------------------------------------------------------
249
+ exports.TEMPLATE_EXAMPLES = {
250
+ // Cool builds
251
+ castle: CASTLE,
252
+ pyramid: PYRAMID,
253
+ rocket: ROCKET,
254
+ lighthouse: LIGHTHOUSE,
255
+ skyscraper: SKYSCRAPER,
256
+ pirate_ship: PIRATE_SHIP,
257
+ // Map starters
258
+ skyblock: SKYBLOCK,
259
+ void_platform: VOID_PLATFORM,
260
+ one_block: ONE_BLOCK,
261
+ };
262
+ /**
263
+ * If `templateStr` is exactly `[name]` (whitespace tolerated), return the
264
+ * matching built-in example; otherwise return `templateStr` unchanged.
265
+ *
266
+ * Throws when the example name is not registered.
267
+ */
268
+ function resolveTemplate(templateStr) {
269
+ const m = templateStr.match(/^\s*\[([\w-]+)\]\s*$/);
270
+ if (!m)
271
+ return templateStr;
272
+ const name = m[1].toLowerCase();
273
+ const example = exports.TEMPLATE_EXAMPLES[name];
274
+ if (!example) {
275
+ throw new Error(`[chunkTemplate] Unknown example '${name}'. ` +
276
+ `Available: ${Object.keys(exports.TEMPLATE_EXAMPLES).join(', ')}`);
277
+ }
278
+ return example;
279
+ }
package/dist/modules.d.ts CHANGED
@@ -93,10 +93,17 @@ declare global {
93
93
  * If provided, this encoded string completely replaces the normal chunk
94
94
  * generator for the overworld. Every chunk is filled from the decoded
95
95
  * structure; chunks outside the structure bounds are empty (air + sky
96
- * light).
96
+ * light). Player spawn is forced to a fixed point on top of the
97
+ * template (see `getTemplateSpawnPoint`).
97
98
  *
98
- * Strict format:
99
- * Y<n>: row0 | row1 | … | rowN-1 Y<n>: …
99
+ * **Built-in examples** — pass `"[name]"` to load one of the bundled
100
+ * templates.
101
+ * - Builds: `[castle]`, `[pyramid]`, `[rocket]`, `[lighthouse]`,
102
+ * `[skyscraper]`, `[pirate_ship]`
103
+ * - Map starters: `[skyblock]`, `[void_platform]`, `[one_block]`
104
+ *
105
+ * **Custom format** — strict layer encoding:
106
+ * `Y<n>: row0 | row1 | … | rowN-1 Y<n>: …`
100
107
  *
101
108
  * - `<n>` is a 0-based floor index (Y0 = ground, Y1 = one block up, …).
102
109
  * - Rows are separated by `|`; each row is one Z-slice of the floor.
@@ -105,8 +112,8 @@ declare global {
105
112
  * - Single characters map to block names via `blockMap` (see below).
106
113
  * - Width and depth are inferred from the decoded row lengths.
107
114
  *
108
- * @example
109
- * "Y0: 16C | 16C Y1: C14AC | C14AC"
115
+ * @example "[skyblock]"
116
+ * @example "Y0: 16C | 16C Y1: C14AC | C14AC"
110
117
  */
111
118
  chunkTemplate?: string;
112
119
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zardoy/flying-squid",
3
3
  "description": "A minecraft server written in TS",
4
- "version": "0.0.121",
4
+ "version": "0.0.123",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",