@zardoy/flying-squid 0.0.121 → 0.0.122
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
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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,
|
|
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
|
|
56
|
-
*
|
|
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
|
|
61
|
-
* `worldHeight`).
|
|
62
|
-
* @param userBlockMap Optional extra / override mappings on top
|
|
63
|
-
* DEFAULT_BLOCK_MAP.
|
|
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,6 +4,7 @@ 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");
|
|
9
10
|
/**
|
|
@@ -126,19 +127,35 @@ function parseTemplate(templateStr) {
|
|
|
126
127
|
// ---------------------------------------------------------------------------
|
|
127
128
|
// Chunk generator factory
|
|
128
129
|
// ---------------------------------------------------------------------------
|
|
130
|
+
/** X/Z offset inward from the (0, 0) corner used as the template spawn. */
|
|
131
|
+
const SPAWN_OFFSET = 10;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the deterministic spawn point for a chunk-template world.
|
|
134
|
+
* The player is placed one block above the Y0 floor (`baseY + 1`) at a
|
|
135
|
+
* fixed 10-block inset from the template's (0, 0) corner.
|
|
136
|
+
*/
|
|
137
|
+
function getTemplateSpawnPoint(options) {
|
|
138
|
+
const baseY = options.baseY ?? 64;
|
|
139
|
+
return new vec3_1.Vec3(SPAWN_OFFSET, baseY + 1, SPAWN_OFFSET);
|
|
140
|
+
}
|
|
129
141
|
/**
|
|
130
142
|
* Returns a `(chunkX, chunkZ) => Chunk` generator that paints the decoded
|
|
131
|
-
* template structure into the world starting at (0,
|
|
143
|
+
* template structure into the world starting at (0, baseY, 0).
|
|
144
|
+
*
|
|
145
|
+
* A stone block is guaranteed directly below the spawn position so the
|
|
146
|
+
* player always has something solid to land on regardless of what the
|
|
147
|
+
* template has at that cell.
|
|
132
148
|
*
|
|
133
|
-
* Chunks that do not overlap the structure are
|
|
134
|
-
*
|
|
149
|
+
* Chunks that do not overlap the structure are returned as empty (air +
|
|
150
|
+
* full sky-light), compatible with every generator contract.
|
|
135
151
|
*
|
|
136
152
|
* @param templateStr Encoded template string (see parseTemplate).
|
|
137
153
|
* @param options generationOptions forwarded from world.ts
|
|
138
|
-
* (must include `version
|
|
139
|
-
* `worldHeight`).
|
|
140
|
-
* @param userBlockMap Optional extra / override mappings on top
|
|
141
|
-
* DEFAULT_BLOCK_MAP.
|
|
154
|
+
* (must include `version`; may include `minY`,
|
|
155
|
+
* `worldHeight`, `baseY`).
|
|
156
|
+
* @param userBlockMap Optional extra / override char→name mappings on top
|
|
157
|
+
* of DEFAULT_BLOCK_MAP. Accepts a string
|
|
158
|
+
* (`"C=cobblestone, G=glass"`) or a plain object.
|
|
142
159
|
*/
|
|
143
160
|
function makeTemplateGenerator(templateStr, options, userBlockMap) {
|
|
144
161
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
@@ -186,6 +203,12 @@ function makeTemplateGenerator(templateStr, options, userBlockMap) {
|
|
|
186
203
|
}
|
|
187
204
|
}
|
|
188
205
|
}
|
|
206
|
+
// Guarantee a solid block directly below the spawn position so the player
|
|
207
|
+
// always has something to land on (stone at Y0 = baseY, spawn is at baseY+1).
|
|
208
|
+
const spawnPlatformId = theFlattening
|
|
209
|
+
? mcData.blocksByName.stone.minStateId
|
|
210
|
+
: mcData.blocksByName.stone.id;
|
|
211
|
+
blockGrid.set(`${SPAWN_OFFSET},${baseY},${SPAWN_OFFSET}`, spawnPlatformId);
|
|
189
212
|
return (chunkX, chunkZ) => {
|
|
190
213
|
const chunk = new Chunk({ minY, worldHeight });
|
|
191
214
|
// Full sky-light (standard for surface/flat worlds)
|