diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 23bcbf37f3..438f7f4f27 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3148,6 +3148,10 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) return end + if minetest.is_creative_enabled(hitter:get_player_name()) then + self.health = 0 + end + -- set/update 'drop xp' timestamp if hitted by player self.xp_timestamp = minetest.get_us_time() end diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index 86670a8b30..895ccd8115 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -196,6 +196,7 @@ local mt_is_creative_enabled = minetest.is_creative_enabled function minetest.is_creative_enabled(name) if mt_is_creative_enabled(name) then return true end + if not name then return false end local p = minetest.get_player_by_name(name) if p then return p:get_meta():get_string("gamemode") == "creative" @@ -203,6 +204,20 @@ function minetest.is_creative_enabled(name) return false end +--Insta "digging" nodes in gamemode-creative +minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) + if minetest.is_creative_enabled() then return end + local name = puncher:get_player_name() + if not minetest.is_creative_enabled(name) then return end + if pointed_thing.type ~= "node" then return end + local def = minetest.registered_nodes[node.name] + if def then + if def.on_destruct then def.on_destruct(pos) end + minetest.remove_node(pos) + return true + end +end) + local function in_table(n,h) for k,v in pairs(h) do if v == n then return true end