]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/script/lua_api/l_object.cpp
Add ItemStack:get_description() to get tooltip (#8847)
[dragonfireclient.git] / src / script / lua_api / l_object.cpp
index b3c3bdf668fb2fe27a64e980ad48785ae604907e..be2172f1b853d5cd4a80e37bb5ef4cdce244d43c 100644 (file)
@@ -18,9 +18,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "lua_api/l_object.h"
+#include <cmath>
 #include "lua_api/l_internal.h"
 #include "lua_api/l_inventory.h"
 #include "lua_api/l_item.h"
+#include "lua_api/l_playermeta.h"
 #include "common/c_converter.h"
 #include "common/c_content.h"
 #include "log.h"
@@ -101,12 +103,8 @@ int ObjectRef::l_remove(lua_State *L)
        if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
                return 0;
 
-       const std::unordered_set<int> &child_ids = co->getAttachmentChildIds();
-       for (int child_id : child_ids) {
-               // Child can be NULL if it was deleted earlier
-               if (ServerActiveObject *child = env->getActiveObject(child_id))
-                       child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
-       }
+       co->clearChildAttachments();
+       co->clearParentAttachment();
 
        verbosestream << "ObjectRef::l_remove(): id=" << co->getId() << std::endl;
        co->m_pending_removal = true;
@@ -158,7 +156,7 @@ int ObjectRef::l_move_to(lua_State *L)
        // pos
        v3f pos = checkFloatPos(L, 2);
        // continuous
-       bool continuous = lua_toboolean(L, 3);
+       bool continuous = readParam<bool>(L, 3);
        // Do it
        co->moveTo(pos, continuous);
        return 0;
@@ -172,8 +170,8 @@ int ObjectRef::l_punch(lua_State *L)
        ObjectRef *puncher_ref = checkobject(L, 2);
        ServerActiveObject *co = getobject(ref);
        ServerActiveObject *puncher = getobject(puncher_ref);
-       if (co == NULL) return 0;
-       if (puncher == NULL) return 0;
+       if (!co || !puncher)
+               return 0;
        v3f dir;
        if (lua_type(L, 5) != LUA_TTABLE)
                dir = co->getBasePosition() - puncher->getBasePosition();
@@ -185,8 +183,8 @@ int ObjectRef::l_punch(lua_State *L)
        ToolCapabilities toolcap = read_tool_capabilities(L, 4);
        dir.normalize();
 
-       s16 src_original_hp = co->getHP();
-       s16 dst_origin_hp = puncher->getHP();
+       u16 src_original_hp = co->getHP();
+       u16 dst_origin_hp = puncher->getHP();
 
        // Do it
        co->punch(dir, &toolcap, puncher, time_from_last_punch);
@@ -194,7 +192,8 @@ int ObjectRef::l_punch(lua_State *L)
        // If the punched is a player, and its HP changed
        if (src_original_hp != co->getHP() &&
                        co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
-               getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher));
+               getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co,
+                               PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher));
        }
 
        // If the puncher is a player, and its HP changed
@@ -245,7 +244,8 @@ int ObjectRef::l_set_hp(lua_State *L)
                lua_pushvalue(L, 3);
 
                lua_getfield(L, -1, "type");
-               if (lua_isstring(L, -1) && !reason.setTypeFromString(lua_tostring(L, -1))) {
+               if (lua_isstring(L, -1) &&
+                               !reason.setTypeFromString(readParam<std::string>(L, -1))) {
                        errorstream << "Bad type given!" << std::endl;
                }
                lua_pop(L, 1);
@@ -258,6 +258,9 @@ int ObjectRef::l_set_hp(lua_State *L)
        if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
                getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, reason);
 
+       if (reason.hasLuaReference())
+               luaL_unref(L, LUA_REGISTRYINDEX, reason.lua_reference);
+
        // Return
        return 0;
 }
@@ -305,8 +308,9 @@ int ObjectRef::l_get_wield_list(lua_State *L)
        NO_MAP_LOCK_REQUIRED;
        ObjectRef *ref = checkobject(L, 1);
        ServerActiveObject *co = getobject(ref);
