From c7045bc415b680ae67b050b733a1f2e1b1a4350a Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 02:57:24 +0200 Subject: [PATCH 1/2] Instadig nodes on punch in (gamemode) creative --- mods/HUD/mcl_inventory/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index 86670a8b3..895ccd811 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 From 20a30f9f44c0819b4c10606da7b5e212453e27c7 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 03:39:59 +0200 Subject: [PATCH 2/2] Instakill mobs on punch in creative --- mods/ENTITIES/mcl_mobs/api.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 23bcbf37f..438f7f4f2 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