From 602f175cc043245f3300b1e0eda621e09174de41 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 20 Apr 2024 14:03:37 +0200 Subject: [PATCH] Make use of minetest.load_area --- worldedit/common.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/worldedit/common.lua b/worldedit/common.lua index 2275d13..71b43eb 100644 --- a/worldedit/common.lua +++ b/worldedit/common.lua @@ -47,10 +47,15 @@ end function worldedit.keep_loaded(pos1, pos2) -- Create a vmanip and read the area from map, this - -- causes all MapBlocks to be loaded into memory. + -- causes all MapBlocks to be loaded into memory synchronously. -- This doesn't actually *keep* them loaded, unlike the name implies. - local manip = minetest.get_voxel_manip() - manip:read_from_map(pos1, pos2) + if minetest.load_area then + -- same effect but without unnecessary data copying + minetest.load_area(pos1, pos2) + else + local manip = minetest.get_voxel_manip() + manip:read_from_map(pos1, pos2) + end end