From 823ff7e22e7f1e6956878acce30893daee7c808c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 5 Jan 2021 20:36:50 +0100 Subject: [PATCH] Fix #955 --- mods/ITEMS/mcl_furnaces/init.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index a0b9469558..d3877d90b5 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -69,15 +69,17 @@ local receive_fields = function(pos, formname, fields, sender) end end -local function drop_xp(pos) - if mcl_experience.throw_experience then - local meta = minetest.get_meta(pos) - local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2),-1.95) - local xp = meta:get_int("xp") - if xp > 0 then +local function give_xp(pos, player) + local meta = minetest.get_meta(pos) + local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2),-1.95) + local xp = meta:get_int("xp") + if xp > 0 then + if player then + mcl_experience.add_experience(player, xp) + else mcl_experience.throw_experience(vector.add(pos, dir), xp) - meta:set_int("xp", 0) end + meta:set_int("xp", 0) end end @@ -155,7 +157,7 @@ local function on_metadata_inventory_take(pos, listname, index, stack, player) elseif stack:get_name() == "mcl_fishing:fish_cooked" then awards.unlock(player:get_player_name(), "mcl:cookFish") end - drop_xp(pos) + give_xp(pos, player) end end @@ -472,7 +474,7 @@ minetest.register_node("mcl_furnaces:furnace", { end, on_destruct = function(pos) mcl_particles.delete_node_particlespawners(pos) - drop_xp(pos) + give_xp(pos) end, on_metadata_inventory_move = function(pos) @@ -486,14 +488,14 @@ minetest.register_node("mcl_furnaces:furnace", { -- start timer function, it will sort out whether furnace can burn or not. minetest.get_node_timer(pos):start(1.0) end, - on_metadata_inventory_take = function(pos, listname) + on_metadata_inventory_take = function(pos, listname, index, stack, player) -- Reset accumulated game time when player works with furnace: furnace_reset_delta_time(pos) -- start timer function, it will helpful if player clears dst slot minetest.get_node_timer(pos):start(1.0) if listname == "dst" then - drop_xp(pos) + give_xp(pos, player) end end, @@ -544,7 +546,7 @@ minetest.register_node("mcl_furnaces:furnace_active", { end, on_destruct = function(pos) mcl_particles.delete_node_particlespawners(pos) - drop_xp(pos) + give_xp(pos) end, allow_metadata_inventory_put = allow_metadata_inventory_put,