forked from VoxeLibre/VoxeLibre
Respawn armor entity of armor stand on load
This commit is contained in:
parent
267a697fab
commit
e332c64d2a
|
@ -125,6 +125,12 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
||||||
minetest.record_protection_violation(pos, protname)
|
minetest.record_protection_violation(pos, protname)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local inv = minetest.get_inventory({type = "node", pos = pos})
|
||||||
|
if not inv then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if player wields armor
|
-- Check if player wields armor
|
||||||
local name = itemstack:get_name()
|
local name = itemstack:get_name()
|
||||||
local list
|
local list
|
||||||
|
@ -135,11 +141,8 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If player wields armor, put it on armor stand
|
-- If player wields armor, put it on armor stand
|
||||||
local inv = minetest.get_inventory({type = "node", pos = pos})
|
|
||||||
local wielditem = clicker:get_wielded_item()
|
local wielditem = clicker:get_wielded_item()
|
||||||
if not inv then return itemstack end
|
|
||||||
if list then
|
if list then
|
||||||
-- ... but only if the slot is free
|
-- ... but only if the slot is free
|
||||||
local single_item = ItemStack(itemstack)
|
local single_item = ItemStack(itemstack)
|
||||||
|
@ -172,11 +175,12 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
||||||
if taken then
|
if taken then
|
||||||
stand_armor:take_item()
|
stand_armor:take_item()
|
||||||
inv:set_stack("armor_" .. elements[e], 1, stand_armor)
|
inv:set_stack("armor_" .. elements[e], 1, stand_armor)
|
||||||
update_entity(pos)
|
|
||||||
end
|
end
|
||||||
|
update_entity(pos)
|
||||||
return clicker:get_wielded_item()
|
return clicker:get_wielded_item()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
update_entity(pos)
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
|
@ -264,6 +268,17 @@ minetest.register_entity("3d_armor_stand:armor_entity", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- FIXME: Armor helper entity can get destroyed by /clearobjects
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Respawn armor stand entities",
|
||||||
|
name = "3d_armor_stand:respawn_entities",
|
||||||
|
nodenames = {"3d_armor_stand:armor_stand"},
|
||||||
|
run_at_every_load = true,
|
||||||
|
action = function(pos, node)
|
||||||
|
update_entity(pos, node)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
if minetest.get_modpath("doc_identifier") ~= nil then
|
if minetest.get_modpath("doc_identifier") ~= nil then
|
||||||
doc.sub.identifier.register_object("3d_armor_stand:armor_entity", "nodes", "3d_armor_stand:armor_stand")
|
doc.sub.identifier.register_object("3d_armor_stand:armor_entity", "nodes", "3d_armor_stand:armor_stand")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue