mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 03:51:05 +01:00
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.
This commit is contained in:
parent
e8d965e21a
commit
7ddcf3f93f
1 changed files with 3 additions and 4 deletions
|
@ -108,19 +108,18 @@ local function bonemeal_grass(pointed_thing, placer)
|
||||||
return true
|
return true
|
||||||
end
|
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 nodename = "mcl_core:dirt_with_grass"
|
||||||
local olddef = minetest.registered_nodes[nodename]
|
local olddef = minetest.registered_nodes[nodename]
|
||||||
if not olddef then
|
if not olddef then
|
||||||
minetest.log("warning", "'mcl_core:dirt_with_grass' not registered, cannot add override!")
|
minetest.log("warning", "'mcl_core:dirt_with_grass' not registered, cannot add override!")
|
||||||
else
|
else
|
||||||
local oldhandler = olddef._mcl_on_bonemealing
|
local oldhandler = olddef._mcl_on_bonemealing
|
||||||
local newdef = table.copy(olddef)
|
local newhandler = function (pointed_thing, placer)
|
||||||
newdef._mcl_on_bonemealing = function (pointed_thing, placer)
|
|
||||||
bonemeal_grass(pointed_thing, placer)
|
bonemeal_grass(pointed_thing, placer)
|
||||||
if oldhandler then
|
if oldhandler then
|
||||||
oldhandler(pointed_thing, placer)
|
oldhandler(pointed_thing, placer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.register_node(":" .. nodename, newdef)
|
minetest.override_item(nodename, {_mcl_on_bonemealing = newhandler})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue