mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Chests work now!
This commit is contained in:
parent
9e683fff50
commit
4a92df6ff0
17 changed files with 519 additions and 147 deletions
|
@ -106,6 +106,9 @@ Client::Client(
|
|||
player->updateName(playername);
|
||||
|
||||
m_env.addPlayer(player);
|
||||
|
||||
// Initialize player in the inventory context
|
||||
m_inventory_context.current_player = player;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1862,6 +1865,44 @@ void Client::getLocalInventory(Inventory &dst)
|
|||
dst = player->inventory;
|
||||
}
|
||||
|
||||
InventoryContext *Client::getInventoryContext()
|
||||
{
|
||||
return &m_inventory_context;
|
||||
}
|
||||
|
||||
Inventory* Client::getInventory(InventoryContext *c, std::string id)
|
||||
{
|
||||
if(id == "current_player")
|
||||
{
|
||||
assert(c->current_player);
|
||||
return &(c->current_player->inventory);
|
||||
}
|
||||
|
||||
Strfnd fn(id);
|
||||
std::string id0 = fn.next(":");
|
||||
|
||||
if(id0 == "nodemeta")
|
||||
{
|
||||
v3s16 p;
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
NodeMetadata* meta = getNodeMetadata(p);
|
||||
if(meta)
|
||||
return meta->getInventory();
|
||||
dstream<<"nodemeta at ("<<p.X<<","<<p.Y<<","<<p.Z<<"): "
|
||||
<<"no metadata found"<<std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dstream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
|
||||
return NULL;
|
||||
}
|
||||
void Client::inventoryAction(InventoryAction *a)
|
||||
{
|
||||
sendInventoryAction(a);
|
||||
}
|
||||
|
||||
MapBlockObject * Client::getSelectedObject(
|
||||
f32 max_d,
|
||||
v3f from_pos_f_on_map,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue