@zardoy/flying-squid 0.0.103 → 0.0.104

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.
@@ -250,19 +250,24 @@ const player = async function (player, serv, settings) {
250
250
  const theItem = registry.itemsByName[itemName] || registry.blocksByName[itemName];
251
251
  // todo test with undefined values (need to preserve!)
252
252
  if (!theItem) {
253
- console.warn(`Unknown item ${itemName} (id in player ${player.username} inventory ${itemValue})`);
253
+ console.warn(`Failed to restore inventory slot. Unknown item ${itemName} (id in player ${player.username} inventory ${itemValue})`);
254
254
  return;
255
255
  }
256
- let newItem;
257
- // todo use supports
258
- if (mcData.version['<']('1.13'))
259
- newItem = new Item(theItem.id, item.Count.value, item.Damage.value);
260
- else if (item.tag)
261
- newItem = new Item(theItem.id, item.Count.value, item.tag);
262
- else
263
- newItem = new Item(theItem.id, item.Count.value);
264
- const slot = convertInventorySlotId.fromNBT(item.Slot.value);
265
- player.inventory.updateSlot(slot, newItem);
256
+ try {
257
+ let newItem;
258
+ // todo use supports
259
+ if (mcData.version['<']('1.13'))
260
+ newItem = new Item(theItem.id, (item.Count ?? item.count)?.value ?? 1, (item.Damage ?? item.damage).value);
261
+ else if (item.tag)
262
+ newItem = new Item(theItem.id, (item.Count ?? item.count)?.value ?? 1, item.tag);
263
+ else
264
+ newItem = new Item(theItem.id, (item.Count ?? item.count)?.value ?? 1);
265
+ const slot = convertInventorySlotId.fromNBT((item.Slot ?? item.slot).value);
266
+ player.inventory.updateSlot(slot, newItem);
267
+ }
268
+ catch (err) {
269
+ console.warn(`Failed to restore inventory slot. Error while restoring item ${itemName} (id in player ${player.username} inventory ${itemValue})`, err);
270
+ }
266
271
  });
267
272
  player._client.write('held_item_slot', {
268
273
  slot: player.heldItemSlot
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.103",
4
+ "version": "0.0.104",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",