From 7ddcf3f93fd42571be9a6b9e559f6e8953a299da Mon Sep 17 00:00:00 2001 From: kabou Date: Mon, 2 May 2022 01:35:47 +0200 Subject: [PATCH] Use better override mechanism. * Use `minetest.override_item()` instead of re-registering the node with ":" prefixed to its name. Thanks again to wsor for mentioning this. --- mods/ITEMS/mcl_flowers/bonemealing.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_flowers/bonemealing.lua b/mods/ITEMS/mcl_flowers/bonemealing.lua index a478ec458..297c297e8 100644 --- a/mods/ITEMS/mcl_flowers/bonemealing.lua +++ b/mods/ITEMS/mcl_flowers/bonemealing.lua @@ -108,19 +108,18 @@ local function bonemeal_grass(pointed_thing, placer) return true end --- Overwrite "mcl_core:dirt_with_grass" bonemealing handler. +-- Override "mcl_core:dirt_with_grass" bonemealing handler. local nodename = "mcl_core:dirt_with_grass" local olddef = minetest.registered_nodes[nodename] if not olddef then minetest.log("warning", "'mcl_core:dirt_with_grass' not registered, cannot add override!") else local oldhandler = olddef._mcl_on_bonemealing - local newdef = table.copy(olddef) - newdef._mcl_on_bonemealing = function (pointed_thing, placer) + local newhandler = function (pointed_thing, placer) bonemeal_grass(pointed_thing, placer) if oldhandler then oldhandler(pointed_thing, placer) end end - minetest.register_node(":" .. nodename, newdef) + minetest.override_item(nodename, {_mcl_on_bonemealing = newhandler}) end