player->control = control;
}
+void Client::selectPlayerItem(u16 item)
+{
+ LocalPlayer *player = m_env.getLocalPlayer();
+ assert(player != NULL);
+
+ player->wieldItem(item);
+}
+
// Returns true if the inventory of the local player has been
// updated from the server. If it is true, it is set to false.
bool Client::getLocalInventoryUpdated()
v3f getPlayerPosition(v3f *eye_position=NULL);
void setPlayerControl(PlayerControl &control);
-
+
+ void selectPlayerItem(u16 item);
+
// Returns true if the inventory of the local player has been
// updated from the server. If it is true, it is set to false.
bool getLocalInventoryUpdated();
if(client.getLocalInventoryUpdated()
|| g_selected_item != old_selected_item)
{
+ client.selectPlayerItem(g_selected_item);
old_selected_item = g_selected_item;
//std::cout<<"Updating local inventory"<<std::endl;
client.getLocalInventory(local_inventory);
craftresult_is_preview(true),
hp(20),
peer_id(PEER_ID_INEXISTENT),
+ m_selected_item(0),
m_pitch(0),
m_yaw(0),
m_speed(0,0,0),
delete inventory_backup;
}
+void Player::wieldItem(u16 item)
+{
+ m_selected_item = item;
+}
+
void Player::resetInventory()
{
inventory.clear();
snprintf(m_name, PLAYERNAME_SIZE, "%s", name);
}
+ virtual void wieldItem(u16 item);
+ virtual const InventoryItem *getWieldItem() const
+ {
+ const InventoryList *list = inventory.getList("main");
+ if (list)
+ return list->getItem(m_selected_item);
+ return NULL;
+ }
+
const char * getName()
{
return m_name;
protected:
char m_name[PLAYERNAME_SIZE];
+ u16 m_selected_item;
f32 m_pitch;
f32 m_yaw;
v3f m_speed;