MCPcopy Create free account
hub / github.com/cuberite/cuberite / LoadPickupFromNBT

Method LoadPickupFromNBT

src/WorldStorage/WSSAnvil.cpp:1416–1451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1414
1415
1416void 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

Callers

nothing calls this directly

Calls 7

getMethod · 0.80
SetHealthMethod · 0.80
GetShortMethod · 0.80
releaseMethod · 0.80
FindChildByNameMethod · 0.45
GetTypeMethod · 0.45
SetAgeMethod · 0.45

Tested by

no test coverage detected