| 1414 | |
| 1415 | |
| 1416 | void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) |
| 1417 | { |
| 1418 | // Load item: |
| 1419 | int ItemTag = a_NBT.FindChildByName(a_TagIdx, "Item"); |
| 1420 | if ((ItemTag < 0) || (a_NBT.GetType(ItemTag) != TAG_Compound)) |
| 1421 | { |
| 1422 | return; |
| 1423 | } |
| 1424 | cItem Item; |
| 1425 | if (!LoadItemFromNBT(Item, a_NBT, ItemTag)) |
| 1426 | { |
| 1427 | return; |
| 1428 | } |
| 1429 | |
| 1430 | std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false |
| 1431 | if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx)) |
| 1432 | { |
| 1433 | return; |
| 1434 | } |
| 1435 | |
| 1436 | // Load health: |
| 1437 | int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); |
| 1438 | if (Health > 0) |
| 1439 | { |
| 1440 | Pickup->SetHealth((int) (a_NBT.GetShort(Health) & 0xFF)); |
| 1441 | } |
| 1442 | |
| 1443 | // Load age: |
| 1444 | int Age = a_NBT.FindChildByName(a_TagIdx, "Age"); |
| 1445 | if (Age > 0) |
| 1446 | { |
| 1447 | Pickup->SetAge(a_NBT.GetShort(Age)); |
| 1448 | } |
| 1449 | |
| 1450 | a_Entities.push_back(Pickup.release()); |
| 1451 | } |
| 1452 | |
| 1453 | |
| 1454 | |