mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-16 02:05:04 +00:00
Respawn armor entity of armor stand on load
This commit is contained in:
parent
267a697fab
commit
e332c64d2a
1 changed files with 19 additions and 4 deletions
|
@ -125,6 +125,12 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
|||
minetest.record_protection_violation(pos, protname)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local inv = minetest.get_inventory({type = "node", pos = pos})
|
||||
if not inv then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Check if player wields armor
|
||||
local name = itemstack:get_name()
|
||||
local list
|
||||
|
@ -135,11 +141,8 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
|||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- If player wields armor, put it on armor stand
|
||||
local inv = minetest.get_inventory({type = "node", pos = pos})
|
||||
local wielditem = clicker:get_wielded_item()
|
||||
if not inv then return itemstack end
|
||||
if list then
|
||||
-- ... but only if the slot is free
|
||||
local single_item = ItemStack(itemstack)
|
||||
|
@ -172,11 +175,12 @@ minetest.register_node("3d_armor_stand:armor_stand", {
|
|||
if taken then
|
||||
stand_armor:take_item()
|
||||
inv:set_stack("armor_" .. elements[e], 1, stand_armor)
|
||||
update_entity(pos)
|
||||
end
|
||||
update_entity(pos)
|
||||
return clicker:get_wielded_item()
|
||||
end
|
||||
end
|
||||
update_entity(pos)
|
||||
return itemstack
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
|
@ -264,6 +268,17 @@ minetest.register_entity("3d_armor_stand:armor_entity", {
|
|||
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
|
||||
doc.sub.identifier.register_object("3d_armor_stand:armor_entity", "nodes", "3d_armor_stand:armor_stand")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue