Update master #1

Merged
THE-NERD2 merged 296 commits from VoxeLibre/VoxeLibre:master into master 2024-11-21 19:51:04 +01:00
3 changed files with 21 additions and 10 deletions
Showing only changes of commit 8acddab74f - Show all commits

View File

@ -8,7 +8,17 @@ The bone meal API provides a callback definition that nodes can use to
register a handler that is executed when a bone meal item is used on it.
Nodes that wish to use the bone meal API should in their node registration
define a callback handler named `_mcl_on_bonemealing`. This handler is a
define a callback handler named `_mcl_on_bonemealing`.
Note that by registering the callback handler, the node declares that bone
meal can be used on it and as a result, when the user is not in creative
mode, the used bone meal is spent and taken from the itemstack passed to
the `on_place()` handler of the bone meal item used.
It is for all intents and purposes up to the callback defined in the node to
decide how to handle the specific effect that bone meal has on that node.
The `_mcl_on_bonemealing` callback handler is a
`function(pointed_thing, placer)`
@ -17,10 +27,9 @@ Its arguments are:
bone meal is applied
* `placer`: ObjectRef of the player who aplied the bone meal, can be nil!
The function should return `true` if the bonemealing was succesful.
It is for all intents and purposes up to the callback defined in the node to
decide how to handle the effect that bone meal has on that particular node.
The return value of the handler function indicates if the bonemealing had
its intended effect. If `true`, 'bone meal particles' are spawned at the
position of the bonemealed node.
The `on_place` code in the bone meal item will spawn bone meal particles and
decrease the bone meal itemstack if the handler returned `true` and the

View File

@ -49,7 +49,7 @@ end
--
mcl_bone_meal.bone_meal_callbacks = {}
-- Shims for the old API are still available in mcl_dye and refer to
-- Shims for the old API are still available in mcl_dye and defer to
-- the real functions in mcl_bone_meal.
--
function mcl_bone_meal.register_on_bone_meal_apply(func)
@ -117,9 +117,9 @@ minetest.register_craftitem("mcl_bone_meal:bone_meal", {
if ndef and ndef._mcl_on_bonemealing then
if ndef._mcl_on_bonemealing(pointed_thing, placer) then
mcl_bone_meal.add_bone_meal_particle(pos)
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
end
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
-- Otherwise try the legacy API.
elseif apply_bone_meal(pointed_thing, placer) and
@ -140,8 +140,9 @@ minetest.register_craftitem("mcl_bone_meal:bone_meal", {
-- If the pointed node can be bonemealed, let it handle the processing.
if ndef and ndef._mcl_on_bonemealing then
if ndef._mcl_on_bonemealing(pointed_thing, nil) then
itemstack:take_item()
mcl_bone_meal.add_bone_meal_particle(pos)
end
itemstack:take_item()
else
-- Otherwise try the legacy API.
if apply_bone_meal(pointed_thing, nil) then

View File

@ -167,6 +167,7 @@ for i = 1, 3 do
end
if i == 3 then
def.drop = "mcl_cocoas:cocoa_beans 3"
def._mcl_on_bonemealing = nil
end
minetest.register_node("mcl_cocoas:cocoa_" .. i, table.copy(def))