Пример #1
0
//world
void World::init(void)
{
  width = 8;
  height = 8;

  // Replace this bit with a progmem loader doodah
  static const uint8_t leveldata[64] =
  {
    1,1,1,1,1,1,1,1,
    0,0,0,0,0,1,0,0,
    1,1,0,1,1,0,0,1,
    1,0,0,0,0,0,1,0,
    1,1,0,1,1,1,1,0,
    1,0,0,0,0,0,0,0,
    1,0,1,1,1,1,1,0,
    1,1,1,1,1,1,1,0
  };
  for(uint8_t i=0; i<64; ++i)
  {
    level[i] = static_cast<TileType>(leveldata[i]);
  };
  battleTendency = 4;

  // No need to assign to locals anymore
  //Chest chest1 = Chest(0,1,1);
  //Chest chest2 = Chest(1,6,1);
  
  // Creates a chest and adds it straight to the list
  chests.add(Chest(0, 1, ItemType::TestItem));
  chests.add(Chest(1, 6, ItemType::TestItem2));
}
Пример #2
0
void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
{
    ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
    int x, y, z;
    if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z))
    {
        return;
    }
    int Items = a_NBT.FindChildByName(a_TagIdx, "Items");
    if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List))
    {
        return;  // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this
    }
    std::auto_ptr<cChestEntity> Chest(new cChestEntity(x, y, z, m_World));
    LoadItemGridFromNBT(Chest->GetContents(), a_NBT, Items);
    a_BlockEntities.push_back(Chest.release());
}
Пример #3
0
// If you made Chest public you could just make this function accept an index and a Chest.
// Ultimately I'm concerned about other code being able to effectively overwrite all chests though.
// Maybe now ChestList is available you should change this to an add function that doesn't need an index
// and might potentially fail.
void World::setItem(const uint8_t item,const int8_t x, const int8_t y, const ItemType type)
{
  chests[item] = Chest(x,y,type);
}