From b839a6dd5425c334e6528ae230f05ca5b15cc3a1 Mon Sep 17 00:00:00 2001 From: sofar Date: Sat, 27 Apr 2019 16:42:13 -0700 Subject: Force send a mapblock to a player (#8140) * Force send a mapblock to a player. Send a single mapblock to a specific remote player. This is badly needed for mods and games where players are teleported into terrain which may be not generated, loaded, or modified significantly since the last player visit. In all these cases, the player currently ends up in void, air, or inside blocks which not only looks bad, but has the effect that the player might end up falling and then the server needs to correct for the player position again later, which is a hack. The best solution is to send at least the single mapblock that the player will be teleported to. I've tested this with ITB which does this all the time, and I can see it functioning as expected (it even shows a half loaded entry hallway, as the further blocks aren't loaded yet). The parameter is a blockpos (table of x, y, z), not a regular pos. The function may return false if the call failed. This is most likely due to the target position not being generated or emerged yet, or another internal failure, such as the player not being initialized. * Always send mapblock on teleport or respawn. This avoids the need for mods to send a mapblock on teleport or respawn, since any call to `player:set_pos()` will pass this code. --- doc/lua_api.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'doc') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index c7035bb72..c75800cf4 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -5382,6 +5382,11 @@ This is basically a reference to a C++ `ServerActiveObject` * in first person view * in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`) * `get_eye_offset()`: returns `offset_first` and `offset_third` +* `send_mapblock(blockpos)`: + * Sends a server-side loaded mapblock to the player. + * Returns `false` if failed. + * Resource intensive - use sparsely + * To get blockpos, integer divide pos by 16 `PcgRandom` ----------- -- cgit v1.2.3