@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.
- package/dist/lib/modules/playerLogin.js +16 -11
- package/package.json +1 -1
|
@@ -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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|