From 484a20083f107dfa3db87922fe335e3fbd72886d Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Tue, 15 Jun 2021 12:39:25 +0200 Subject: [PATCH] Builtin: minor patches --- builtin/game/falling.lua | 6 +++++- builtin/game/item.lua | 5 +++++ builtin/game/misc.lua | 9 ++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 6ae2aaf6..773bb796 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -158,7 +158,11 @@ core.register_entity(":__builtin:falling_node", { -- Drop node if does not fall within 5 seconds self.timer = self.timer + dtime if self.timer > 5 then - core.add_item(pos, self.node) + -- Add dropped items + local drops = core.get_node_drops(self.node, "") + for _, dropped_item in pairs(drops) do + core.add_item(pos, dropped_item) + end self.object:remove() end end diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 51c1db17..a53457df 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -624,6 +624,11 @@ end function core.item_eat(hp_change, replace_with_item, poison) return function(itemstack, user, pointed_thing) -- closure if user then + if user:is_player() and pointed_thing.type == "object" then + pointed_thing.ref:right_click(user) + return user:get_wielded_item() + end + return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing, poison) end end diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 72dc1160..39b72ef8 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -44,7 +44,9 @@ local player_list = {} function core.send_join_message(player_name) - core.chat_send_all("=> " .. player_name .. " has joined the server") + if not core.is_singleplayer() then + core.chat_send_all("=> " .. player_name .. " has joined the server") + end end @@ -60,10 +62,7 @@ end core.register_on_joinplayer(function(player) local player_name = player:get_player_name() player_list[player_name] = player - if not core.is_singleplayer() then - core.send_join_message(player_name) - end - + core.send_join_message(player_name) end)