-       if (co == NULL) return 0;
-       // Do it
+       if (!co)
+               return 0;
+
        lua_pushstring(L, co->getWieldList().c_str());
        return 1;
 }
@@ -317,8 +321,9 @@ int ObjectRef::l_get_wield_index(lua_State *L)
        NO_MAP_LOCK_REQUIRED;
        ObjectRef *ref = checkobject(L, 1);
        ServerActiveObject *co = getobject(ref);
-       if (co == NULL) return 0;
-       // Do it
+       if (!co)
+               return 0;
+
        lua_pushinteger(L, co->getWieldIndex() + 1);
        return 1;
 }
@@ -329,12 +334,12 @@ int ObjectRef::l_get_wielded_item(lua_State *L)
        NO_MAP_LOCK_REQUIRED;
        ObjectRef *ref = checkobject(L, 1);
        ServerActiveObject *co = getobject(ref);
-       if (co == NULL) {
+       if (!co) {
                // Empty ItemStack
                LuaItemStack::create(L, ItemStack());
                return 1;
        }
-       // Do it
+
        LuaItemStack::create(L, co->getWieldedItem());
        return 1;
 }
@@ -459,7 +464,7 @@ int ObjectRef::l_set_animation(lua_State *L)
        // Do it
        v2f frames = v2f(1, 1);
        if (!lua_isnil(L, 2))
-               frames = read_v2f(L, 2);
+               frames = readParam<v2f>(L, 2);
        float frame_speed = 15;
        if (!lua_isnil(L, 3))
                frame_speed = lua_tonumber(L, 3);
@@ -468,7 +473,7 @@ int ObjectRef::l_set_animation(lua_State *L)
                frame_blend = lua_tonumber(L, 4);
        bool frame_loop = true;
        if (lua_isboolean(L, 5))
-               frame_loop = lua_toboolean(L, 5);
+               frame_loop = readParam<bool>(L, 5);
        co->setAnimation(frames, frame_speed, frame_blend, frame_loop);
        return 0;
 }
@@ -581,6 +586,24 @@ int ObjectRef::l_get_eye_offset(lua_State *L)
        return 2;
 }
 
+// send_mapblock(self, pos)
+int ObjectRef::l_send_mapblock(lua_State *L)
+{
+       NO_MAP_LOCK_REQUIRED;
+       ObjectRef *ref = checkobject(L, 1);
+
+       RemotePlayer *player = getplayer(ref);
+       if (!player)
+               return 0;
+       v3s16 p = read_v3s16(L, 2);
+
+       session_t peer_id = player->getPeerId();
+       bool r = getServer(L)->SendBlock(peer_id, p);
+
+       lua_pushboolean(L, r);
+       return 1;
+}
+
 // set_animation_frame_speed(self, frame_speed)
 int ObjectRef::l_set_animation_frame_speed(lua_State *L)
 {
@@ -611,7 +634,7 @@ int ObjectRef::l_set_bone_position(lua_State *L)
        // Do it
        std::string bone;
        if (!lua_isnil(L, 2))
-               bone = lua_tostring(L, 2);
+               bone = readParam<std::string>(L, 2);
        v3f position = v3f(0, 0, 0);
        if (!lua_isnil(L, 3))
                position = check_v3f(L, 3);
@@ -633,7 +656,7 @@ int ObjectRef::l_get_bone_position(lua_State *L)
        // Do it
        std::string bone;
        if (!lua_isnil(L, 2))
-               bone = lua_tostring(L, 2);
+               bone = readParam<std::string>(L, 2);
 
        v3f position = v3f(0, 0, 0);
        v3f rotation = v3f(0, 0, 0);
@@ -670,7 +693,7 @@ int ObjectRef::l_set_attach(lua_State *L)
 
        bone = "";
        if (!lua_isnil(L, 3))
-               bone = lua_tostring(L, 3);
+               bone = readParam<std::string>(L, 3);
        position = v3f(0, 0, 0);
        if (!lua_isnil(L, 4))
                position = read_v3f(L, 4);
@@ -719,21 +742,7 @@ int ObjectRef::l_set_detach(lua_State *L)
        if (co == NULL)
                return 0;
 
-       int parent_id = 0;
-       std::string bone;
-       v3f position;
-       v3f rotation;
-       co->getAttachment(&parent_id, &bone, &position, &rotation);
-       ServerActiveObject *parent = NULL;
-       if (parent_id) {
-               parent = env->getActiveObject(parent_id);
-               co->setAttachment(0, "", position, rotation);
-       } else {
-               co->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
-       }
-       // Do it
-       if (parent != NULL)
-               parent->removeAttachmentChild(co->getId());
+       co->clearParentAttachment();
        return 0;
 }
 
