diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 6c63c21ab..aedff5ef8 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -405,3 +405,53 @@ function mcl_util.get_object_center(obj) pos.y = pos.y + (ymax - ymin) / 2.0 return pos end + +local get_node_emerge_queue = {} +local function ecb_get_far_node(blockpos, action, calls_remaining, param) + if calls_remaining <= 0 and param then + minetest.log("verbose","[mcl_util] ecb done for param = "..param.." node.name="..minetest.get_node(minetest.string_to_pos(param)).name) + get_node_emerge_queue[param] = nil + end +end + +function mcl_util.get_far_node(pos, force) + local node = minetest.get_node(pos) + if node.name ~= "ignore" then + return node + end + + minetest.get_voxel_manip():read_from_map(pos, pos) + node = minetest.get_node(pos) + if node.name ~= "ignore" or not force then + return node + end + + local blockpos = vector.multiply(vector.floor(vector.divide(pos, mcl_vars.MAP_BLOCKSIZE)), mcl_vars.MAP_BLOCKSIZE) + local key = minetest.pos_to_string(blockpos) + + for i=1,2 do -- give engine 2 chances to emerge the data + if not get_node_emerge_queue[key] then + get_node_emerge_queue[key] = 1 + minetest.log("verbose","[mcl_util] emerge during get_far_node("..minetest.pos_to_string(pos).."), key="..key..", blockpos="..minetest.pos_to_string(blockpos)) + minetest.emerge_area(blockpos, vector.add(blockpos, mcl_vars.MAP_BLOCKSIZE-1), ecb_get_far_node, key) + end + + while not get_node_emerge_queue[key] do end + minetest.log("verbose","[mcl_util] emerge finished for node "..minetest.pos_to_string(pos)..", key="..key..", blockpos="..minetest.pos_to_string(blockpos)..", node.name="..mcl_util.get_far_node(pos).name) + + node = minetest.get_node(pos) + if node.name ~= "ignore" then + return node + end + + minetest.get_voxel_manip():read_from_map(pos, pos) + node = minetest.get_node(pos) + if node.name ~= "ignore" or not force then + return node + end + end + + node.name = "air" -- engine continuously returns "ignore" - probably it is a bug + minetest.swap_node(pos, node) -- engine continuously returns "ignore" - probably it is a bug + return node -- engine continuously returns "ignore" - probably it is a bug +end diff --git a/mods/ENTITIES/mcl_paintings/init.lua b/mods/ENTITIES/mcl_paintings/init.lua index 25811d87d..6a3ccab4d 100644 --- a/mods/ENTITIES/mcl_paintings/init.lua +++ b/mods/ENTITIES/mcl_paintings/init.lua @@ -143,6 +143,7 @@ minetest.register_entity("mcl_paintings:painting", { _xsize = 1, _ysize = 1, on_activate = function(self, staticdata) + self.object:set_armor_groups({immortal = 1}) if staticdata and staticdata ~= "" then local data = minetest.deserialize(staticdata) if data then @@ -165,18 +166,20 @@ minetest.register_entity("mcl_paintings:painting", { } return minetest.serialize(data) end, - on_death = function(self, killer) - -- Drop as item on death - local kname = "" - if killer and killer:is_player() then - kname = killer:get_player_name() - end - if not minetest.is_creative_enabled(kname) then + on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) + -- Drop as item on punch + if puncher and puncher:is_player() then + kname = puncher:get_player_name() local pos = self._pos if not pos then pos = self.object:get_pos() end - minetest.add_item(pos, "mcl_paintings:painting") + if not minetest.is_protected(pos, kname) then + self.object:remove() + if not minetest.is_creative_enabled(kname) then + minetest.add_item(pos, "mcl_paintings:painting") + end + end end end, }) diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d b/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d index 0852c4cb1..05ab1907f 100644 Binary files a/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d and b/mods/ITEMS/mcl_armor/models/mcl_armor_character.b3d differ diff --git a/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend b/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend index e940742c1..67468fd63 100644 Binary files a/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend and b/mods/ITEMS/mcl_armor/models/mcl_armor_character.blend differ diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index 6dfa807bf..0d58739ed 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -4,7 +4,7 @@ ------------------------------------------------------------------------------- function settlements.build_schematic(vm, data, va, pos, building, replace_wall, name) -- get building node material for better integration to surrounding - local platform_material = minetest.get_node_or_nil(pos) + local platform_material = mcl_util.get_far_node(pos, true) if not platform_material then return end diff --git a/mods/MAPGEN/mcl_villages/depends.txt b/mods/MAPGEN/mcl_villages/depends.txt index 9ba29f3ee..e9d14ad9b 100644 --- a/mods/MAPGEN/mcl_villages/depends.txt +++ b/mods/MAPGEN/mcl_villages/depends.txt @@ -1,3 +1,4 @@ +mcl_util mcl_core mcl_loot mcl_farming? diff --git a/mods/MAPGEN/mcl_villages/foundation.lua b/mods/MAPGEN/mcl_villages/foundation.lua index 15936ef4c..98726966c 100644 --- a/mods/MAPGEN/mcl_villages/foundation.lua +++ b/mods/MAPGEN/mcl_villages/foundation.lua @@ -52,8 +52,7 @@ function settlements.terraform(settlement_info, pr) else -- write ground local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi} - minetest.forceload_block(p) - local node = minetest.get_node_or_nil(p) + local node = mcl_util.get_far_node(p, true) if node and node.name ~= "air" then minetest.swap_node(p,{name="air"}) end diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index 6413174db..287b4c9be 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -94,11 +94,8 @@ if mg_name ~= "singlenode" then -- don't build settlements on (too) uneven terrain local height_difference = settlements.evaluate_heightmap(minp, maxp) if height_difference > max_height_difference then return end - - -- new way - slow :((((( - minetest.emerge_area(vector.subtract(minp,24), vector.add(maxp,24), ecb_build_a_settlement, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed}) - -- old way - wait 3 seconds: - -- minetest.after(3, ecb_build_a_settlement, nil, 1, 0, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed}) + -- we need 'minetest.after' here to exit from emerging thread we probably currently in: + minetest.after(0.1, build_a_settlement_no_delay, vector.new(minp), vector.new(maxp), blockseed) end) end -- manually place villages diff --git a/mods/MAPGEN/mcl_villages/utils.lua b/mods/MAPGEN/mcl_villages/utils.lua index 96d540b57..c539e7dc1 100644 --- a/mods/MAPGEN/mcl_villages/utils.lua +++ b/mods/MAPGEN/mcl_villages/utils.lua @@ -51,7 +51,7 @@ function settlements.find_surface(pos) local itter -- count up or down local cnt_max = 200 -- check, in which direction to look for surface - local surface_node = minetest.get_node_or_nil(p6) + local surface_node = mcl_util.get_far_node(p6, true) if surface_node and string.find(surface_node.name,"air") then itter = -1 else @@ -60,32 +60,16 @@ function settlements.find_surface(pos) -- go through nodes an find surface while cnt < cnt_max do cnt = cnt+1 - minetest.forceload_block(p6) - surface_node = minetest.get_node_or_nil(p6) - - if not surface_node then - -- Load the map at pos and try again - minetest.get_voxel_manip():read_from_map(p6, p6) - surface_node = minetest.get_node(p6) - if surface_node.name == "ignore" then - settlements.debug("find_surface1: nil or ignore") - return nil - end + surface_node = mcl_util.get_far_node(p6, true) + if surface_node.name == "ignore" then + settlements.debug("find_surface1: nil or ignore") + return nil end - -- if surface_node == nil or surface_node.name == "ignore" then - -- --return nil - -- local fl = minetest.forceload_block(p6) - -- if not fl then - -- - -- return nil - -- end - -- end - -- -- Check Surface_node and Node above -- if settlements.surface_mat[surface_node.name] then - local surface_node_plus_1 = minetest.get_node_or_nil({ x=p6.x, y=p6.y+1, z=p6.z}) + local surface_node_plus_1 = mcl_util.get_far_node({ x=p6.x, y=p6.y+1, z=p6.z}, true) if surface_node_plus_1 and surface_node and (string.find(surface_node_plus_1.name,"air") or string.find(surface_node_plus_1.name,"snow") or @@ -257,7 +241,7 @@ function settlements.initialize_nodes(settlement_info, pr) for xi = 0,width do for zi = 0,depth do local ptemp = {x=p.x+xi, y=p.y+yi, z=p.z+zi} - local node = minetest.get_node(ptemp) + local node = mcl_util.get_far_node(ptemp, true) if node.name == "mcl_furnaces:furnace" or node.name == "mcl_chests:chest" or node.name == "mcl_anvils:anvil" then diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index a4606a9da..92ec697d8 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -38,7 +38,7 @@ minetest.register_globalstep(function(dtime) -- sets eye height, and nametag color accordingly player:set_properties({eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) - elseif minetest.get_item_group(mcl_playerinfo[name].node_stand, "water") ~= 0 then + elseif minetest.get_item_group(mcl_playerinfo[name].node_stand, "water") ~= 0 and player:get_attach() == nil then -- controls head pitch when swiming player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90,0,0)) -- sets eye height, and nametag color accordingly