objectref.lua 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. ---@diagnostic disable: unused-local, missing-return
  2. ---@meta
  3. ---ObjectRef
  4. ------------
  5. ---@class mt.ObjectRefProto
  6. local ObjectRef = {}
  7. -- A reference to an entity.
  8. --
  9. -- This is basically a reference to a C++ `ServerActiveObject`.
  10. --
  11. -- **Advice on handling `ObjectRefs`**
  12. --
  13. -- When you receive an `ObjectRef` as a callback argument or from another API
  14. -- function, it is possible to store the reference somewhere and keep it around.
  15. -- It will keep functioning until the object is unloaded or removed.
  16. --
  17. -- However, doing this is **NOT** recommended as there is (intentionally) no method
  18. -- to test if a previously acquired `ObjectRef` is still valid.
  19. -- Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
  20. -- Lua back to the engine.
  21. -- Doing so is much less error-prone and you will never need to wonder if the
  22. -- object you are working with still exists.
  23. ---@alias mt.ObjectRef mt.LuaObjectRef|mt.PlayerObjectRef
  24. ---@return mt.Vector|nil
  25. function ObjectRef:get_pos() end
  26. ---@param pos mt.Vector
  27. function ObjectRef:set_pos(pos) end
  28. ---@return mt.Vector|nil
  29. function ObjectRef:get_velocity() end
  30. ---* In comparison to using get_velocity, adding the velocity and then using
  31. --- set_velocity, add_velocity is supposed to avoid synchronization problems.
  32. --- Additionally, players also do not support set_velocity.
  33. ---* If a player:
  34. --- * Does not apply during free_move.
  35. --- * Note that since the player speed is normalized at each move step,
  36. --- increasing e.g. Y velocity beyond what would usually be achieved
  37. --- (see: physics overrides) will cause existing X/Z velocity to be reduced.
  38. --- * Example: `add_velocity({x=0, y=6.5, z=0})` is equivalent to
  39. --- pressing the jump key (assuming default settings)
  40. ---@param vel mt.Vector
  41. function ObjectRef:add_velocity(vel) end
  42. ---* Does an interpolated move for Lua entities for visually smooth transitions.
  43. ---* If `continuous` is true, the Lua entity will not be moved to the current
  44. --- position before starting the interpolated move.
  45. ---* For players this does the same as `set_pos`,`continuous` is ignored.
  46. ---@param pos mt.Vector
  47. ---@param continuous boolean|nil Default: `false`.
  48. function ObjectRef:move_to(pos, continuous) end
  49. --[[
  50. If `direction` equals `nil` and `puncher` does not equal `nil`, `direction`
  51. will be automatically filled in based on the location of `puncher`.
  52. ]]
  53. ---@param puncher mt.ObjectRef
  54. ---@param time_from_last_punch number|nil Time since last punch action.
  55. ---@param tool_capabilities mt.ToolCaps|nil
  56. ---@param direction mt.Vector|nil
  57. ---@return number tool_wear
  58. function ObjectRef:punch(
  59. puncher,
  60. time_from_last_punch,
  61. tool_capabilities,
  62. direction
  63. )
  64. end
  65. ---@param clicker mt.ObjectRef
  66. function ObjectRef:right_click(clicker) end
  67. ---Returns number of health points.
  68. ---@return number|nil
  69. function ObjectRef:get_hp() end
  70. ---* Set number of health points.
  71. ---* Is limited to the range of 0 ... 65535 (2^16 - 1).
  72. ---* For players: HP are also limited by `hp_max` specified in object properties.
  73. ---@param hp number
  74. ---@param reason string|nil See in register_on_player_hpchange
  75. function ObjectRef:set_hp(hp, reason) end
  76. ---Returns an `InvRef` for players, otherwise returns `nil`.
  77. ---@return mt.InvRef|nil
  78. function ObjectRef:get_inventory() end
  79. ---Returns the name of the inventory list the wielded item is in.
  80. ---@return string|nil
  81. function ObjectRef:get_wield_list() end
  82. ---Returns the index of the wielded item.
  83. ---@return number|nil
  84. function ObjectRef:get_wield_index() end
  85. ---@return mt.ItemStack|nil
  86. function ObjectRef:get_wielded_item() end
  87. ---Replaces the wielded item, returns `true` if successful.
  88. ---@param item mt.Item
  89. ---@return boolean true If successful.
  90. function ObjectRef:set_wielded_item(item) end
  91. ---@param group_table table {group1=rating, group2=rating, ...}
  92. function ObjectRef:set_armor_groups(group_table) end
  93. ---Returns a table with the armor group ratings.
  94. ---@return table {group1=rating, group2=rating, ...}|nil
  95. function ObjectRef:get_armor_groups() end
  96. ---@param frame_range { x: number, y: number }|nil `{x=1, y=1}`
  97. ---@param frame_speed number|nil Default: `15.0`.
  98. ---@param frame_blend number|nil Default: `0.0`.
  99. ---@param frame_loop boolean|nil Default: `true`.
  100. function ObjectRef:set_animation(
  101. frame_range,
  102. frame_speed,
  103. frame_blend,
  104. frame_loop
  105. )
  106. end
  107. ---@return { x: number, y: number}|nil range
  108. ---@return number|nil frame_speed
  109. ---@return number|nil frame_blend
  110. ---@return boolean|nil frame_loop
  111. function ObjectRef:get_animation() end
  112. ---@param frame_speed number|nil Default: `15.0`.
  113. function ObjectRef:set_animation_frame_speed(frame_speed) end
  114. ---@param parent mt.ObjectRef
  115. ---@param bone string|nil Default: `""`. The root bone.
  116. ---@param position mt.Vector|nil Default: `{x=0, y=0, z=0}`. Relative position.
  117. ---@param rotation mt.Vector|nil Default: `{x=0, y=0, z=0}`. Relative rotation in degrees.
  118. ---@param forced_visible boolean|nil Default: `false`. Should appear in first person?
  119. function ObjectRef:set_attach(
  120. parent,
  121. bone,
  122. position,
  123. rotation,
  124. forced_visible
  125. )
  126. end
  127. ---* This command may fail silently (do nothing) when it would result
  128. --- in circular attachments.
  129. ---* Returns parent, bone, position, rotation, forced_visible,
  130. --- or nil if it isn't attached.
  131. ---@return mt.ObjectRef|nil parent
  132. ---@return string|nil bone The root bone.
  133. ---@return mt.Vector|nil position Relative position.
  134. ---@return mt.Vector|nil rotation Relative rotation in degrees.
  135. ---@return boolean|nil forced_visible Should appear in first person?
  136. function ObjectRef:get_attach() end
  137. ---Returns a list of ObjectRefs that are attached to the object.
  138. ---@return mt.ObjectRef[]|nil
  139. function ObjectRef:get_children() end
  140. function ObjectRef:set_detach() end
  141. ---@param bone string|nil Default: `""`. The root bone.
  142. ---@param position mt.Vector|nil Default: `{x=0, y=0, z=0}`. Relative position.
  143. ---@param rotation mt.Vector|nil Default: `{x=0, y=0, z=0}`.
  144. function ObjectRef:set_bone_position(bone, position, rotation) end
  145. ---Returns position and rotation of the bone.
  146. ---@param bone string
  147. ---@return mt.Vector|nil position, mt.Vector|nil rotation
  148. function ObjectRef:get_bone_position(bone) end
  149. ---@param property_table table
  150. function ObjectRef:set_properties(property_table) end
  151. ---@return table|nil
  152. function ObjectRef:get_properties() end
  153. ---@return boolean
  154. function ObjectRef:is_player() end
  155. ---@class mt.NameTagAttributes
  156. ---@field text string|nil
  157. ---@field color mt.ColorSpec|nil
  158. ---@field bgcolor mt.ColorSpec|nil
  159. ---Returns a table with the attributes of the nametag of an object.
  160. ---@return mt.NameTagAttributes|nil
  161. function ObjectRef:get_nametag_attributes() end
  162. ---Sets the attributes of the nametag of an object.
  163. ---@param attrs mt.NameTagAttributes
  164. function ObjectRef:set_nametag_attributes(attrs) end
  165. ---Lua entity only (no-op for other objects).
  166. ---@class mt.LuaObjectRef : mt.ObjectRefProto
  167. local LuaObjectRef = {}
  168. ---* Remove object.
  169. ---* The object is removed after returning from Lua. However the `ObjectRef`
  170. --- itself instantly becomes unusable with all further method calls having
  171. --- no effect and returning `nil`.
  172. function LuaObjectRef:remove() end
  173. ---@param vel mt.Vector
  174. function LuaObjectRef:set_velocity(vel) end
  175. ---@param acc mt.Vector
  176. function LuaObjectRef:set_acceleration(acc) end
  177. ---@return mt.Vector
  178. function LuaObjectRef:get_acceleration() end
  179. ---* X is pitch (elevation), Y is yaw (heading) and Z is roll (bank).
  180. ---* Does not reset rotation incurred through `automatic_rotate`.
  181. ---* Remove & read your objects to force a certain rotation.
  182. ---@param rot mt.Vector (radians)
  183. function LuaObjectRef:set_rotation(rot) end
  184. ---@return mt.Vector (radians)
  185. function LuaObjectRef:get_rotation() end
  186. ---Sets the yaw in radians (heading).
  187. ---@param yaw number
  188. function LuaObjectRef:set_yaw(yaw) end
  189. ---Returns number in radians.
  190. ---@return number
  191. function LuaObjectRef:get_yaw() end
  192. ---* Set a texture modifier to the base texture, for sprites and meshes.
  193. ---* When calling `set_texture_mod` again, the previous one is discarded.
  194. ---@param mod string Texture modifier.
  195. function LuaObjectRef:set_texture_mod(mod) end
  196. ---Returns current texture modifier.
  197. ---@return string mod Texture modifier.
  198. function LuaObjectRef:get_texture_mod() end
  199. ---* Specifies and starts a sprite animation.
  200. ---* Animations iterate along the frame `y` position.
  201. --- * First column: subject facing the camera
  202. --- * Second column: subject looking to the left
  203. --- * Third column: subject backing the camera
  204. --- * Fourth column: subject looking to the right
  205. --- * Fifth column: subject viewed from above
  206. --- * Sixth column: subject viewed from below
  207. ---@param start_frame {x: number, y: number}|nil Default: `{x=0, y=0}`. The coordinate of the first frame.
  208. ---@param num_frames number|nil Default: `1`. Total frames in the texture.
  209. ---@param framelength number|nil Default: `0.2`. Time per animated frame in seconds.
  210. ---@param select_x_by_camera boolean|nil Default: `false`. Only for visual = `sprite`. Changes the frame `x` position according to the view direction.
  211. function LuaObjectRef:set_sprite(
  212. start_frame,
  213. num_frames,
  214. framelength,
  215. select_x_by_camera
  216. )
  217. end
  218. ---**Deprecated**: Use the field `self.name` instead.
  219. ---@deprecated
  220. function LuaObjectRef:get_entity_name() end
  221. ---@return any
  222. function LuaObjectRef:get_luaentity() end
  223. ---Player only (no-op for other objects).
  224. ---@class mt.PlayerObjectRef : mt.ObjectRefProto
  225. local PlayerObjectRef = {}
  226. ---@return string name `""` if is not a player.
  227. function PlayerObjectRef:get_player_name() end
  228. ---**DEPRECATED**, use get_velocity() instead.
  229. ---@deprecated
  230. ---@return mt.Vector|nil
  231. function PlayerObjectRef:get_player_velocity() end
  232. ---**DEPRECATED**, use add_velocity(vel) instead.
  233. ---@deprecated
  234. ---@param vel mt.Vector|nil
  235. function PlayerObjectRef:add_player_velocity(vel) end
  236. ---Get camera direction as a unit vector.
  237. ---@return mt.Vector|nil
  238. function PlayerObjectRef:get_look_dir() end
  239. ---* Pitch in radians.
  240. ---* Angle ranges between -pi/2 and pi/2, which are straight up and down
  241. --- respectively.
  242. ---@return number|nil
  243. function PlayerObjectRef:get_look_vertical() end
  244. ---* Yaw in radians.
  245. ---* Angle is counter-clockwise from the +z direction.
  246. ---@return number|nil
  247. function PlayerObjectRef:get_look_horizontal() end
  248. ---Sets look pitch.
  249. ---@param radians number Angle from looking forward, where positive is downwards.
  250. function PlayerObjectRef:set_look_vertical(radians) end
  251. ---Sets look yaw.
  252. ---@param radians number Angle from the +z direction, where positive is counter-clockwise.
  253. function PlayerObjectRef:set_look_horizontal(radians) end
  254. ---* Pitch in radians - **Deprecated** as broken. Use `get_look_vertical`.
  255. ---* Angle ranges between -pi/2 and pi/2, which are straight down and up
  256. --- respectively.
  257. ---@deprecated
  258. ---@return number|nil
  259. function PlayerObjectRef:get_look_pitch() end
  260. ---* Yaw in radians - **Deprecated** as broken. Use `get_look_horizontal`.
  261. ---* Angle is counter-clockwise from the +x direction.
  262. ---@deprecated
  263. ---@return number|nil
  264. function PlayerObjectRef:get_look_yaw() end
  265. ---Sets look pitch - **Deprecated**. Use `set_look_vertical`.
  266. ---@deprecated
  267. ---@param radians number Angle from looking forward, where positive is downwards.
  268. function PlayerObjectRef:set_look_pitch(radians) end
  269. ---Sets look yaw - **Deprecated**. Use `set_look_horizontal`.
  270. ---@deprecated
  271. ---@param radians number
  272. function PlayerObjectRef:set_look_yaw(radians) end
  273. ---Returns player's breath.
  274. ---@return number|nil
  275. function PlayerObjectRef:get_breath() end
  276. ---* Sets player's breath
  277. ---* values:
  278. --- * `0`: player is drowning
  279. --- * max: bubbles bar is not shown
  280. --- * See [Object properties] for more information
  281. ---* Is limited to range 0 ... 65535 (2^16 - 1)
  282. ---@param value number
  283. function PlayerObjectRef:set_breath(value) end
  284. ---* Sets player's FOV.
  285. ---* Set `fov` to 0 to clear FOV override.
  286. ---@param fov number FOV value
  287. ---@param is_multiplier boolean|nil Default: `false`. Set to `true` if the FOV value is a multiplier.
  288. ---@param transition_time number|nil Default: `0`. If defined, enables smooth FOV transition. Interpreted as the time (in seconds) to reach target FOV. If set to 0, FOV change is instantaneous.
  289. function PlayerObjectRef:set_fov(fov, is_multiplier, transition_time) end
  290. ---@return number|nil fov Server-sent FOV value. Returns 0 if an FOV override doesn't exist.
  291. ---@return boolean|nil is_multiplier Indicating whether the FOV value is a multiplier.
  292. ---@return number|nil transition_time (in seconds) taken for the FOV transition. Set by `set_fov`.
  293. function PlayerObjectRef:get_fov() end
  294. ---**DEPRECATED**, use set_meta() instead.
  295. ---@deprecated
  296. ---@param attribute string
  297. ---@param value string|number|nil
  298. function PlayerObjectRef:set_attribute(attribute, value) end
  299. ---**DEPRECATED**, use set_meta() instead.
  300. ---@deprecated
  301. ---@param attribute string
  302. ---@return string|nil value
  303. function PlayerObjectRef:get_attribute(attribute) end
  304. ---@return mt.PlayerMetaRef|nil
  305. function PlayerObjectRef:get_meta() end
  306. ---* Redefine player's inventory form.
  307. ---* Should usually be called in `on_joinplayer`
  308. ---* If `formspec` is `""`, the player's inventory is disabled.
  309. --- @param formspec string
  310. function PlayerObjectRef:set_inventory_formspec(formspec) end
  311. ---Returns a formspec string.
  312. --- @return string|nil
  313. function PlayerObjectRef:get_inventory_formspec() end
  314. ---* The formspec string will be added to every formspec shown to the user,
  315. --- except for those with a no_prepend[] tag.
  316. ---* This should be used to set style elements such as background[] and
  317. --- bgcolor[], any non-style elements (eg: label) may result in weird behavior.
  318. ---* Only affects formspecs shown after this is called.
  319. ---@param formspec string
  320. function PlayerObjectRef:set_formspec_prepend(formspec) end
  321. ---Returns a formspec string.
  322. ---@return string formspec|nil
  323. function PlayerObjectRef:get_formspec_prepend() end
  324. ---* Returns table with player pressed keys.
  325. ---* The table consists of fields with the following boolean values
  326. --- representing the pressed keys: `up`, `down`, `left`, `right`, `jump`,
  327. --- `aux1`, `sneak`, `dig`, `place`, `LMB`, `RMB`, and `zoom`.
  328. ---* The fields `LMB` and `RMB` are equal to `dig` and `place` respectively,
  329. --- and exist only to preserve backwards compatibility.
  330. ---* Returns an empty table `{}` if the object is not a player.
  331. ---@return { up: boolean|nil, down: boolean|nil, left: boolean|nil, right: boolean|nil, jump: boolean|nil, aux1: boolean|nil, sneak: boolean|nil, dig: boolean|nil, place: boolean|nil, LMB: boolean|nil, RMB: boolean|nil, zoom: boolean|nil }|nil
  332. function PlayerObjectRef:get_player_control() end
  333. ---* Returns integer with bit packed player pressed keys.
  334. ---* Bits:
  335. --- * 0 - up
  336. --- * 1 - down
  337. --- * 2 - left
  338. --- * 3 - right
  339. --- * 4 - jump
  340. --- * 5 - aux1
  341. --- * 6 - sneak
  342. --- * 7 - dig
  343. --- * 8 - place
  344. --- * 9 - zoom
  345. ---* Returns `0` (no bits set) if the object is not a player.
  346. ---@return number|nil
  347. function PlayerObjectRef:get_player_control_bits() end
  348. ---@class mt.PhysicsOverride
  349. ---@field speed number|nil Default: `1`. Multiplier to default walking speed value.
  350. ---@field jump number|nil Default: `1`. Multiplier to default jump value.
  351. ---@field gravity number|nil Default: `1`. Multiplier to default gravity value.
  352. ---@field sneak boolean|nil Default: `true`. Whether player can sneak.
  353. ---@field sneak_glitch boolean|nil Default: `false`. Whether player can use the new move code replications of the old sneak side-effects: sneak ladders and 2 node sneak jump.
  354. ---@field new_move boolean|nil Default: `true`. Use new move/sneak code. When false the exact old code is used for the specific old sneak behavior.
  355. --- @param override_table mt.PhysicsOverride
  356. function PlayerObjectRef:set_physics_override(override_table) end
  357. ---Returns the table given to `set_physics_override`.
  358. ---@return mt.PhysicsOverride|nil
  359. function PlayerObjectRef:get_physics_override() end
  360. ---Add a HUD element described by HUD def, returns ID number on success.
  361. ---@param definition mt.HUDDef
  362. ---@return number id On success.
  363. function PlayerObjectRef:hud_add(definition) end
  364. ---Remove the HUD element of the specified id.
  365. ---@param id number
  366. function PlayerObjectRef:hud_remove(id) end
  367. ---* Change a value of a previously added HUD element.
  368. ---* `stat` supports the same keys as in the hud definition table except for
  369. --- `"hud_elem_type"`.
  370. ---@param id number
  371. ---@param stat '"position"'|'"name"'|'"scale"'|'"text"'|'"number"'|'"item"'|'"dir"'
  372. ---@param value any
  373. function PlayerObjectRef:hud_change(id, stat, value) end
  374. ---Gets the HUD element definition structure of the specified ID.
  375. ---@param id number
  376. ---@return mt.HUDElement
  377. function PlayerObjectRef:hud_get(id) end
  378. ---@class mt.HUDFlags
  379. ---@field hotbar boolean|nil
  380. ---@field healthbar boolean|nil
  381. ---@field crosshair boolean|nil
  382. ---@field wielditem boolean|nil
  383. ---@field breathbar boolean|nil
  384. ---@field minimap boolean|nil The client may locally elect to not view the minimap.
  385. ---@field minimap_radar boolean|nil Is only usable when `minimap` is true.
  386. ---Allow showing basic debug info that might give a gameplay advantage.
  387. ---This includes map seed, player position, look direction, the pointed node
  388. ---and block bounds. Does not affect players with the `debug` privilege.
  389. ---@field basic_debug boolean|nil
  390. ---Sets specified HUD flags of player.
  391. ---@param flags mt.HUDFlags If a flag equals `nil`, the flag is not modified.
  392. function PlayerObjectRef:hud_set_flags(flags) end
  393. ---`hud_get_flags()`: returns a table of player HUD flags with boolean values.
  394. ---@return mt.HUDFlags
  395. function PlayerObjectRef:hud_get_flags() end
  396. ---Sets number of items in builtin hotbar.
  397. ---@param count number Must be between `1` and `32`.
  398. function PlayerObjectRef:hud_set_hotbar_itemcount(count) end
  399. ---Returns number of visible items.
  400. ---@return number
  401. function PlayerObjectRef:hud_get_hotbar_itemcount() end
  402. ---Sets background image for hotbar.
  403. ---@param texturename string
  404. function PlayerObjectRef:hud_set_hotbar_image(texturename) end
  405. ---Returns texturename.
  406. ---@return string
  407. function PlayerObjectRef:hud_get_hotbar_image() end
  408. ---Sets image for selected item of hotbar.
  409. ---@param texturename string
  410. function PlayerObjectRef:hud_set_hotbar_selected_image(texturename) end
  411. ---Returns texturename
  412. ---@return string
  413. function PlayerObjectRef:hud_get_hotbar_selected_image() end
  414. ---@class mt.MiniMapMode
  415. ---@field type '"off"'|'"surface"'|'"radar"'|'"texture"'|nil
  416. ---@field label string|nil
  417. ---@field size number|nil Side length or diameter in nodes.
  418. ---@field texture string|nil Name of the texture.
  419. ---@field scale number|nil Only for texture type.
  420. ---Overrides the available minimap modes (and toggle order), and changes the
  421. ---selected mode.
  422. ---@param modes mt.MiniMapMode[]
  423. ---@param selected_mode number Mode index to be selected after change (starting at 0).
  424. function PlayerObjectRef:set_minimap_modes(modes, selected_mode) end
  425. ---* The presence of the function `set_sun`, `set_moon` or `set_stars` indicates
  426. --- whether `set_sky` accepts this format. Check the legacy format otherwise.
  427. ---* Passing no arguments resets the sky to its default values.
  428. ---@param sky_parameters mt.SkyParameters|nil
  429. ---@overload fun(base_color: mt.ColorSpec|nil, type:string|nil, textures:table|nil, clouds:boolean|nil) **Deprecated**.
  430. function PlayerObjectRef:set_sky(sky_parameters) end
  431. ---A table used in regular sky_parameters type only (alpha is ignored)
  432. ---@class mt.SkyColor
  433. ---Default: `#61b5f5`. For the top half of the sky during the day.
  434. ---@field day_sky mt.ColorSpec|nil
  435. ---Default: `#90d3f6`. For the bottom half of the sky during the day.
  436. ---@field day_horizon mt.ColorSpec|nil
  437. ---Default: `#b4bafa`. For the top half of the sky during dawn/sunset.
  438. ---@field dawn_sky mt.ColorSpec|nil
  439. ---Default: `#bac1f0`. For the bottom half of the sky during dawn/sunset.
  440. ---@field dawn_horizon mt.ColorSpec|nil
  441. ---Default: `#006bff`. For the top half of the sky during the night.
  442. ---@field night_sky mt.ColorSpec|nil
  443. ---Default: `#4090ff`. For the bottom half of the sky during the night.
  444. ---@field night_horizon mt.ColorSpec|nil
  445. ---Default: `#646464`. For when you're either indoors or underground.
  446. ---@field indoors mt.ColorSpec|nil
  447. ---Default: `#f47d1d`. Changes the fog tinting for the sun at sunrise and sunset.
  448. ---@field fog_sun_tint mt.ColorSpec|nil
  449. ---Default: `#7f99cc`. Changes the fog tinting for the moon at sunrise and sunset.
  450. ---@field fog_moon_tint mt.ColorSpec|nil
  451. ---Default: `"default"`. Changes which mode the directional fog.
  452. ---@field fog_tint_type `"custom"`|`"default"`|nil
  453. ---@class mt.SkyParameters
  454. ---Changes fog in "skybox" and "plain".
  455. ---@field base_color mt.ColorSpec|nil Default: `#ffffff`.
  456. ---`"regular"` Uses `0 | 6 | 0` textures, `base_color`
  457. ---`ignored | used as fog | used as both fog and sky`.
  458. ---@field type `"regular"`|`"skybox"`|`"plain"`|nil
  459. ---A table containing up to six textures in the following order: Y+ (top),
  460. ---Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
  461. ---@field textures table|nil
  462. ---@field clouds boolean|nil `true` Boolean for whether clouds appear.
  463. ---@field sky_color mt.SkyColor
  464. ---* `as_table`: boolean that determines whether the deprecated version of this
  465. --- function is being used.
  466. --- * `true` returns a table containing sky parameters as defined in `set_sky(sky_parameters)`.
  467. --- * Deprecated: `false` or `nil` returns base_color, type, table of textures,
  468. --- clouds.
  469. ---@param as_table boolean|nil
  470. ---@return mt.ColorSpec|mt.SkyParameters, string|nil, string[]|nil, boolean|nil
  471. function PlayerObjectRef:get_sky(as_table) end
  472. ---* Deprecated: Use `get_sky(as_table)` instead.
  473. ---* Returns a table with the `sky_color` parameters as in `set_sky`.
  474. ---@deprecated
  475. ---@return mt.SkyColor
  476. function get_sky_color() end
  477. ---@class mt.SunParameters
  478. ---@field visible boolean|nil Default: `true`. Whether the sun is visible.
  479. ---@field texture string|nil Default: `"sun.png"`. A regular texture for the sun. Setting to `""` will re-enable the mesh sun. The texture appears non-rotated at sunrise and rotated 180 degrees (upside down) at sunset.
  480. ---@field tonemap string|nil Default: `"sun_tonemap.png"`. A 512x1 texture containing the tonemap for the sun
  481. ---@field sunrise string|nil Default: `"sunrisebg.png"`. A regular texture for the sunrise texture.
  482. ---@field sunrise_visible boolean|nil Default: `true`. Boolean for whether the sunrise texture is visible.
  483. ---@field scale number|nil Default: `1`. Overall size of the sun. For legacy reasons, the sun is bigger than the moon by a factor of about `1.57` for equal `scale` values.
  484. ---Passing no arguments resets the sun to its default values.
  485. ---@param sun_parameters mt.SunParameters|nil
  486. function PlayerObjectRef:set_sun(sun_parameters) end
  487. ---Returns a table with the current sun parameters as in `set_sun`.
  488. ---@return mt.SunParameters|nil
  489. function PlayerObjectRef:get_sun() end
  490. ---@class mt.MoonParameters
  491. ---@field visible boolean|nil Default: `true`. Whether the moon is visible.
  492. ---@field texture string|nil Default: `"moon.png"`. A regular texture for the moon. Setting to `""` will re-enable the mesh moon. The texture appears non-rotated at sunrise / moonset and rotated 180 degrees (upside down) at sunset / moonrise. Note: Relative to the sun, the moon texture is hence rotated by 180°. You can use the `^[transformR180` texture modifier to achieve the same orientation.
  493. ---@field tonemap string|nil Default: `"moon_tonemap.png"`. A 512x1 texture containing the tonemap for the moon.
  494. ---@field scale number|nil Default: `1`. Controlling the overall size of the moon. Note: For legacy reasons, the sun is bigger than the moon by a factor of about `1.57` for equal `scale` values.
  495. ---Passing no arguments resets the moon to its default values.
  496. ---@param moon_parameters mt.MoonParameters
  497. function PlayerObjectRef:set_moon(moon_parameters) end
  498. ---Returns a table with the current moon parameters as in `set_moon`.
  499. ---@return mt.MoonParameters|nil
  500. function PlayerObjectRef:get_moon() end
  501. ---@class mt.StarParameters
  502. ---@field visible boolean|nil Default: `true`. Whether the stars are visible.
  503. ---@field day_opacity number|nil Default: `0.0`. Maximum opacity of stars at day (maximum: 1.0; minimum: 0.0). No effect if `visible` is false.
  504. ---@field count integer|nil Default: `1000`. Set the number of stars in the skybox. Only applies to `"skybox"` and `"regular"` sky types.
  505. ---@field star_color mt.ColorSpec|nil Default: `#ebebff69`. Sets the colors of the stars, alpha channel is used to set overall star brightness.
  506. ---@field scale number|nil Default: `1`. Controlling the overall size of the stars.
  507. ---Passing no arguments resets stars to their default values.
  508. ---@param star_parameters mt.StarParameters
  509. function PlayerObjectRef:set_stars(star_parameters) end
  510. ---Returns a table with the current stars parameters as in `set_stars`.
  511. ---@return mt.StarParameters|nil
  512. function PlayerObjectRef:get_stars() end
  513. ---@class mt.CloudParameters
  514. ---@field density number|nil Default: `0.4`. From `0` (no clouds) to `1` (full clouds).
  515. ---@field color mt.ColorSpec|nil Default: `#fff0f0e5`. Basic cloud color with alpha channel.
  516. ---@field ambient mt.ColorSpec|nil Default: `#000000`. Cloud color lower bound, use for a "glow at night" effect (alpha ignored).
  517. ---@field height number|nil Default: `120`. Cloud height, i.e. y of cloud base.
  518. ---@field thickness number|nil Default: `16`. Cloud thickness in nodes.
  519. ---@field speed {x:number, z:number}|nil Default: `{x=0, z=-2}`.
  520. ---Passing no arguments resets clouds to their default values.
  521. ---@param cloud_parameters mt.CloudParameters
  522. function PlayerObjectRef:set_clouds(cloud_parameters) end
  523. ---Returns a table with the current cloud parameters as in `set_clouds`.
  524. ---@return mt.CloudParameters|nil
  525. function PlayerObjectRef:get_clouds() end
  526. ---* Overrides day-night ratio, controlling sunlight to a specific amount.
  527. ---* `nil`: Disables override, defaulting to sunlight based on day-night cycle.
  528. ---@param ratio number|nil Ratio from 0 to 1.
  529. function PlayerObjectRef:override_day_night_ratio(ratio) end
  530. ---@return number|nil ratio Ratio from 0 to 1, or `nil` if not overridden.
  531. function PlayerObjectRef:get_day_night_ratio() end
  532. ---* Set animation for player model in third person view.
  533. ---* Every animation equals to a `{x=starting frame, y=ending frame}`.
  534. ---@param idle {x:number, y:number}|nil
  535. ---@param walk {x:number, y:number}|nil
  536. ---@param dig {x:number, y:number}|nil
  537. ---@param walk_while_dig {x:number, y:number}|nil
  538. ---@param frame_speed number|nil Default: `30`.
  539. function PlayerObjectRef:set_local_animation(
  540. idle,
  541. walk,
  542. dig,
  543. walk_while_dig,
  544. frame_speed
  545. )
  546. end
  547. ---Returns idle, walk, dig, walk_while_dig tables and `frame_speed`.
  548. ---@return {x:number, y:number}|nil idle
  549. ---@return {x:number, y:number}|nil walk
  550. ---@return {x:number, y:number}|nil dig
  551. ---@return {x:number, y:number}|nil walk_while_dig
  552. ---@return number|nil frame_speed
  553. function PlayerObjectRef:get_local_animation() end
  554. ---* Defines offset vectors for camera per player.
  555. ---* in third person view max values are `{x=-10/10, y=-10,15, z=-5/5}`
  556. ---@param firstperson? mt.Vector|nil Default: `{x=0, y=0, z=0}`.
  557. ---@param thirdperson? mt.Vector|nil Default: `{x=0, y=0, z=0}`.
  558. function PlayerObjectRef:set_eye_offset(firstperson, thirdperson) end
  559. ---Returns first and third person offsets.
  560. ---@return mt.Vector|nil, mt.Vector|nil
  561. function get_eye_offset() end
  562. ---* Sends an already loaded mapblock to the player.
  563. ---* Returns `false` if nothing was sent (note that this can also mean that
  564. --- the client already has the block)
  565. ---* Resource intensive - use sparsely
  566. ---@param blockpos mt.Vector
  567. ---@return unknown|boolean result False if failed.
  568. function PlayerObjectRef:send_mapblock(blockpos) end
  569. ---@class mt.Light
  570. ---@field saturation number|nil This value has no effect on clients who have the "Tone Mapping" shader disabled.
  571. ---@field shadows {intensity: number|nil}|nil This value has no effect on clients who have the "Dynamic Shadows" shader disabled.
  572. ---Sets lighting for the player.
  573. ---@param light_definition mt.Light
  574. function PlayerObjectRef:set_lighting(light_definition) end
  575. ---Returns the current state of lighting for the player.
  576. ---@return mt.Light|nil
  577. function PlayerObjectRef:get_lighting() end
  578. ---Respawns the player using the same mechanism as the death screen,
  579. ---including calling on_respawnplayer callbacks.
  580. function PlayerObjectRef:respawn() end
  581. ---@return mt.InvRef
  582. function PlayerObjectRef:get_inventory() end