@@ -743,17 +752,14 @@ int ObjectRef::l_set_properties(lua_State *L)
        NO_MAP_LOCK_REQUIRED;
        ObjectRef *ref = checkobject(L, 1);
        ServerActiveObject *co = getobject(ref);
-       if (co == NULL) return 0;
+       if (!co)
+               return 0;
+
        ObjectProperties *prop = co->accessObjectProperties();
        if (!prop)
                return 0;
-       read_object_properties(L, 2, prop, getServer(L)->idef());
-       if (prop->hp_max < co->getHP()) {
-               PlayerHPChangeReason reason(PlayerHPChangeReason::SET_HP);
-               co->setHP(prop->hp_max, reason);
-               if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
-                       getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, reason);
-       }
+
+       read_object_properties(L, 2, co, prop, getServer(L)->idef());
        co->notifyObjectPropertiesModified();
        return 0;
 }
@@ -904,16 +910,51 @@ int ObjectRef::l_get_acceleration(lua_State *L)
        return 1;
 }
 
+// set_rotation(self, {x=num, y=num, z=num})
+// Each 'num' is in radians
+int ObjectRef::l_set_rotation(lua_State *L)
+{
+       NO_MAP_LOCK_REQUIRED;
+       ObjectRef *ref = checkobject(L, 1);
+       LuaEntitySAO *co = getluaobject(ref);
+       if (!co)
+               return 0;
+
+       v3f rotation = check_v3f(L, 2) * core::RADTODEG;
+       co->setRotation(rotation);
+       return 0;
+}
+
+// get_rotation(self)
+// returns: {x=num, y=num, z=num}
+// Each 'num' is in radians
+int ObjectRef::l_get_rotation(lua_State *L)
+{
+       NO_MAP_LOCK_REQUIRED;
+       ObjectRef *ref = checkobject(L, 1);
+       LuaEntitySAO *co = getluaobject(ref);
+       if (!co)
+               return 0;
+
+       lua_newtable(L);
+       v3f rotation = co->getRotation() * core::DEGTORAD;
+       push_v3f(L, rotation);
+       return 1;
+}
+
 // set_yaw(self, radians)
 int ObjectRef::l_set_yaw(lua_State *L)
 {
        NO_MAP_LOCK_REQUIRED;
        ObjectRef *ref = checkobject(L, 1);
        LuaEntitySAO *co = getluaobject(ref);
+
        if (co == NULL) return 0;
-       float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
-       // Do it
-       co->setYaw(yaw);
+       if (isNaN(L, 2))
+               throw LuaError("ObjectRef::set_yaw: NaN value is not allowed.");
+
+       float yaw = readParam<float>(L, 2) * core::RADTODEG;
+       co->setRotation(v3f(0, yaw, 0));
        return 0;
 }
 
@@ -923,9 +964,10 @@ int ObjectRef::l_get_yaw(lua_State *L)
        NO_MAP_LOCK_REQUIRED;
        ObjectRef *ref = checkobject(L, 1);
        LuaEntitySAO *co = getluaobject(ref);
-       if (co == NULL) return 0;
-       // Do it
-       float yaw = co->getYaw() * core::DEGTORAD;
+       if (!co)
+               return 0;
+
+       float yaw = co->getRotation().Y * core::DEGTORAD;
        lua_pushnumber(L, yaw);
        return 1;
 }
