Exemple #1
0
        public void PushMinecraftBlocksDataBlockFlags(RealStatePtr L, Minecraft.BlocksData.BlockFlags val)
        {
            if (MinecraftBlocksDataBlockFlags_TypeID == -1)
            {
                bool is_first;
                MinecraftBlocksDataBlockFlags_TypeID = getTypeId(L, typeof(Minecraft.BlocksData.BlockFlags), out is_first);

                if (MinecraftBlocksDataBlockFlags_EnumRef == -1)
                {
                    Utils.LoadCSTable(L, typeof(Minecraft.BlocksData.BlockFlags));
                    MinecraftBlocksDataBlockFlags_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
                }
            }

            if (LuaAPI.xlua_tryget_cachedud(L, (int)val, MinecraftBlocksDataBlockFlags_EnumRef) == 1)
            {
                return;
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, MinecraftBlocksDataBlockFlags_TypeID);

            if (!CopyByValue.Pack(buff, 0, (int)val))
            {
                throw new Exception("pack fail fail for Minecraft.BlocksData.BlockFlags ,value=" + val);
            }

            LuaAPI.lua_getref(L, MinecraftBlocksDataBlockFlags_EnumRef);
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.xlua_rawseti(L, -2, (int)val);
            LuaAPI.lua_pop(L, 1);
        }
Exemple #2
0
        public void UpdateMinecraftBlocksDataBlockFlags(RealStatePtr L, int index, Minecraft.BlocksData.BlockFlags val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != MinecraftBlocksDataBlockFlags_TypeID)
                {
                    throw new Exception("invalid userdata for Minecraft.BlocksData.BlockFlags");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!CopyByValue.Pack(buff, 0, (int)val))
                {
                    throw new Exception("pack fail for Minecraft.BlocksData.BlockFlags ,value=" + val);
                }
            }

            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
Exemple #3
0
        public void Get(RealStatePtr L, int index, out Minecraft.BlocksData.BlockFlags val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

            if (type == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != MinecraftBlocksDataBlockFlags_TypeID)
                {
                    throw new Exception("invalid userdata for Minecraft.BlocksData.BlockFlags");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                int    e;
                if (!CopyByValue.UnPack(buff, 0, out e))
                {
                    throw new Exception("unpack fail for Minecraft.BlocksData.BlockFlags");
                }
                val = (Minecraft.BlocksData.BlockFlags)e;
            }
            else
            {
                val = (Minecraft.BlocksData.BlockFlags)objectCasters.GetCaster(typeof(Minecraft.BlocksData.BlockFlags))(L, index, null);
            }
        }