@zardoy/flying-squid 0.0.136 → 0.0.138

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.
@@ -18,6 +18,10 @@ const server = function (serv, options) {
18
18
  const mcData = serv.mcData;
19
19
  const projectiles = new Set();
20
20
  const typeId = (names) => serv.entityTypeId(names, 'object');
21
+ // NoGravity (entity metadata 5, boolean, 1.9+): clients (mineflayer integrates ender pearls, snowballs, eggs and falling blocks itself) must not move what the server steers
22
+ const metaTypes = mcData.protocol?.types?.entityMetadataEntry?.[1]?.[1]?.type?.[1]?.mappings;
23
+ const boolType = Object.entries(metaTypes ?? {}).find(([, name]) => /^bool/.test(String(name)))?.[0];
24
+ const noGravityMetadata = () => (boolType !== undefined && mcData.version['>=']('1.9') ? [{ key: 5, type: Number(boolType), value: true }] : []);
21
25
  const spawn = (names, world, position, velocity, owner, size = 0.25) => {
22
26
  const id = typeId(names);
23
27
  if (id === undefined)
@@ -37,7 +41,7 @@ const server = function (serv, options) {
37
41
  e.pitch = pitch;
38
42
  e.yawDeg = yaw;
39
43
  e.data = (owner?.id ?? 0);
40
- e.metadata = [];
44
+ e.metadata = noGravityMetadata();
41
45
  e.updateAndSpawn();
42
46
  return e;
43
47
  };
@@ -273,9 +277,27 @@ const server = function (serv, options) {
273
277
  return;
274
278
  eyeBusy.add(player);
275
279
  try {
276
- const target = await nearestStronghold(player.world, player.position.x, player.position.z);
280
+ const world = player.world;
281
+ // say why there is nothing to point at (the eye is not used up in these cases)
282
+ if (world.environment !== 'normal') {
283
+ player.chat?.('The eye of ender only points to strongholds in the overworld.');
284
+ return;
285
+ }
286
+ if (!world.strongholds) {
287
+ player.chat?.(`This world has no strongholds (world generator: ${world.generatorName ?? 'unknown'}, only the noise generator makes them).`);
288
+ return;
289
+ }
290
+ let target;
291
+ try {
292
+ target = await nearestStronghold(world, player.position.x, player.position.z);
293
+ }
294
+ catch (e) {
295
+ serv.warn?.('stronghold search failed: ' + e.message);
296
+ player.chat?.('The stronghold search failed: ' + e.message);
297
+ return;
298
+ }
277
299
  if (!target) {
278
- player.chat?.('The eye has nothing to point at here.');
300
+ player.chat?.('No stronghold was found in this world.');
279
301
  return;
280
302
  }
281
303
  const start = player.position.offset(0, 1.62 * 0.5 + 0.2, 0);
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.136",
4
+ "version": "0.0.138",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",