@@ -967,7 +1009,7 @@ int ObjectRef::l_set_sprite(lua_State *L)
        // Do it
        v2s16 p(0,0);
        if (!lua_isnil(L, 2))
-               p = read_v2s16(L, 2);
+               p = readParam<v2s16>(L, 2);
        int num_frames = 1;
        if (!lua_isnil(L, 3))
                num_frames = lua_tonumber(L, 3);
@@ -976,7 +1018,7 @@ int ObjectRef::l_set_sprite(lua_State *L)
                framelength = lua_tonumber(L, 4);
        bool select_horiz_by_yawpitch = false;
        if (!lua_isnil(L, 5))
-               select_horiz_by_yawpitch = lua_toboolean(L, 5);
+               select_horiz_by_yawpitch = readParam<bool>(L, 5);
        co->setSprite(p, num_frames, framelength, select_horiz_by_yawpitch);
        return 0;
 }
@@ -1050,6 +1092,27 @@ int ObjectRef::l_get_player_velocity(lua_State *L)
        return 1;
 }
 
+// add_player_velocity(self, {x=num, y=num, z=num})
+int ObjectRef::l_add_player_velocity(lua_State *L)
+{
+       NO_MAP_LOCK_REQUIRED;
+       ObjectRef *ref = checkobject(L, 1);
+       v3f vel = checkFloatPos(L, 2);
+
+       RemotePlayer *player = getplayer(ref);
+       PlayerSAO *co = getplayersao(ref);
+       if (!player || !co)
+               return 0;
+
+       session_t peer_id = player->getPeerId();
+       if (peer_id == PEER_ID_INEXISTENT)
+               return 0;
+       // Do it
+       co->setMaxSpeedOverride(vel);
+       getServer(L)->SendPlayerSpeed(peer_id, vel);
+       return 0;
+}
+
 // get_look_dir(self)
 int ObjectRef::l_get_look_dir(lua_State *L)
 {
@@ -1058,9 +1121,10 @@ int ObjectRef::l_get_look_dir(lua_State *L)
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
        // Do it
-       float pitch = co->getRadPitchDep();
+       float pitch = co->getRadLookPitchDep();
        float yaw = co->getRadYawDep();
-       v3f v(cos(pitch)*cos(yaw), sin(pitch), cos(pitch)*sin(yaw));
+       v3f v(std::cos(pitch) * std::cos(yaw), std::sin(pitch), std::cos(pitch) *
+               std::sin(yaw));
        push_v3f(L, v);
        return 1;
 }
@@ -1078,7 +1142,7 @@ int ObjectRef::l_get_look_pitch(lua_State *L)
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
        // Do it
-       lua_pushnumber(L, co->getRadPitchDep());
+       lua_pushnumber(L, co->getRadLookPitchDep());
        return 1;
 }
 
@@ -1107,7 +1171,7 @@ int ObjectRef::l_get_look_vertical(lua_State *L)
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
        // Do it
-       lua_pushnumber(L, co->getRadPitch());
+       lua_pushnumber(L, co->getRadLookPitch());
        return 1;
 }
 
@@ -1119,7 +1183,7 @@ int ObjectRef::l_get_look_horizontal(lua_State *L)
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
        // Do it
-       lua_pushnumber(L, co->getRadYaw());
+       lua_pushnumber(L, co->getRadRotation().Y);
        return 1;
 }
 
@@ -1130,9 +1194,9 @@ int ObjectRef::l_set_look_vertical(lua_State *L)
        ObjectRef *ref = checkobject(L, 1);
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
-       float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
+       float pitch = readParam<float>(L, 2) * core::RADTODEG;
        // Do it
-       co->setPitchAndSend(pitch);
+       co->setLookPitchAndSend(pitch);
        return 1;
 }
 
@@ -1143,9 +1207,9 @@ int ObjectRef::l_set_look_horizontal(lua_State *L)
        ObjectRef *ref = checkobject(L, 1);
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
-       float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
+       float yaw = readParam<float>(L, 2) * core::RADTODEG;
        // Do it
-       co->setYawAndSend(yaw);
+       co->setPlayerYawAndSend(yaw);
        return 1;
 }
 
