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

Method LoadEntityBaseFromNBT

src/WorldStorage/WSSAnvil.cpp:2377–2407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2375
2376
2377bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
2378{
2379 double Pos[3];
2380 if (!LoadDoublesListFromNBT(Pos, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Pos")))
2381 {
2382 return false;
2383 }
2384 a_Entity.SetPosition(Pos[0], Pos[1], Pos[2]);
2385
2386 double Speed[3];
2387 if (!LoadDoublesListFromNBT(Speed, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Motion")))
2388 {
2389 // Provide default speed:
2390 Speed[0] = 0;
2391 Speed[1] = 0;
2392 Speed[2] = 0;
2393 }
2394 a_Entity.SetSpeed(Speed[0], Speed[1], Speed[2]);
2395
2396 double Rotation[3];
2397 if (!LoadDoublesListFromNBT(Rotation, 2, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Rotation")))
2398 {
2399 // Provide default rotation:
2400 Rotation[0] = 0;
2401 Rotation[1] = 0;
2402 }
2403 a_Entity.SetYaw(Rotation[0]);
2404 a_Entity.SetRoll(Rotation[1]);
2405
2406 return true;
2407}
2408
2409
2410

Callers

nothing calls this directly

Calls 5

SetYawMethod · 0.80
SetRollMethod · 0.80
FindChildByNameMethod · 0.45
SetPositionMethod · 0.45
SetSpeedMethod · 0.45

Tested by

no test coverage detected