@zardoy/flying-squid 0.0.123 → 0.0.124
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/config/default-settings.json +2 -4
- package/dist/app.js +18 -0
- package/dist/index.js +1 -1
- package/dist/lib/generations.d.ts +1 -1
- package/dist/lib/generations.js +2 -2
- package/dist/lib/modules/dimensionCodec.d.ts +2 -0
- package/dist/lib/modules/dimensionCodec.js +121 -0
- package/dist/lib/modules/effects.js +3 -0
- package/dist/lib/modules/index.js +3 -1
- package/dist/lib/modules/playerLogin.js +3 -2
- package/dist/lib/modules/players.d.ts +6 -0
- package/dist/lib/modules/players.js +42 -16
- package/dist/lib/modules/players.test.d.ts +1 -0
- package/dist/lib/modules/players.test.js +30 -0
- package/dist/lib/modules/portal.d.ts +5 -0
- package/dist/lib/modules/portal.js +179 -0
- package/dist/lib/modules/recipes.d.ts +12 -0
- package/dist/lib/modules/recipes.js +266 -0
- package/dist/lib/modules/title.d.ts +4 -2
- package/dist/lib/modules/title.js +33 -16
- package/dist/lib/modules/title.test.d.ts +1 -0
- package/dist/lib/modules/title.test.js +102 -0
- package/dist/lib/modules/world.d.ts +36 -3
- package/dist/lib/modules/world.js +259 -46
- package/dist/lib/modules/worldManager.d.ts +1 -0
- package/dist/lib/modules/worldManager.js +119 -0
- package/dist/lib/playerDat.d.ts +1 -8
- package/dist/lib/playerDat.js +13 -2
- package/dist/lib/worldGenerations/biomeFix.d.ts +10 -0
- package/dist/lib/worldGenerations/biomeFix.js +19 -0
- package/dist/lib/worldGenerations/empty.js +4 -1
- package/dist/lib/worldGenerations/noise.d.ts +22 -0
- package/dist/lib/worldGenerations/noise.js +248 -0
- package/dist/minigames/oneblock.d.ts +1 -0
- package/dist/minigames/oneblock.js +41 -0
- package/dist/minigames/tntRun.d.ts +1 -0
- package/dist/minigames/tntRun.js +14 -0
- package/dist/modules.d.ts +2 -2
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
const { Vec3 } = require('vec3');
|
|
1
2
|
module.exports = (options) => {
|
|
2
3
|
const Chunk = require('prismarine-chunk')(options.version);
|
|
3
4
|
const mcData = require('minecraft-data')(options.version);
|
|
4
5
|
const stoneId = mcData.blocksByName.stone.id;
|
|
6
|
+
// 1.18+ columns can have a custom height range (nether / end: 0..256)
|
|
7
|
+
const chunkOptions = options.worldHeight !== undefined && options.minY !== undefined ? { minY: options.minY, worldHeight: options.worldHeight } : undefined;
|
|
5
8
|
return (chunkX, chunkZ) => {
|
|
6
|
-
const chunk = new Chunk();
|
|
9
|
+
const chunk = new Chunk(chunkOptions);
|
|
7
10
|
if (chunkX === 0 && chunkZ === 0) {
|
|
8
11
|
chunk.setBlockType(new Vec3(0, 64, 0), stoneId);
|
|
9
12
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minecraft 26.3 noise worldgen (`minecraft:noise`) chunk generator (package minecraft-worldgen); external worldgen datapacks are optional layers on top of the vanilla data.
|
|
3
|
+
*
|
|
4
|
+
* Options (on top of the usual `version`, `seed`, `minY`, `worldHeight`, `getRenamedData`):
|
|
5
|
+
* - `jars`: datapack jars in priority order, lowest first (default: vanilla client.jar + the external datapack jar, see
|
|
6
|
+
* `minecraft-worldgen` `src/data/registry.ts`).
|
|
7
|
+
* - `dimension`: `overworld` (default) | `nether` | `end`; selects the noise settings, the biome source and the chunk column size
|
|
8
|
+
* (overworld -64..320, nether / end 0..256 like their dimension types).
|
|
9
|
+
* - `preset` (overworld only): `default` | `amplified` | `large_biomes` | `caves` | `floating_islands` (vanilla noise settings of the same name).
|
|
10
|
+
* - `settings`: explicit noise settings id (overrides `dimension` / `preset`).
|
|
11
|
+
* - `recipe`: custom dimension, see minecraft-worldgen `src/recipe` and docs/worlds.md: a built-in name (`mining` | `islands` | `chaos`), `{ builtin, options }`,
|
|
12
|
+
* `{ script: '/path/recipe.js', options }` or a complete recipe object. A built-in recipe name is also accepted as `preset`.
|
|
13
|
+
* - `workers`: worker_threads used for generation (default min(4, cpus-1), env `MC_WORLDGEN_WORKERS`; 0 = in-process).
|
|
14
|
+
* - `workerFactory` (browser hosts): `(index) => new Worker(...)`; chunks are then generated in Web Workers (count: `workers`,
|
|
15
|
+
* default min(4, hardwareConcurrency-1)). The worker script is `minecraft-worldgen/dist/worker/web-entry` bundled by the host. The datapack zip
|
|
16
|
+
* URL(s) (`globalThis.__MC_WORLDGEN_DATAPACK_URL`: string, string[] or a function returning them) are passed to the workers, which fetch it themselves.
|
|
17
|
+
*/
|
|
18
|
+
declare function generation(options?: any): {
|
|
19
|
+
(chunkX: number, chunkZ: number): Promise<any>;
|
|
20
|
+
dispose(): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export = generation;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const vec3_1 = require("vec3");
|
|
3
|
+
const biomeFix_1 = require("./biomeFix");
|
|
4
|
+
const random_1 = require("minecraft-worldgen/dist/rng/random");
|
|
5
|
+
const builtin_1 = require("minecraft-worldgen/dist/recipe/builtin");
|
|
6
|
+
const pool_1 = require("minecraft-worldgen/dist/worker/pool");
|
|
7
|
+
const DIMENSIONS = {
|
|
8
|
+
overworld: { settings: 'minecraft:overworld' }, nether: { settings: 'minecraft:nether' }, end: { settings: 'minecraft:end' }
|
|
9
|
+
};
|
|
10
|
+
const PRESET_SETTINGS = {
|
|
11
|
+
default: 'minecraft:overworld', amplified: 'minecraft:amplified', large_biomes: 'minecraft:large_biomes', caves: 'minecraft:caves', floating_islands: 'minecraft:floating_islands'
|
|
12
|
+
};
|
|
13
|
+
/** Source version of the worldgen data / block names (all palette names are 26.3 names). */
|
|
14
|
+
const SOURCE_VERSION = '26.3';
|
|
15
|
+
/**
|
|
16
|
+
* Minecraft 26.3 noise worldgen (`minecraft:noise`) chunk generator (package minecraft-worldgen); external worldgen datapacks are optional layers on top of the vanilla data.
|
|
17
|
+
*
|
|
18
|
+
* Options (on top of the usual `version`, `seed`, `minY`, `worldHeight`, `getRenamedData`):
|
|
19
|
+
* - `jars`: datapack jars in priority order, lowest first (default: vanilla client.jar + the external datapack jar, see
|
|
20
|
+
* `minecraft-worldgen` `src/data/registry.ts`).
|
|
21
|
+
* - `dimension`: `overworld` (default) | `nether` | `end`; selects the noise settings, the biome source and the chunk column size
|
|
22
|
+
* (overworld -64..320, nether / end 0..256 like their dimension types).
|
|
23
|
+
* - `preset` (overworld only): `default` | `amplified` | `large_biomes` | `caves` | `floating_islands` (vanilla noise settings of the same name).
|
|
24
|
+
* - `settings`: explicit noise settings id (overrides `dimension` / `preset`).
|
|
25
|
+
* - `recipe`: custom dimension, see minecraft-worldgen `src/recipe` and docs/worlds.md: a built-in name (`mining` | `islands` | `chaos`), `{ builtin, options }`,
|
|
26
|
+
* `{ script: '/path/recipe.js', options }` or a complete recipe object. A built-in recipe name is also accepted as `preset`.
|
|
27
|
+
* - `workers`: worker_threads used for generation (default min(4, cpus-1), env `MC_WORLDGEN_WORKERS`; 0 = in-process).
|
|
28
|
+
* - `workerFactory` (browser hosts): `(index) => new Worker(...)`; chunks are then generated in Web Workers (count: `workers`,
|
|
29
|
+
* default min(4, hardwareConcurrency-1)). The worker script is `minecraft-worldgen/dist/worker/web-entry` bundled by the host. The datapack zip
|
|
30
|
+
* URL(s) (`globalThis.__MC_WORLDGEN_DATAPACK_URL`: string, string[] or a function returning them) are passed to the workers, which fetch it themselves.
|
|
31
|
+
*/
|
|
32
|
+
function generation(options = {}) {
|
|
33
|
+
const { version, getRenamedData } = options;
|
|
34
|
+
const dimension = options.dimension ?? 'overworld';
|
|
35
|
+
if (!DIMENSIONS[dimension])
|
|
36
|
+
throw new Error(`noise generator: unknown dimension '${dimension}' (overworld | nether | end)`);
|
|
37
|
+
let preset = options.preset ?? 'default';
|
|
38
|
+
let recipe = typeof options.recipe === 'string' ? { builtin: options.recipe } : options.recipe;
|
|
39
|
+
if (!recipe && builtin_1.BUILTIN_RECIPES[preset]) {
|
|
40
|
+
recipe = { builtin: preset };
|
|
41
|
+
preset = 'default';
|
|
42
|
+
}
|
|
43
|
+
if (recipe && 'script' in recipe)
|
|
44
|
+
recipe = { ...recipe, script: require('path').resolve(recipe.script) };
|
|
45
|
+
if (!recipe && dimension === 'overworld' && !PRESET_SETTINGS[preset])
|
|
46
|
+
throw new Error(`noise generator: unknown preset '${preset}' (${Object.keys(PRESET_SETTINGS).join(' | ')})`);
|
|
47
|
+
const settingsId = options.settings ?? (dimension === 'overworld' ? PRESET_SETTINGS[preset] : DIMENSIONS[dimension].settings);
|
|
48
|
+
// dimension type of the chunk column: overworld -64..320, nether / end 0..256
|
|
49
|
+
const minY = dimension === 'overworld' ? (options.minY ?? -64) : 0;
|
|
50
|
+
const worldHeight = dimension === 'overworld' ? (options.worldHeight ?? 384) : 256;
|
|
51
|
+
const Chunk = require('prismarine-chunk')(version);
|
|
52
|
+
const registry = require('prismarine-registry')(version);
|
|
53
|
+
const Block = require('prismarine-block')(registry);
|
|
54
|
+
if (dimension === 'overworld' && (minY !== -64 || worldHeight !== 384)) {
|
|
55
|
+
throw new Error(`noise generator needs a 384-block tall world starting at y=-64 (version >= 1.18), got minY=${minY} height=${worldHeight}`);
|
|
56
|
+
}
|
|
57
|
+
const seed = (0, random_1.parseWorldSeed)(options.seed);
|
|
58
|
+
const workers = options.workers;
|
|
59
|
+
const workerFactory = options.workerFactory;
|
|
60
|
+
const createSource = () => (async () => {
|
|
61
|
+
let zipBuffers = options.zipBuffers;
|
|
62
|
+
if (!zipBuffers && !options.jars) {
|
|
63
|
+
// one URL or several (lowest priority first: vanilla pack, then e.g. a datapack the player loaded)
|
|
64
|
+
let global = globalThis.__MC_WORLDGEN_DATAPACK_URL;
|
|
65
|
+
if (typeof global === 'function')
|
|
66
|
+
global = await global();
|
|
67
|
+
const urls = global === undefined ? undefined : Array.isArray(global) ? global : [global];
|
|
68
|
+
if (urls?.length && workerFactory && workers !== 0) {
|
|
69
|
+
// Web Workers fetch the (HTTP-cached / data: / blob:) datapack themselves instead of receiving a copy each
|
|
70
|
+
return (0, pool_1.createChunkSource)({ seed: seed.toString(), datapackUrl: urls.length === 1 ? urls[0] : urls, settings: settingsId, recipe, maxCachedChunks: options.maxCachedChunks ?? 160 }, workers, workerFactory);
|
|
71
|
+
}
|
|
72
|
+
if (urls?.length) {
|
|
73
|
+
zipBuffers = await Promise.all(urls.map(async (url, i) => {
|
|
74
|
+
const res = await fetch(url);
|
|
75
|
+
if (!res.ok)
|
|
76
|
+
throw new Error(`worldgen datapack fetch failed ${res.status}: ${url}`);
|
|
77
|
+
return { name: `datapack${i}.zip`, data: new Uint8Array(await res.arrayBuffer()) };
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return (0, pool_1.createChunkSource)({ seed: seed.toString(), jars: options.jars, zipBuffers, settings: settingsId, recipe }, workers, workerFactory);
|
|
82
|
+
})();
|
|
83
|
+
// created lazily: a dimension nobody visits does not start a worker pool
|
|
84
|
+
let sourceP;
|
|
85
|
+
const getSource = () => {
|
|
86
|
+
if (!sourceP) {
|
|
87
|
+
sourceP = createSource();
|
|
88
|
+
sourceP.catch(() => { });
|
|
89
|
+
} // failures surface through generateChunk
|
|
90
|
+
return sourceP;
|
|
91
|
+
};
|
|
92
|
+
// ------------------------------------------------------------------ block-state mapping (26.3 -> client version)
|
|
93
|
+
const warned = new Set();
|
|
94
|
+
const stateByName = new Map();
|
|
95
|
+
const fallbackStone = registry.blocksByName.stone.defaultState ?? registry.blocksByName.stone.minStateId;
|
|
96
|
+
// blocks newer than the client version: aliases first, then a category fallback (plants / decoration -> air, other unknown blocks -> stone)
|
|
97
|
+
const ALIASES = {
|
|
98
|
+
short_grass: 'grass', tall_dry_grass: 'dead_bush', short_dry_grass: 'dead_bush', dead_bush: 'dead_bush',
|
|
99
|
+
cherry_leaves: 'flowering_azalea_leaves', pale_oak_leaves: 'dark_oak_leaves', mangrove_leaves: 'jungle_leaves',
|
|
100
|
+
cherry_log: 'acacia_log', pale_oak_log: 'dark_oak_log', mangrove_log: 'jungle_log', mangrove_roots: 'oak_log', pale_moss_block: 'moss_block', pale_moss_carpet: 'moss_carpet',
|
|
101
|
+
resin_block: 'orange_terracotta', creaking_heart: 'dark_oak_log', pale_hanging_moss: 'air'
|
|
102
|
+
};
|
|
103
|
+
const PLANTISH = /(^|_)(grass|bush|flowers?|litter|mushroom|fern|vines?|petals|sprouts?|roots|sapling|tulip|dandelion|poppy|orchid|allium|azure_bluet|cornflower|lily|peony|lilac|rose|dripleaf|hanging_moss|wildflowers|firefly|sweet_berry|torchflower|pitcher|eyeblossom|cactus_flower|dry_grass)(_|$)/;
|
|
104
|
+
const woodSuffix = /_(log|wood|planks|slab|stairs|fence|fence_gate|door|trapdoor|button|pressure_plate|sign|leaves)$/;
|
|
105
|
+
const resolveBlock = (base) => {
|
|
106
|
+
const direct = registry.blocksByName[base];
|
|
107
|
+
if (direct)
|
|
108
|
+
return direct;
|
|
109
|
+
const alias = ALIASES[base];
|
|
110
|
+
if (alias && registry.blocksByName[alias])
|
|
111
|
+
return registry.blocksByName[alias];
|
|
112
|
+
if (alias === 'air' || PLANTISH.test(base))
|
|
113
|
+
return registry.blocksByName.air;
|
|
114
|
+
const m = woodSuffix.exec(base);
|
|
115
|
+
if (m && registry.blocksByName['oak' + m[0]])
|
|
116
|
+
return registry.blocksByName['oak' + m[0]];
|
|
117
|
+
return undefined;
|
|
118
|
+
};
|
|
119
|
+
const mapState = (state) => {
|
|
120
|
+
const m = /^(?:minecraft:)?([^[]+)(?:\[(.*)\])?$/.exec(state);
|
|
121
|
+
const base = m[1];
|
|
122
|
+
const props = {};
|
|
123
|
+
if (m[2])
|
|
124
|
+
for (const kv of m[2].split(',')) {
|
|
125
|
+
const [k, v] = kv.split('=');
|
|
126
|
+
props[k] = v;
|
|
127
|
+
}
|
|
128
|
+
const renamed = getRenamedData ? getRenamedData('blocks', base, SOURCE_VERSION, version) : base;
|
|
129
|
+
const block = resolveBlock(renamed) ?? resolveBlock(base);
|
|
130
|
+
if (!block) {
|
|
131
|
+
if (!warned.has(renamed)) {
|
|
132
|
+
warned.add(renamed);
|
|
133
|
+
console.warn(`[noise] block '${renamed}' (from ${state}) unknown in ${version}, using stone`);
|
|
134
|
+
}
|
|
135
|
+
return fallbackStone;
|
|
136
|
+
}
|
|
137
|
+
if (block.name === 'air')
|
|
138
|
+
return 0;
|
|
139
|
+
if (!block.states)
|
|
140
|
+
return block.defaultState ?? block.minStateId ?? block.id;
|
|
141
|
+
// the generator omits properties equal to the block's default state: start from the defaults (Block.fromProperties would take the first value of each property)
|
|
142
|
+
const known = new Set(block.states.map((s) => s.name));
|
|
143
|
+
const filtered = { ...defaultProps(block) };
|
|
144
|
+
for (const k of Object.keys(props))
|
|
145
|
+
if (known.has(k))
|
|
146
|
+
filtered[k] = props[k];
|
|
147
|
+
try {
|
|
148
|
+
return Block.fromProperties(block.name, filtered, 0).stateId;
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return block.defaultState ?? block.minStateId;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const defaultPropsCache = new Map();
|
|
155
|
+
const defaultProps = (block) => {
|
|
156
|
+
let d = defaultPropsCache.get(block.name);
|
|
157
|
+
if (!d) {
|
|
158
|
+
d = {};
|
|
159
|
+
try {
|
|
160
|
+
const props = Block.fromStateId(block.defaultState, 0).getProperties();
|
|
161
|
+
for (const [k, v] of Object.entries(props))
|
|
162
|
+
d[k] = String(v);
|
|
163
|
+
}
|
|
164
|
+
catch { }
|
|
165
|
+
defaultPropsCache.set(block.name, d);
|
|
166
|
+
}
|
|
167
|
+
return d;
|
|
168
|
+
};
|
|
169
|
+
const stateIdOfName = (name) => {
|
|
170
|
+
let s = stateByName.get(name);
|
|
171
|
+
if (s === undefined) {
|
|
172
|
+
s = mapState(name);
|
|
173
|
+
stateByName.set(name, s);
|
|
174
|
+
}
|
|
175
|
+
return s;
|
|
176
|
+
};
|
|
177
|
+
// ------------------------------------------------------------------ biome mapping (<datapack>:* -> vanilla client id)
|
|
178
|
+
const plains = registry.biomesByName.plains.id;
|
|
179
|
+
let biomeIds;
|
|
180
|
+
const biomeIdsFor = (info) => biomeIds ??= info.vanillaBiomes.map(v => {
|
|
181
|
+
const b = registry.biomesByName[v.replace(/^minecraft:/, '')];
|
|
182
|
+
return b ? b.id : plains;
|
|
183
|
+
});
|
|
184
|
+
const pos = new vec3_1.Vec3(0, 0, 0);
|
|
185
|
+
async function generateChunk(chunkX, chunkZ) {
|
|
186
|
+
const source = await getSource();
|
|
187
|
+
const data = await source.generate(chunkX, chunkZ);
|
|
188
|
+
const ids = biomeIdsFor(source.info);
|
|
189
|
+
const palette = new Int32Array(data.palette.length);
|
|
190
|
+
for (let i = 1; i < palette.length; i++)
|
|
191
|
+
palette[i] = stateIdOfName(data.palette[i]);
|
|
192
|
+
const chunk = (0, biomeFix_1.fixSetBiome)(new Chunk({ minY, worldHeight }));
|
|
193
|
+
const info = source.info;
|
|
194
|
+
const blocks = data.blocks;
|
|
195
|
+
const rows = Math.min(info.height, minY + worldHeight - info.minY);
|
|
196
|
+
for (let y = Math.max(0, minY - info.minY); y < rows; y++) {
|
|
197
|
+
pos.y = info.minY + y;
|
|
198
|
+
for (let z = 0; z < 16; z++) {
|
|
199
|
+
pos.z = z;
|
|
200
|
+
const row = (y * 16 + z) * 16;
|
|
201
|
+
for (let x = 0; x < 16; x++) {
|
|
202
|
+
const id = blocks[row + x];
|
|
203
|
+
if (id === 0)
|
|
204
|
+
continue;
|
|
205
|
+
pos.x = x;
|
|
206
|
+
chunk.setBlockStateId(pos, palette[id]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// biomes: quart resolution, absolute y; quart rows above/below the generated range repeat the nearest generated row
|
|
211
|
+
const biomes = data.biomes;
|
|
212
|
+
const qRows = info.height >> 2;
|
|
213
|
+
const baseQy = info.minY >> 2;
|
|
214
|
+
for (let qy = minY >> 2; qy < (minY + worldHeight) >> 2; qy++) {
|
|
215
|
+
const src = Math.min(Math.max(qy - baseQy, 0), qRows - 1);
|
|
216
|
+
for (let qz = 0; qz < 4; qz++) {
|
|
217
|
+
for (let qx = 0; qx < 4; qx++) {
|
|
218
|
+
pos.set(qx * 4, qy * 4, qz * 4);
|
|
219
|
+
chunk.setBiome(pos, ids[biomes[(src * 4 + qz) * 4 + qx]]);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// full-bright like the other generators: max sky + block light everywhere
|
|
224
|
+
for (let y = 0; y < worldHeight; y++) {
|
|
225
|
+
pos.y = minY + y;
|
|
226
|
+
for (let z = 0; z < 16; z++) {
|
|
227
|
+
pos.z = z;
|
|
228
|
+
for (let x = 0; x < 16; x++) {
|
|
229
|
+
pos.x = x;
|
|
230
|
+
chunk.setSkyLight(pos, 15);
|
|
231
|
+
chunk.setBlockLight(pos, 15);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return chunk;
|
|
236
|
+
}
|
|
237
|
+
/** releases the worker generator (and the pool when it was the last user) */
|
|
238
|
+
generateChunk.dispose = async () => { if (sourceP) {
|
|
239
|
+
const p = sourceP;
|
|
240
|
+
sourceP = undefined;
|
|
241
|
+
try {
|
|
242
|
+
await (await p).close();
|
|
243
|
+
}
|
|
244
|
+
catch { }
|
|
245
|
+
} };
|
|
246
|
+
return generateChunk;
|
|
247
|
+
}
|
|
248
|
+
module.exports = generation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const minigame: (server: Server) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minigame = void 0;
|
|
4
|
+
const vec3_1 = require("vec3");
|
|
5
|
+
const randomBlocksByEra = {
|
|
6
|
+
wood: ['dirt', 'oak_planks', 'spruce_planks', 'birch_planks', 'jungle_planks', 'acacia_planks', 'dark_oak_planks'],
|
|
7
|
+
mining: ['stone', 'iron_ore', 'granite', 'redstone_ore', 'diamond_ore', 'coal_ore'],
|
|
8
|
+
};
|
|
9
|
+
const minigame = (server) => {
|
|
10
|
+
server.spawnPoint = new vec3_1.Vec3(0, 1, 0);
|
|
11
|
+
const setBlock = (player) => {
|
|
12
|
+
const world = player.world;
|
|
13
|
+
const position = new vec3_1.Vec3(0, 0, 0);
|
|
14
|
+
const column = world.getLoadedColumn(0, 0);
|
|
15
|
+
if (!column)
|
|
16
|
+
return;
|
|
17
|
+
let block = column.getBlock(position);
|
|
18
|
+
while (!block) {
|
|
19
|
+
try {
|
|
20
|
+
const allBlockNames = Object.keys(randomBlocksByEra).flatMap(era => randomBlocksByEra[era]);
|
|
21
|
+
const blockName = allBlockNames[Math.floor(Math.random() * allBlockNames.length)];
|
|
22
|
+
block = server.PrismarineBlock.fromStateId(server.mcData.blocksByName[blockName].defaultState, 0);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
world.setBlock(position, block);
|
|
29
|
+
};
|
|
30
|
+
server.on('newPlayer', (player) => {
|
|
31
|
+
// if player's inventory is empty give an iron pickaxe
|
|
32
|
+
if (player.inventory.slots.length === 0) {
|
|
33
|
+
server.handleCommand(`give ${player.name} iron_pickaxe 1`);
|
|
34
|
+
}
|
|
35
|
+
setBlock(player);
|
|
36
|
+
player.on('dug_done', () => {
|
|
37
|
+
setBlock(player);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.minigame = minigame;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const minigame: (server: Server) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minigame = void 0;
|
|
4
|
+
const vec3_1 = require("vec3");
|
|
5
|
+
const minigame = (server) => {
|
|
6
|
+
server.spawnPoint = new vec3_1.Vec3(1, 1, 0);
|
|
7
|
+
server.on('newPlayer', (player) => {
|
|
8
|
+
// if player's inventory is empty give a TNT
|
|
9
|
+
if (player.inventory.slots.length === 0) {
|
|
10
|
+
server.handleCommand(`give ${player.name} tnt 1`);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.minigame = minigame;
|
package/dist/modules.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ declare global {
|
|
|
40
40
|
newEntity: (entity: Entity) => void;
|
|
41
41
|
tick: (delta: number, tickCount: number) => void;
|
|
42
42
|
/** Emit seed once the world is loaded */
|
|
43
|
-
seed: (seed: number) => void;
|
|
43
|
+
seed: (seed: number | bigint) => void;
|
|
44
44
|
warpsLoaded: () => void;
|
|
45
45
|
}
|
|
46
46
|
interface Server extends TypedEmitter<ServerEvents> {
|
|
@@ -85,7 +85,7 @@ declare global {
|
|
|
85
85
|
options: {
|
|
86
86
|
worldHeight?: number;
|
|
87
87
|
minY?: number;
|
|
88
|
-
seed?: number;
|
|
88
|
+
seed?: string | number | bigint;
|
|
89
89
|
version?: string;
|
|
90
90
|
};
|
|
91
91
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ import "./lib/modules/players.d.ts"
|
|
|
43
43
|
import "./lib/modules/pluginsFolder.d.ts"
|
|
44
44
|
import "./lib/modules/portal.d.ts"
|
|
45
45
|
import "./lib/modules/pvp.d.ts"
|
|
46
|
+
import "./lib/modules/recipes.d.ts"
|
|
46
47
|
import "./lib/modules/redstone.d.ts"
|
|
47
48
|
import "./lib/modules/resourcePack.d.ts"
|
|
48
49
|
import "./lib/modules/respawn.d.ts"
|
|
@@ -63,3 +64,4 @@ import "./lib/modules/utils.d.ts"
|
|
|
63
64
|
import "./lib/modules/warps.d.ts"
|
|
64
65
|
import "./lib/modules/weather.d.ts"
|
|
65
66
|
import "./lib/modules/world.d.ts"
|
|
67
|
+
import "./lib/modules/worldManager.d.ts"
|
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.
|
|
4
|
+
"version": "0.0.124",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"bin": "dist/app.js",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"@tootallnate/once": "2.0.0",
|
|
25
25
|
"chalk": "^5.3.0",
|
|
26
26
|
"change-case": "^4.1.2",
|
|
27
|
-
"diamond-square": "github:zardoy/diamond-square",
|
|
28
27
|
"exit-hook": "^2.2.1",
|
|
29
28
|
"flatmap": "^0.0.3",
|
|
30
29
|
"long": "^5.1.0",
|
|
31
30
|
"mc-bridge": "^0.1.1",
|
|
31
|
+
"minecraft-worldgen": "^0.1.0",
|
|
32
32
|
"minecraft-data": "^3.95.0",
|
|
33
33
|
"minecraft-protocol": "^1.60.1",
|
|
34
34
|
"mkdirp": "^2.1.3",
|