@@ -1161,9 +1225,9 @@ int ObjectRef::l_set_look_pitch(lua_State *L)
        ObjectRef *ref = checkobject(L, 1);
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
-       float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
+       float pitch = readParam<float>(L, 2) * core::RADTODEG;
        // Do it
-       co->setPitchAndSend(pitch);
+       co->setLookPitchAndSend(pitch);
        return 1;
 }
 
@@ -1179,9 +1243,9 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
        ObjectRef *ref = checkobject(L, 1);
        PlayerSAO* co = getplayersao(ref);
        if (co == NULL) return 0;
-       float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
+       float yaw = readParam<float>(L, 2) * core::RADTODEG;
        // Do it
-       co->setYawAndSend(yaw);
+       co->setPlayerYawAndSend(yaw);
        return 1;
 }
 
@@ -1214,18 +1278,20 @@ int ObjectRef::l_get_breath(lua_State *L)
 // set_attribute(self, attribute, value)
 int ObjectRef::l_set_attribute(lua_State *L)
 {
+       log_deprecated(L,
+               "Deprecated call to set_attribute, use MetaDataRef methods instead.");
+
        ObjectRef *ref = checkobject(L, 1);
        PlayerSAO* co = getplayersao(ref);
-       if (co == NULL) {
+       if (co == NULL)
                return 0;
-       }
 
        std::string attr = luaL_checkstring(L, 2);
        if (lua_isnil(L, 3)) {
-               co->removeExtendedAttribute(attr);
+               co->getMeta().removeString(attr);
        } else {
                std::string value = luaL_checkstring(L, 3);
-               co->setExtendedAttribute(attr, value);
+               co->getMeta().setString(attr, value);
        }
        return 1;
 }
