Always spawn wield ents at live player pos

Don't use the stored pos, which might be at the time of
player login, and thus arbitrarily far from where the player
is now, such that it might never actually be loaded.
This commit is contained in:
Aaron Suen 2022-09-26 07:31:20 -04:00
parent b37d01107f
commit f15e1369f1

View File

@ -100,12 +100,13 @@ local function pumpqueue()
local player = minetest.get_player_by_name(v.pname) local player = minetest.get_player_by_name(v.pname)
if not player then return end if not player then return end
if not minetest.get_node_or_nil(player:get_pos()) then local pos = player:get_pos()
if not minetest.get_node_or_nil() then
attq[#attq + 1] = v attq[#attq + 1] = v
return return
end end
local obj = minetest.add_entity(v.pos, modname .. ":ent") local obj = minetest.add_entity(pos, modname .. ":ent")
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
ent.conf = v ent.conf = v
end end
@ -178,13 +179,11 @@ minetest.register_entity(modname .. ":ent", entdef)
nodecore.register_on_joinplayer("join setup wieldview", function(player) nodecore.register_on_joinplayer("join setup wieldview", function(player)
local pname = player:get_player_name() local pname = player:get_player_name()
local pos = player:get_pos()
local function addslot(n, b, x, y, z, rx, ry, rz) local function addslot(n, b, x, y, z, rx, ry, rz)
attq[#attq + 1] = { attq[#attq + 1] = {
pname = pname, pname = pname,
slot = n, slot = n,
pos = pos,
bone = b, bone = b,
apos = { apos = {
x = x, x = x,