Builtin: minor patches

This commit is contained in:
MoNTE48 2021-06-15 12:39:25 +02:00
parent 191bb343f9
commit 484a20083f
3 changed files with 14 additions and 6 deletions

View File

@ -158,7 +158,11 @@ core.register_entity(":__builtin:falling_node", {
-- Drop node if does not fall within 5 seconds -- Drop node if does not fall within 5 seconds
self.timer = self.timer + dtime self.timer = self.timer + dtime
if self.timer > 5 then 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() self.object:remove()
end end
end end

View File

@ -624,6 +624,11 @@ end
function core.item_eat(hp_change, replace_with_item, poison) function core.item_eat(hp_change, replace_with_item, poison)
return function(itemstack, user, pointed_thing) -- closure return function(itemstack, user, pointed_thing) -- closure
if user then 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) return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing, poison)
end end
end end

View File

@ -44,7 +44,9 @@ local player_list = {}
function core.send_join_message(player_name) 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 end
@ -60,10 +62,7 @@ end
core.register_on_joinplayer(function(player) core.register_on_joinplayer(function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
player_list[player_name] = player player_list[player_name] = player
if not core.is_singleplayer() then core.send_join_message(player_name)
core.send_join_message(player_name)
end
end) end)