@zardoy/flying-squid 0.0.132 → 0.0.134
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/dist/lib/entityPhysics.d.ts +48 -0
- package/dist/lib/entityPhysics.js +178 -0
- package/dist/lib/modules/bed.d.ts +16 -0
- package/dist/lib/modules/bed.js +63 -0
- package/dist/lib/modules/daycycle.d.ts +7 -0
- package/dist/lib/modules/daycycle.js +16 -5
- package/dist/lib/modules/endFight.d.ts +17 -0
- package/dist/lib/modules/endFight.js +298 -0
- package/dist/lib/modules/entities.js +7 -8
- package/dist/lib/modules/index.js +5 -0
- package/dist/lib/modules/mobs.d.ts +86 -0
- package/dist/lib/modules/mobs.js +456 -0
- package/dist/lib/modules/physics.d.ts +7 -1
- package/dist/lib/modules/physics.js +18 -48
- package/dist/lib/modules/playerLogin.js +6 -14
- package/dist/lib/modules/portal.js +7 -3
- package/dist/lib/modules/projectiles.d.ts +22 -0
- package/dist/lib/modules/projectiles.js +334 -0
- package/dist/lib/modules/pvp.d.ts +4 -1
- package/dist/lib/modules/pvp.js +25 -6
- package/dist/lib/modules/respawn.js +3 -3
- package/dist/lib/modules/spawners.d.ts +9 -0
- package/dist/lib/modules/spawners.js +114 -0
- package/dist/lib/modules/updatePositions.d.ts +2 -0
- package/dist/lib/modules/updatePositions.js +26 -2
- package/dist/lib/modules/world.d.ts +4 -0
- package/dist/lib/modules/world.js +37 -11
- package/dist/lib/playerDat.js +18 -1
- package/dist/lib/worldGenerations/noise.d.ts +1 -0
- package/dist/lib/worldGenerations/noise.js +25 -2
- package/dist/types.d.ts +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.server = void 0;
|
|
4
|
+
exports.spawnerEntityOf = spawnerEntityOf;
|
|
5
|
+
const vec3_1 = require("vec3");
|
|
6
|
+
const entityPhysics_1 = require("../entityPhysics");
|
|
7
|
+
/**
|
|
8
|
+
* Mob spawner blocks (nether fortress blazes, dungeons, mineshaft cave spiders, stronghold silverfish, spawners of vanilla saves).
|
|
9
|
+
*
|
|
10
|
+
* Like `BaseSpawner`: while a survival player is within `RequiredPlayerRange` (16) blocks the delay counts down; at zero up to `SpawnCount` mobs appear at random spots within
|
|
11
|
+
* `SpawnRange` blocks (x, z) and +-1 block (y), unless `MaxNearbyEntities` mobs of that type are around already; then a new delay of `MinSpawnDelay`..`MaxSpawnDelay` ticks starts.
|
|
12
|
+
* Light levels and the spawn rules of the individual mobs are ignored. Blazes (and every other flying mob) can spawn in the air.
|
|
13
|
+
*
|
|
14
|
+
* The state lives in the block entity of the chunk (`Delay` is written back every few seconds), so it survives saving.
|
|
15
|
+
*/
|
|
16
|
+
const num = (tag, fallback) => (typeof tag?.value === 'number' ? tag.value : fallback);
|
|
17
|
+
/** entity id of a spawner block entity (1.21 `SpawnData.entity.id`, 1.18 `SpawnData.id`, 1.8 `EntityId`, `SpawnPotentials`) */
|
|
18
|
+
function spawnerEntityOf(be) {
|
|
19
|
+
const sd = be?.SpawnData?.value;
|
|
20
|
+
const id = sd?.entity?.value?.id?.value ?? sd?.id?.value ?? be?.EntityId?.value;
|
|
21
|
+
if (typeof id === 'string')
|
|
22
|
+
return id;
|
|
23
|
+
const pot = be?.SpawnPotentials?.value?.value?.[0];
|
|
24
|
+
const pid = pot?.data?.value?.entity?.value?.id?.value ?? pot?.data?.value?.id?.value ?? pot?.Entity?.value?.id?.value ?? pot?.Type?.value;
|
|
25
|
+
return typeof pid === 'string' ? pid : undefined;
|
|
26
|
+
}
|
|
27
|
+
const server = function (serv, options) {
|
|
28
|
+
const mcData = serv.mcData;
|
|
29
|
+
const spawnerBlocks = new Set(['spawner', 'mob_spawner']);
|
|
30
|
+
const delays = new Map();
|
|
31
|
+
const every = 2; // ticks between checks
|
|
32
|
+
const keyOf = (world, pos) => `${world.worldName ?? 'world'}:${pos.x},${pos.y},${pos.z}`;
|
|
33
|
+
const strip = (id) => id.replace(/^minecraft:/, '');
|
|
34
|
+
const spotFree = (world, p, size) => (0, entityPhysics_1.collisionBoxes)(world, [p.x - size.x / 2 + 1e-3, p.y + 1e-3, p.z - size.z / 2 + 1e-3, p.x + size.x / 2 - 1e-3, p.y + size.y - 1e-3, p.z + size.z / 2 - 1e-3]).length === 0;
|
|
35
|
+
const trySpawn = (world, pos, be, entityName) => {
|
|
36
|
+
const typeId = serv.entityTypeId(entityName, 'mob');
|
|
37
|
+
if (typeId === undefined)
|
|
38
|
+
return false;
|
|
39
|
+
const range = num(be.SpawnRange, 4);
|
|
40
|
+
const count = num(be.SpawnCount, 4);
|
|
41
|
+
const maxNearby = num(be.MaxNearbyEntities, 6);
|
|
42
|
+
const name = strip(entityName);
|
|
43
|
+
const nearby = Object.values(serv.entities).filter(e => e.world === world && e.type === 'mob' && !e.dead && (e.name ?? '').toLowerCase() === name &&
|
|
44
|
+
Math.abs(e.position.x - pos.x) <= range + 4 && Math.abs(e.position.z - pos.z) <= range + 4 && Math.abs(e.position.y - pos.y) <= range + 4).length;
|
|
45
|
+
if (nearby >= maxNearby)
|
|
46
|
+
return false;
|
|
47
|
+
const info = mcData.entitiesArray.find(e => e.id === typeId);
|
|
48
|
+
const size = new vec3_1.Vec3(info?.width ?? 0.6, info?.height ?? 1.8, info?.width ?? 0.6);
|
|
49
|
+
let spawned = 0;
|
|
50
|
+
for (let i = 0; i < count && nearby + spawned < maxNearby; i++) {
|
|
51
|
+
for (let attempt = 0; attempt < 8; attempt++) {
|
|
52
|
+
const p = new vec3_1.Vec3(pos.x + 0.5 + (Math.random() - Math.random()) * range, pos.y + Math.floor(Math.random() * 3) - 1, pos.z + 0.5 + (Math.random() - Math.random()) * range);
|
|
53
|
+
if (!spotFree(world, p, size))
|
|
54
|
+
continue;
|
|
55
|
+
serv.spawnMob(typeId, world, p, { yaw: Math.random() * 360 }).spawnerKey = keyOf(world, pos);
|
|
56
|
+
spawned++;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (spawned)
|
|
61
|
+
serv.emitParticle?.(mcData.particlesByName?.flame?.id ?? 0, world, pos.offset(0.5, 0.5, 0.5), { count: 10, size: new vec3_1.Vec3(1, 1, 1) });
|
|
62
|
+
return spawned > 0;
|
|
63
|
+
};
|
|
64
|
+
let tick = 0;
|
|
65
|
+
serv.on('tick', () => {
|
|
66
|
+
tick++;
|
|
67
|
+
if (tick % every !== 0)
|
|
68
|
+
return;
|
|
69
|
+
const done = new Set();
|
|
70
|
+
for (const player of serv.players) {
|
|
71
|
+
if (player.gameMode === 1 || player.gameMode === 3 || !player.world)
|
|
72
|
+
continue;
|
|
73
|
+
const world = player.world;
|
|
74
|
+
const cx = Math.floor(player.position.x / 16);
|
|
75
|
+
const cz = Math.floor(player.position.z / 16);
|
|
76
|
+
for (let dx = -2; dx <= 2; dx++) {
|
|
77
|
+
for (let dz = -2; dz <= 2; dz++) {
|
|
78
|
+
const column = world.getLoadedColumn(cx + dx, cz + dz);
|
|
79
|
+
if (!column || done.has(column))
|
|
80
|
+
continue;
|
|
81
|
+
done.add(column);
|
|
82
|
+
for (const [key, be] of Object.entries(column.blockEntities ?? {})) {
|
|
83
|
+
const entityName = spawnerEntityOf(be);
|
|
84
|
+
if (!entityName)
|
|
85
|
+
continue;
|
|
86
|
+
const [x, y, z] = key.split(',').map(Number);
|
|
87
|
+
const pos = new vec3_1.Vec3(x, y, z);
|
|
88
|
+
// a spawner whose block is gone does nothing
|
|
89
|
+
const block = world.sync.getBlock(pos);
|
|
90
|
+
if (!block || !spawnerBlocks.has(block.name))
|
|
91
|
+
continue;
|
|
92
|
+
const range = num(be.RequiredPlayerRange, 16);
|
|
93
|
+
const near = serv.players.some(p => p.world === world && p.gameMode !== 1 && p.gameMode !== 3 && p.position.distanceTo(pos.offset(0.5, 0.5, 0.5)) <= range);
|
|
94
|
+
if (!near)
|
|
95
|
+
continue;
|
|
96
|
+
const k = keyOf(world, pos);
|
|
97
|
+
let delay = delays.get(k) ?? num(be.Delay, 20);
|
|
98
|
+
delay -= every;
|
|
99
|
+
if (delay <= 0) {
|
|
100
|
+
trySpawn(world, pos, be, entityName);
|
|
101
|
+
const min = num(be.MinSpawnDelay, 200);
|
|
102
|
+
const max = num(be.MaxSpawnDelay, 800);
|
|
103
|
+
delay = min + Math.floor(Math.random() * (Math.max(max, min) - min + 1));
|
|
104
|
+
if (be.Delay)
|
|
105
|
+
be.Delay.value = delay;
|
|
106
|
+
}
|
|
107
|
+
delays.set(k, delay);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
exports.server = server;
|
|
@@ -25,6 +25,8 @@ declare global {
|
|
|
25
25
|
/** Pitch of entity (rotation sideways) */
|
|
26
26
|
pitch: number;
|
|
27
27
|
"teleport": (pos: Vec3) => void;
|
|
28
|
+
/** sends the current position as an absolute position to the clients nearby (resync of clients that predict movement) */
|
|
29
|
+
sendAbsolute: () => void;
|
|
28
30
|
}
|
|
29
31
|
interface PlayerBehaviorInputMap {
|
|
30
32
|
'move': {
|
|
@@ -115,6 +115,8 @@ const player = function (player) {
|
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
117
|
exports.player = player;
|
|
118
|
+
const degreesToByte = (deg) => { let b = Math.floor(((deg % 360) + 360) % 360 * 256 / 360); if (b > 127)
|
|
119
|
+
b -= 256; return b; };
|
|
118
120
|
const entity = function (entity, serv) {
|
|
119
121
|
entity.sendPosition = async (position, onGround, teleport = false) => {
|
|
120
122
|
if (typeof position === 'undefined')
|
|
@@ -153,8 +155,9 @@ const entity = function (entity, serv) {
|
|
|
153
155
|
x: entityPosition.x,
|
|
154
156
|
y: entityPosition.y,
|
|
155
157
|
z: entityPosition.z,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
// players keep their rotation as protocol bytes, other entities as degrees
|
|
159
|
+
yaw: entity.type === 'player' ? entity.yaw : degreesToByte(entity.yawDeg ?? entity.yaw ?? 0),
|
|
160
|
+
pitch: entity.type === 'player' ? entity.pitch : degreesToByte(entity.pitch ?? 0),
|
|
158
161
|
onGround
|
|
159
162
|
});
|
|
160
163
|
entity.knownPosition = position;
|
|
@@ -186,6 +189,27 @@ const entity = function (entity, serv) {
|
|
|
186
189
|
});
|
|
187
190
|
return !cancelled;
|
|
188
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* Absolute position for the clients nearby. Moves are sent as small deltas against the position the client has; a client that predicts movement itself (mineflayer's entity
|
|
194
|
+
* physics: gravity, water) drifts away from the server over time. An absolute position now and then (see entities.ts) puts every entity back where the server has it.
|
|
195
|
+
*/
|
|
196
|
+
entity.sendAbsolute = () => {
|
|
197
|
+
let entityPosition;
|
|
198
|
+
if (serv.supportFeature('fixedPointPosition'))
|
|
199
|
+
entityPosition = entity.position.scaled(32).floored();
|
|
200
|
+
else
|
|
201
|
+
entityPosition = entity.position;
|
|
202
|
+
entity._writeOthersNearby('entity_teleport', {
|
|
203
|
+
entityId: entity.id,
|
|
204
|
+
x: entityPosition.x,
|
|
205
|
+
y: entityPosition.y,
|
|
206
|
+
z: entityPosition.z,
|
|
207
|
+
yaw: entity.type === 'player' ? entity.yaw : degreesToByte(entity.yawDeg ?? entity.yaw ?? 0),
|
|
208
|
+
pitch: entity.type === 'player' ? entity.pitch : degreesToByte(entity.pitch ?? 0),
|
|
209
|
+
onGround: !!entity.onGround
|
|
210
|
+
});
|
|
211
|
+
entity.knownPosition = entity.position.clone();
|
|
212
|
+
};
|
|
189
213
|
entity.teleport = (pos) => {
|
|
190
214
|
entity.sendPosition(pos, false, true);
|
|
191
215
|
};
|
|
@@ -19,6 +19,8 @@ export interface WorldSpec {
|
|
|
19
19
|
options?: Record<string, any>;
|
|
20
20
|
}
|
|
21
21
|
export interface CustomWorld extends World {
|
|
22
|
+
/** block positions (x, z) of the strongholds of this world, `limit` = first rings only (noise generator, overworld) */
|
|
23
|
+
strongholds?: (limit?: number) => Promise<Array<[number, number]>>;
|
|
22
24
|
/** releases the chunk generator (worker side caches) */
|
|
23
25
|
disposeGenerator?: () => Promise<void>;
|
|
24
26
|
blockEntityData: Record<string, any>;
|
|
@@ -66,6 +68,8 @@ declare global {
|
|
|
66
68
|
dimension: any;
|
|
67
69
|
worldName: string;
|
|
68
70
|
};
|
|
71
|
+
/** `worldState` (SpawnInfo) of the login / respawn packet of 1.20.2+ */
|
|
72
|
+
worldState: (world: any, gameMode: number, previousGameMode: number | undefined, dimension?: number) => any;
|
|
69
73
|
/** Saves block in world and sends block update to all players of the same world. */
|
|
70
74
|
"setBlock": (world: CustomWorld, position: Vec3, stateId: number) => Promise<void>;
|
|
71
75
|
/** Sends a block action to all players of the same world. */
|
|
@@ -224,6 +224,7 @@ const server = async function (serv, options) {
|
|
|
224
224
|
}, regionFolder === undefined || !Anvil ? null : new Anvil(regionFolder), options.savingInterval);
|
|
225
225
|
serv.overworld.seed = serv.seed = generationOptions.seed;
|
|
226
226
|
serv.overworld.generatorName = generation.name;
|
|
227
|
+
serv.overworld.strongholds = originalGenerator.strongholds;
|
|
227
228
|
patchWorld(serv.overworld);
|
|
228
229
|
dedupeGetColumn(serv.overworld);
|
|
229
230
|
// ---- world registry (Multiverse-style): any number of worlds; each has an environment (= client dimension type) and a generator
|
|
@@ -330,6 +331,7 @@ const server = async function (serv, options) {
|
|
|
330
331
|
const world = new World(generator, storageFor(spec.name, environment, opts.minY, opts.worldHeight), options.savingInterval);
|
|
331
332
|
world['min_y'] = opts.minY;
|
|
332
333
|
world.disposeGenerator = generator?.dispose;
|
|
334
|
+
world.strongholds = generator?.strongholds;
|
|
333
335
|
world['height'] = opts.worldHeight;
|
|
334
336
|
dedupeGetColumn(world);
|
|
335
337
|
world.seed = worldSeed;
|
|
@@ -396,6 +398,27 @@ const server = async function (serv, options) {
|
|
|
396
398
|
dimension: serv.supportFeature('dimensionIsAString') ? serv.dimensionNames[dimension || 0] : serv.supportFeature('dimensionIsAnInt') ? dimension || 0 : (0, dimensionCodec_1.dimensionNbt)(dimension || 0),
|
|
397
399
|
worldName: ['overworld', 'nether', 'end'].includes(world?.worldName) || !world?.worldName ? serv.dimensionNames[dimension || 0] : `flyingsquid:${world.worldName.toLowerCase()}`
|
|
398
400
|
});
|
|
401
|
+
/**
|
|
402
|
+
* `worldState` (protocol `SpawnInfo`) of the login and respawn packets since 1.20.2: the dimension is an index into the `minecraft:dimension_type` registry the client has,
|
|
403
|
+
* the name is the level identifier. Without it the client never switches dimension (the respawn packet cannot even be written) and then fails on the chunks of the new one.
|
|
404
|
+
*/
|
|
405
|
+
serv.worldState = (world, gameMode, previousGameMode, dimension = world?.dimensionId ?? 0) => {
|
|
406
|
+
const typeName = dimension === -1 ? 'minecraft:the_nether' : dimension === 1 ? 'minecraft:the_end' : 'minecraft:overworld';
|
|
407
|
+
const entries = serv.mcData.loginPacket?.dimensionCodec?.['minecraft:dimension_type']?.entries;
|
|
408
|
+
const index = Math.max(0, entries?.findIndex(e => e.key === typeName) ?? 0);
|
|
409
|
+
return {
|
|
410
|
+
dimension: index,
|
|
411
|
+
name: serv.worldClientInfo(world, dimension).worldName,
|
|
412
|
+
hashedSeed: serv.hashedSeed,
|
|
413
|
+
gamemode: { 0: 'survival', 1: 'creative', 2: 'adventure', 3: 'spectator' }[gameMode] ?? 'survival',
|
|
414
|
+
previousGamemode: previousGameMode ?? 255,
|
|
415
|
+
isDebug: false,
|
|
416
|
+
isFlat: false,
|
|
417
|
+
death: undefined,
|
|
418
|
+
portalCooldown: 0,
|
|
419
|
+
seaLevel: dimension === -1 ? 32 : dimension === 1 ? 0 : 63
|
|
420
|
+
};
|
|
421
|
+
};
|
|
399
422
|
serv.overworld.blockEntityData = {};
|
|
400
423
|
serv.overworld.portals = [];
|
|
401
424
|
serv.pregenWorld = (world, size = 3) => {
|
|
@@ -877,21 +900,24 @@ const player = function (player, serv, settings) {
|
|
|
877
900
|
player.prevGameMode = player.gameMode;
|
|
878
901
|
player.gameMode = opt.gamemode;
|
|
879
902
|
}
|
|
880
|
-
player._client.write('respawn',
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
903
|
+
player._client.write('respawn', serv.supportFeature('spawnRespawnWorldDataField')
|
|
904
|
+
? { worldState: serv.worldState(world, opt.gamemode || player.gameMode, player.prevGameMode, opt.dimension), copyMetadata: 1 }
|
|
905
|
+
: {
|
|
906
|
+
previousGameMode: player.prevGameMode,
|
|
907
|
+
...serv.worldClientInfo(world, opt.dimension),
|
|
908
|
+
difficulty: opt.difficulty || serv.difficulty,
|
|
909
|
+
hashedSeed: serv.hashedSeed,
|
|
910
|
+
gamemode: opt.gamemode || player.gameMode,
|
|
911
|
+
levelType: 'default',
|
|
912
|
+
isDebug: false,
|
|
913
|
+
isFlat: false,
|
|
914
|
+
copyMetadata: true
|
|
915
|
+
});
|
|
891
916
|
await player.findSpawnPoint();
|
|
892
917
|
// `player.spawnPoint` is the respawn point in the overworld: another world has its own standable entry point
|
|
893
918
|
player.position = opt.position ?? (world === serv.overworld || !serv.worldEntryPoint ? player.spawnPoint : await serv.worldEntryPoint(world, from, player.position));
|
|
894
919
|
player.sendSpawnPosition();
|
|
920
|
+
player.sendTime();
|
|
895
921
|
player.updateAndSpawn();
|
|
896
922
|
await player.sendMap();
|
|
897
923
|
player.sendSelfPosition(false);
|
package/dist/lib/playerDat.js
CHANGED
|
@@ -64,6 +64,10 @@ async function read(uuid, getSpawnPoint, worldFolder, useInMemoryStorage) {
|
|
|
64
64
|
pitch: playerData.Rotation.value.value[1],
|
|
65
65
|
onGround: Boolean(playerData.OnGround.value),
|
|
66
66
|
flying: Boolean(playerData.abilities.value.flying.value),
|
|
67
|
+
// bed (Java: SpawnX/Y/Z + SpawnDimension) set in the overworld
|
|
68
|
+
...(playerData.SpawnX && playerData.SpawnY && playerData.SpawnZ && (!playerData.SpawnDimension || /overworld$/.test(playerData.SpawnDimension.value))
|
|
69
|
+
? { bedSpawn: new vec3_1.Vec3(playerData.SpawnX.value, playerData.SpawnY.value, playerData.SpawnZ.value) }
|
|
70
|
+
: {})
|
|
67
71
|
},
|
|
68
72
|
inventory: playerData.Inventory.value.value.map(nbtItem => {
|
|
69
73
|
if (nbtItem?.tag && !nbtItem.tag.name)
|
|
@@ -147,7 +151,8 @@ async function save(player, worldFolder, snakeCase, theFlattening, useInMemorySt
|
|
|
147
151
|
yaw: player.yaw,
|
|
148
152
|
pitch: player.pitch,
|
|
149
153
|
onGround: player.onGround,
|
|
150
|
-
flying: player.flying ?? 0
|
|
154
|
+
flying: player.flying ?? 0,
|
|
155
|
+
...(player.bedSpawn ? { bedSpawn: player.bedSpawn.clone() } : {})
|
|
151
156
|
},
|
|
152
157
|
inventory: playerInventoryToNBT(player.inventory, theFlattening),
|
|
153
158
|
enderItems: player.enderChestToNbt?.() ?? []
|
|
@@ -174,6 +179,18 @@ async function save(player, worldFolder, snakeCase, theFlattening, useInMemorySt
|
|
|
174
179
|
const ender = player.enderChestToNbt?.() ?? [];
|
|
175
180
|
newUncompressedData.value.EnderItems = ender.length ? { type: 'list', value: { type: 'compound', value: ender } } : { type: 'list', value: { type: 'end', value: [] } };
|
|
176
181
|
newUncompressedData.value.abilities.value.flying.value = player.flying ?? 0;
|
|
182
|
+
if (player.bedSpawn) {
|
|
183
|
+
newUncompressedData.value.SpawnX = { type: 'int', value: player.bedSpawn.x };
|
|
184
|
+
newUncompressedData.value.SpawnY = { type: 'int', value: player.bedSpawn.y };
|
|
185
|
+
newUncompressedData.value.SpawnZ = { type: 'int', value: player.bedSpawn.z };
|
|
186
|
+
newUncompressedData.value.SpawnDimension = { type: 'string', value: 'minecraft:overworld' };
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
delete newUncompressedData.value.SpawnX;
|
|
190
|
+
delete newUncompressedData.value.SpawnY;
|
|
191
|
+
delete newUncompressedData.value.SpawnZ;
|
|
192
|
+
delete newUncompressedData.value.SpawnDimension;
|
|
193
|
+
}
|
|
177
194
|
const newDataCompressed = await (0, node_gzip_1.gzip)((0, prismarine_nbt_1.writeUncompressed)(newUncompressedData));
|
|
178
195
|
await fs_1.promises.writeFile(`${worldFolder}/playerdata/${player.uuid}.dat`, newDataCompressed);
|
|
179
196
|
return newUncompressedData;
|
|
@@ -227,19 +227,40 @@ function generation(options = {}) {
|
|
|
227
227
|
const flattened = registry.supportFeature?.('theFlattening') !== false;
|
|
228
228
|
chunk.blockEntities ??= {};
|
|
229
229
|
for (const be of data.blockEntities) {
|
|
230
|
-
if (
|
|
230
|
+
if (be.y < minY || be.y >= minY + worldHeight)
|
|
231
|
+
continue;
|
|
232
|
+
if (!be.lootTable && !be.spawnerEntity)
|
|
231
233
|
continue;
|
|
232
234
|
const name = be.id.replace(/^minecraft:/, '');
|
|
233
235
|
pos.set(be.x, be.y, be.z);
|
|
234
236
|
// the block of this version at the position has to be the container (blocks newer than the version are replaced by stone / air)
|
|
235
237
|
if (registry.blocksByStateId[chunk.getBlockStateId(pos)]?.name !== name)
|
|
236
238
|
continue;
|
|
237
|
-
const legacyId = { chest: 'Chest', dispenser: 'Trap' }[name];
|
|
239
|
+
const legacyId = { chest: 'Chest', dispenser: 'Trap', spawner: 'MobSpawner' }[name];
|
|
238
240
|
if (!flattened && !legacyId)
|
|
239
241
|
continue;
|
|
240
242
|
const wx = chunkX * 16 + be.x;
|
|
241
243
|
const wz = chunkZ * 16 + be.z;
|
|
242
244
|
const seed = BigInt.asUintN(64, be.lootSeed ?? 0n);
|
|
245
|
+
if (be.spawnerEntity) {
|
|
246
|
+
// BaseSpawner defaults: first spawn after 20 ticks, then every 200-800 ticks, up to 4 mobs within 4 blocks, active within 16 blocks
|
|
247
|
+
const mob = be.spawnerEntity;
|
|
248
|
+
chunk.blockEntities[`${wx},${be.y},${wz}`] = {
|
|
249
|
+
id: { type: 'string', value: flattened ? be.id : legacyId },
|
|
250
|
+
x: { type: 'int', value: wx },
|
|
251
|
+
y: { type: 'int', value: be.y },
|
|
252
|
+
z: { type: 'int', value: wz },
|
|
253
|
+
Delay: { type: 'short', value: 20 },
|
|
254
|
+
MinSpawnDelay: { type: 'short', value: 200 },
|
|
255
|
+
MaxSpawnDelay: { type: 'short', value: 800 },
|
|
256
|
+
SpawnCount: { type: 'short', value: 4 },
|
|
257
|
+
MaxNearbyEntities: { type: 'short', value: 6 },
|
|
258
|
+
RequiredPlayerRange: { type: 'short', value: 16 },
|
|
259
|
+
SpawnRange: { type: 'short', value: 4 },
|
|
260
|
+
SpawnData: { type: 'compound', value: { entity: { type: 'compound', value: { id: { type: 'string', value: mob } } } } }
|
|
261
|
+
};
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
243
264
|
chunk.blockEntities[`${wx},${be.y},${wz}`] = {
|
|
244
265
|
id: { type: 'string', value: flattened ? be.id : legacyId },
|
|
245
266
|
x: { type: 'int', value: wx },
|
|
@@ -278,6 +299,8 @@ function generation(options = {}) {
|
|
|
278
299
|
return chunk;
|
|
279
300
|
}
|
|
280
301
|
/** releases the worker generator (and the pool when it was the last user) */
|
|
302
|
+
/** block positions (x, z) of the strongholds (eyes of ender point to them); `limit`: only the first rings (nearest the origin first) */
|
|
303
|
+
generateChunk.strongholds = async (limit) => (dimension === 'overworld' ? (await getSource()).strongholds(limit) : []);
|
|
281
304
|
generateChunk.dispose = async () => { if (sourceP) {
|
|
282
305
|
const p = sourceP;
|
|
283
306
|
sourceP = undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./lib/modules/animations.d.ts"
|
|
2
|
+
import "./lib/modules/bed.d.ts"
|
|
2
3
|
import "./lib/modules/behavior.d.ts"
|
|
3
4
|
import "./lib/modules/blockUpdates.d.ts"
|
|
4
5
|
import "./lib/modules/blocks.d.ts"
|
|
@@ -19,6 +20,7 @@ import "./lib/modules/daycycle.d.ts"
|
|
|
19
20
|
import "./lib/modules/digging.d.ts"
|
|
20
21
|
import "./lib/modules/dimensionCodec.d.ts"
|
|
21
22
|
import "./lib/modules/effects.d.ts"
|
|
23
|
+
import "./lib/modules/endFight.d.ts"
|
|
22
24
|
import "./lib/modules/entities.d.ts"
|
|
23
25
|
import "./lib/modules/errorHandler.d.ts"
|
|
24
26
|
import "./lib/modules/experience.d.ts"
|
|
@@ -34,6 +36,7 @@ import "./lib/modules/inventory.d.ts"
|
|
|
34
36
|
import "./lib/modules/log.d.ts"
|
|
35
37
|
import "./lib/modules/logout.d.ts"
|
|
36
38
|
import "./lib/modules/maps.d.ts"
|
|
39
|
+
import "./lib/modules/mobs.d.ts"
|
|
37
40
|
import "./lib/modules/moderation.d.ts"
|
|
38
41
|
import "./lib/modules/particle.d.ts"
|
|
39
42
|
import "./lib/modules/physics.d.ts"
|
|
@@ -42,6 +45,7 @@ import "./lib/modules/playerLogin.d.ts"
|
|
|
42
45
|
import "./lib/modules/players.d.ts"
|
|
43
46
|
import "./lib/modules/pluginsFolder.d.ts"
|
|
44
47
|
import "./lib/modules/portal.d.ts"
|
|
48
|
+
import "./lib/modules/projectiles.d.ts"
|
|
45
49
|
import "./lib/modules/pvp.d.ts"
|
|
46
50
|
import "./lib/modules/recipes.d.ts"
|
|
47
51
|
import "./lib/modules/redstone.d.ts"
|
|
@@ -54,6 +58,7 @@ import "./lib/modules/signs.d.ts"
|
|
|
54
58
|
import "./lib/modules/smelting.d.ts"
|
|
55
59
|
import "./lib/modules/sound.d.ts"
|
|
56
60
|
import "./lib/modules/spawn.d.ts"
|
|
61
|
+
import "./lib/modules/spawners.d.ts"
|
|
57
62
|
import "./lib/modules/stats.d.ts"
|
|
58
63
|
import "./lib/modules/tabComplete.d.ts"
|
|
59
64
|
import "./lib/modules/tick.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.134",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"bin": "dist/app.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"flatmap": "^0.0.3",
|
|
29
29
|
"long": "^5.1.0",
|
|
30
30
|
"mc-bridge": "^0.1.1",
|
|
31
|
-
"minecraft-worldgen": "^0.1.
|
|
31
|
+
"minecraft-worldgen": "^0.1.4",
|
|
32
32
|
"minecraft-data": "^3.95.0",
|
|
33
33
|
"minecraft-protocol": "^1.60.1",
|
|
34
34
|
"mkdirp": "^2.1.3",
|