@@ -1233,16 +1299,18 @@ int ObjectRef::l_set_attribute(lua_State *L)
 // get_attribute(self, attribute)
 int ObjectRef::l_get_attribute(lua_State *L)
 {
+       log_deprecated(L,
+               "Deprecated call to get_attribute, use MetaDataRef methods instead.");
+
        ObjectRef *ref = checkobject(L, 1);
        PlayerSAO* co = getplayersao(ref);
-       if (co == NULL) {
+       if (co == NULL)
                return 0;
-       }
 
        std::string attr = luaL_checkstring(L, 2);
 
        std::string value;
-       if (co->getExtendedAttribute(attr, &value)) {
+       if (co->getMeta().getStringToRef(attr, value)) {
                lua_pushstring(L, value.c_str());
                return 1;
        }
@@ -1251,6 +1319,19 @@ int ObjectRef::l_get_attribute(lua_State *L)
 }
 
 
+// get_meta(self, attribute)
+int ObjectRef::l_get_meta(lua_State *L)
+{
+       ObjectRef *ref = checkobject(L, 1);
+       PlayerSAO *co = getplayersao(ref);
+       if (co == NULL)
+               return 0;
+
+       PlayerMetaRef::create(L, &co->getMeta());
+       return 1;
+}
+
+
 // set_inventory_formspec(self, formspec)
 int ObjectRef::l_set_inventory_formspec(lua_State *L)
 {
@@ -1537,7 +1618,7 @@ int ObjectRef::l_hud_set_hotbar_image(lua_State *L)
        if (player == NULL)
                return 0;
 
-       std::string name = lua_tostring(L, 2);
+       std::string name = readParam<std::string>(L, 2);
 
        getServer(L)->hudSetHotbarImage(player, name);
        return 1;
@@ -1566,7 +1647,7 @@ int ObjectRef::l_hud_set_hotbar_selected_image(lua_State *L)
        if (player == NULL)
                return 0;
 
-       std::string name = lua_tostring(L, 2);
+       std::string name = readParam<std::string>(L, 2);
 
        getServer(L)->hudSetHotbarSelectedImage(player, name);
        return 1;
@@ -1606,7 +1687,7 @@ int ObjectRef::l_set_sky(lua_State *L)
                while (lua_next(L, 4) != 0) {
                        // key at index -2 and value at index -1
                        if (lua_isstring(L, -1))
-                               params.emplace_back(lua_tostring(L, -1));
+                               params.emplace_back(readParam<std::string>(L, -1));
                        else
                                params.emplace_back("");
                        // removes value, keeps key for next iteration
@@ -1619,7 +1700,7 @@ int ObjectRef::l_set_sky(lua_State *L)
 
        bool clouds = true;
        if (lua_isboolean(L, 5))
-               clouds = lua_toboolean(L, 5);
+               clouds = readParam<bool>(L, 5);
 
        getServer(L)->setSky(player, bgcolor, type, params, clouds);
        lua_pushboolean(L, true);
@@ -1648,8 +1729,7 @@ int ObjectRef::l_get_sky(lua_State *L)
        s16 i = 1;
        for (const std::string &param : params) {
                lua_pushlstring(L, param.c_str(), param.size());
-               lua_rawseti(L, -2, i);
-               i++;
+               lua_rawseti(L, -2, i++);
        }
        lua_pushboolean(L, clouds);
        return 4;
@@ -1740,7 +1820,7 @@ int ObjectRef::l_override_day_night_ratio(lua_State *L)
        float ratio = 0.0f;
        if (!lua_isnil(L, 2)) {
                do_override = true;
-               ratio = luaL_checknumber(L, 2);
+               ratio = readParam<float>(L, 2);
        }
 
        if (!getServer(L)->overrideDayNightRatio(player, do_override, ratio))
@@ -1815,6 +1895,7 @@ void ObjectRef::Register(lua_State *L)
 
        lua_pop(L, 1);  // drop metatable
 
+       markAliasDeprecated(methods);
        luaL_openlib(L, 0, methods, 0);  // fill methodtable
        lua_pop(L, 1);  // drop methodtable
 
@@ -1823,7 +1904,7 @@ void ObjectRef::Register(lua_State *L)
 }
 
 const char ObjectRef::className[] = "ObjectRef";
-const luaL_Reg ObjectRef::methods[] = {
+luaL_Reg ObjectRef::methods[] = {
        // ServerActiveObject
        luamethod(ObjectRef, remove),
        luamethod_aliased(ObjectRef, get_pos, getpos),
@@ -1860,6 +1941,8 @@ const luaL_Reg ObjectRef::methods[] = {
        luamethod_aliased(ObjectRef, get_acceleration, getacceleration),
        luamethod_aliased(ObjectRef, set_yaw, setyaw),
        luamethod_aliased(ObjectRef, get_yaw, getyaw),
+       luamethod(ObjectRef, set_rotation),
+       luamethod(ObjectRef, get_rotation),
        luamethod_aliased(ObjectRef, set_texture_mod, settexturemod),
        luamethod_aliased(ObjectRef, set_sprite, setsprite),
        luamethod(ObjectRef, get_entity_name),
@@ -1869,6 +1952,7 @@ const luaL_Reg ObjectRef::methods[] = {
        luamethod(ObjectRef, is_player_connected),
        luamethod(ObjectRef, get_player_name),
        luamethod(ObjectRef, get_player_velocity),
+       luamethod(ObjectRef, add_player_velocity),
        luamethod(ObjectRef, get_look_dir),
        luamethod(ObjectRef, get_look_pitch),
        luamethod(ObjectRef, get_look_yaw),
@@ -1882,6 +1966,7 @@ const luaL_Reg ObjectRef::methods[] = {
        luamethod(ObjectRef, set_breath),
        luamethod(ObjectRef, get_attribute),
        luamethod(ObjectRef, set_attribute),
+       luamethod(ObjectRef, get_meta),
        luamethod(ObjectRef, set_inventory_formspec),
        luamethod(ObjectRef, get_inventory_formspec),
        luamethod(ObjectRef, set_formspec_prepend),
@@ -1912,5 +1997,6 @@ const luaL_Reg ObjectRef::methods[] = {
        luamethod(ObjectRef, get_local_animation),
        luamethod(ObjectRef, set_eye_offset),
        luamethod(ObjectRef, get_eye_offset),
+       luamethod(ObjectRef, send_mapblock),
        {0,0}
 };