本文整理汇总了C++中NBT_Value::GetListType方法的典型用法代码示例。如果您正苦于以下问题:C++ NBT_Value::GetListType方法的具体用法?C++ NBT_Value::GetListType怎么用?C++ NBT_Value::GetListType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBT_Value
的用法示例。
在下文中一共展示了NBT_Value::GetListType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onStartedDigging
void BlockChest::onStartedDigging(User* user, int8_t status, int32_t x, int16_t y, int32_t z, int map, int8_t direction)
{
// Locksystem
if (user->inv[36 + user->currentItemSlot()].getType() == ITEM_WOODEN_AXE)
{
int chunk_x = blockToChunk(x);
int chunk_z = blockToChunk(z);
sChunk* chunk = ServerInstance->map(map)->loadMap(chunk_x, chunk_z);
if (chunk == NULL)
{
return;
}
NBT_Value* entityList = (*(*(chunk->nbt))["Level"])["TileEntities"];
if (!entityList)
{
entityList = new NBT_Value(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND);
chunk->nbt->Insert("TileEntities", entityList);
}
if (entityList->GetType() == NBT_Value::TAG_LIST)
{
if (entityList->GetListType() != NBT_Value::TAG_COMPOUND)
{
entityList->SetType(NBT_Value::TAG_LIST, NBT_Value::TAG_COMPOUND);
}
std::vector<NBT_Value*> *entities = entityList->GetList();
std::vector<NBT_Value*>::iterator iter = entities->begin(), end = entities->end();
//bool done = false; // Unused variable
for (; iter != end; iter++)
{
if ((**iter)["x"] == NULL || (**iter)["y"] == NULL || (**iter)["z"] == NULL ||
(**iter)["x"]->GetType() != NBT_Value::TAG_INT ||
(**iter)["y"]->GetType() != NBT_Value::TAG_INT ||
(**iter)["z"]->GetType() != NBT_Value::TAG_INT)
{
continue;
}
if ((int32_t)(*(**iter)["x"]) == x && (int32_t)(*(**iter)["y"]) == y && (int32_t)(*(**iter)["z"]) == z)
{
int8_t locked;
NBT_Value* nbtLockdata = (**iter)["Lockdata"];
if (nbtLockdata != NULL)
{
std::string player = *(*nbtLockdata)["player"]->GetString();
// Toggle lock if player is the owner of block
if (player == user->nick)
{
locked = *(*nbtLockdata)["locked"];
locked = (locked == 1) ? 0 : 1;
*(*nbtLockdata)["locked"] = locked;
if (locked == 1)
{
ServerInstance->chat()->sendMsg(user, MC_COLOR_RED + "Chest locked", Chat::USER);
}
else
{
ServerInstance->chat()->sendMsg(user, MC_COLOR_RED + "Chest opened", Chat::USER);
}
}
}
else
{
// If lockdata is missing (old chest)
NBT_Value* nbtLock = new NBT_Value(NBT_Value::TAG_COMPOUND);
nbtLock->Insert("player", new NBT_Value(user->nick));
nbtLock->Insert("locked", new NBT_Value((int8_t)1));
(*iter)->Insert("Lockdata", nbtLock);
}
break;
}
}
}
}
}