Skip to content

Commit

Permalink
Fix invalid player object crash
Browse files Browse the repository at this point in the history
  • Loading branch information
appgurueu committed Jul 29, 2022
1 parent a2acecd commit d8ce7ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ local entity_name = "visible_wielditem:visible_wielditem"
local entities = {}

local function create_entity(player)
minetest.add_entity(assert(player:get_pos()), entity_name):get_luaentity():_set_player(player)
local pos = player:get_pos()
if not pos then return end -- HACK deal with player object being invalidated before on_leaveplayer has been called
minetest.add_entity(pos, entity_name):get_luaentity():_set_player(player)
end

minetest.register_on_joinplayer(create_entity)
Expand Down

0 comments on commit d8ce7ba

Please sign in to comment.