Update 3d_armor and fix stands

stands were unusable since I forgot to put locaked armor stands back to protected armor stands
This commit is contained in:
Elkien3 2018-05-26 08:48:49 -05:00
parent 3fa6069d4a
commit 19f9fb05e9
71 changed files with 188 additions and 149 deletions

View File

@ -4,6 +4,7 @@ local S = armor_i18n.gettext
local skin_previews = {} local skin_previews = {}
local use_player_monoids = minetest.global_exists("player_monoids") local use_player_monoids = minetest.global_exists("player_monoids")
local use_armor_monoid = minetest.global_exists("armor_monoid") local use_armor_monoid = minetest.global_exists("armor_monoid")
local use_pova_mod = minetest.get_modpath("pova")
local armor_def = setmetatable({}, { local armor_def = setmetatable({}, {
__index = function() __index = function()
return setmetatable({ return setmetatable({
@ -269,7 +270,8 @@ armor.set_player_armor = function(self, player)
change[group] = groups[group] / base change[group] = groups[group] / base
end end
for _, attr in pairs(self.attributes) do for _, attr in pairs(self.attributes) do
self.def[name][attr] = attributes[attr] local mult = attr == "heal" and self.config.heal_multiplier or 1
self.def[name][attr] = attributes[attr] * mult
end end
for _, phys in pairs(self.physics) do for _, phys in pairs(self.physics) do
self.def[name][phys] = physics[phys] self.def[name][phys] = physics[phys]
@ -286,6 +288,14 @@ armor.set_player_armor = function(self, player)
"3d_armor:physics") "3d_armor:physics")
player_monoids.gravity:add_change(player, physics.gravity, player_monoids.gravity:add_change(player, physics.gravity,
"3d_armor:physics") "3d_armor:physics")
elseif use_pova_mod then
-- only add the changes, not the default 1.0 for each physics setting
pova.add_override(name, "3d_armor", {
speed = physics.speed - 1,
jump = physics.jump - 1,
gravity = physics.gravity - 1,
})
pova.do_override(player)
else else
player:set_physics_override(physics) player:set_physics_override(physics)
end end
@ -377,7 +387,6 @@ armor.damage = function(self, player, index, stack, use)
self:run_callbacks("on_damage", player, index, stack) self:run_callbacks("on_damage", player, index, stack)
self:set_inventory_stack(player, index, stack) self:set_inventory_stack(player, index, stack)
if stack:get_count() == 0 then if stack:get_count() == 0 then
self:run_callbacks("on_unequip", player, index, old_stack)
self:run_callbacks("on_destroy", player, index, old_stack) self:run_callbacks("on_destroy", player, index, old_stack)
self:set_player_armor(player) self:set_player_armor(player)
end end
@ -428,6 +437,14 @@ armor.get_armor_formspec = function(self, name, listring)
return formspec return formspec
end end
armor.get_element = function(self, item_name)
for _, element in pairs(armor.elements) do
if minetest.get_item_group(item_name, "armor_"..element) > 0 then
return element
end
end
end
armor.serialize_inventory_list = function(self, list) armor.serialize_inventory_list = function(self, list)
local list_table = {} local list_table = {}
for _, stack in ipairs(list) do for _, stack in ipairs(list) do
@ -446,37 +463,64 @@ armor.deserialize_inventory_list = function(self, list_string)
end end
armor.load_armor_inventory = function(self, player) armor.load_armor_inventory = function(self, player)
local msg = "[load_armor_inventory]" local name, inv = self:get_valid_player(player, "[load_armor_inventory]")
local name = player:get_player_name()
if not name then if not name then
minetest.log("warning", S("3d_armor: Player name is nil @1", msg))
return
end
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
if not armor_inv then
minetest.log("warning", S("3d_armor: Detached armor inventory is nil @1", msg))
return return
end end
local armor_list_string = player:get_attribute("3d_armor_inventory") local armor_list_string = player:get_attribute("3d_armor_inventory")
if armor_list_string then if armor_list_string then
armor_inv:set_list("armor", self:deserialize_inventory_list(armor_list_string)) inv:set_list("armor",
self:deserialize_inventory_list(armor_list_string))
return true return true
end end
end end
armor.save_armor_inventory = function(self, player) armor.save_armor_inventory = function(self, player)
local msg = "[save_armor_inventory]" local name, inv = self:get_valid_player(player, "[save_armor_inventory]")
local name = player:get_player_name()
if not name then if not name then
minetest.log("warning", S("3d_armor: Player name is nil @1", msg))
return return
end end
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"}) -- Workaround for detached inventory swap exploit
if not armor_inv then local armor_prev = {}
minetest.log("warning", S("3d_armor: Detached armor inventory is nil @1", msg)) local armor_list_string = player:get_attribute("3d_armor_inventory")
return if armor_list_string then
local armor_list = self:deserialize_inventory_list(armor_list_string)
for i, stack in ipairs(armor_list) do
if stack:get_count() > 0 then
armor_prev[stack:get_name()] = i
end end
player:set_attribute("3d_armor_inventory", self:serialize_inventory_list(armor_inv:get_list("armor"))) end
end
local elements = {}
local player_inv = player:get_inventory()
for i = 1, 6 do
local stack = inv:get_stack("armor", i)
if stack:get_count() > 0 then
local item = stack:get_name()
local element = self:get_element(item)
if element and not elements[element] then
if armor_prev[item] then
armor_prev[item] = nil
else
-- Item was not in previous inventory
armor:run_callbacks("on_equip", player, i, stack)
end
elements[element] = true;
else
inv:remove_item("armor", stack)
if player_inv and player_inv:room_for_item("main", stack) then
player_inv:add_item("main", stack)
end
end
end
end
for item, i in pairs(armor_prev) do
local stack = ItemStack(item)
-- Previous item is not in current inventory
armor:run_callbacks("on_unequip", player, i, stack)
end
player:set_attribute("3d_armor_inventory",
self:serialize_inventory_list(inv:get_list("armor")))
end end
armor.update_inventory = function(self, player) armor.update_inventory = function(self, player)
@ -484,19 +528,11 @@ armor.update_inventory = function(self, player)
end end
armor.set_inventory_stack = function(self, player, i, stack) armor.set_inventory_stack = function(self, player, i, stack)
local msg = "[set_inventory_stack]" local name, inv = self:get_valid_player(player, "[set_inventory_stack]")
local name = player:get_player_name() if inv then
if not name then inv:set_stack("armor", i, stack)
minetest.log("warning", S("3d_armor: Player name is nil @1", msg))
return
end
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
if not armor_inv then
minetest.log("warning", S("3d_armor: Detached armor inventory is nil @1", msg))
return
end
armor_inv:set_stack("armor", i, stack)
self:save_armor_inventory(player) self:save_armor_inventory(player)
end
end end
armor.get_valid_player = function(self, player, msg) armor.get_valid_player = function(self, player, msg)

View File

@ -1,6 +1,7 @@
default default
player_monoids? player_monoids?
armor_monoid? armor_monoid?
pova?
fire? fire?
ethereal? ethereal?
bakedclay? bakedclay?

View File

@ -118,33 +118,30 @@ local function init_player_armor(player)
local armor_inv = minetest.create_detached_inventory(name.."_armor", { local armor_inv = minetest.create_detached_inventory(name.."_armor", {
on_put = function(inv, listname, index, stack, player) on_put = function(inv, listname, index, stack, player)
armor:save_armor_inventory(player) armor:save_armor_inventory(player)
armor:run_callbacks("on_equip", player, index, stack)
armor:set_player_armor(player) armor:set_player_armor(player)
end, end,
on_take = function(inv, listname, index, stack, player) on_take = function(inv, listname, index, stack, player)
armor:save_armor_inventory(player) armor:save_armor_inventory(player)
armor:run_callbacks("on_unequip", player, index, stack)
armor:set_player_armor(player) armor:set_player_armor(player)
end, end,
on_move = function(inv, from_list, from_index, to_list, to_index, count, player) on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
armor:save_armor_inventory(player) armor:save_armor_inventory(player)
armor:set_player_armor(player) armor:set_player_armor(player)
end, end,
allow_put = function(inv, listname, index, stack, player) allow_put = function(inv, listname, index, put_stack, player)
local def = stack:get_definition() or {} local element = armor:get_element(put_stack:get_name())
local allowed = 0 if not element then
for _, element in pairs(armor.elements) do return 0
if def.groups["armor_"..element] then end
allowed = 1
for i = 1, 6 do for i = 1, 6 do
local item = inv:get_stack("armor", i):get_name() local stack = inv:get_stack("armor", i)
if minetest.get_item_group(item, "armor_"..element) > 0 then local def = stack:get_definition() or {}
if def.groups and def.groups["armor_"..element]
and i ~= index then
return 0 return 0
end end
end end
end return 1
end
return allowed
end, end,
allow_take = function(inv, listname, index, stack, player) allow_take = function(inv, listname, index, stack, player)
return stack:get_count() return stack:get_count()
@ -166,8 +163,10 @@ local function init_player_armor(player)
end end
for i=1, 6 do for i=1, 6 do
local stack = armor_inv:get_stack("armor", i) local stack = armor_inv:get_stack("armor", i)
if stack:get_count() > 0 then
armor:run_callbacks("on_equip", player, i, stack) armor:run_callbacks("on_equip", player, i, stack)
end end
end
armor.def[name] = { armor.def[name] = {
init_time = minetest.get_gametime(), init_time = minetest.get_gametime(),
level = 0, level = 0,
@ -269,10 +268,10 @@ if armor.config.drop == true or armor.config.destroy == true then
local stack = armor_inv:get_stack("armor", i) local stack = armor_inv:get_stack("armor", i)
if stack:get_count() > 0 then if stack:get_count() > 0 then
table.insert(drop, stack) table.insert(drop, stack)
armor:set_inventory_stack(player, i, nil) armor_inv:set_stack("armor", i, nil)
armor:run_callbacks("on_unequip", player, i, stack)
end end
end end
armor:save_armor_inventory(player)
armor:set_player_armor(player) armor:set_player_armor(player)
local pos = player:getpos() local pos = player:getpos()
if pos and armor.config.destroy == false then if pos and armor.config.destroy == false then
@ -323,7 +322,6 @@ minetest.register_on_player_hpchange(function(player, hp_change)
local name = player:get_player_name() local name = player:get_player_name()
if name then if name then
local heal = armor.def[name].heal local heal = armor.def[name].heal
heal = heal * armor.config.heal_multiplier
if heal >= math.random(100) then if heal >= math.random(100) then
hp_change = 0 hp_change = 0
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

View File

@ -0,0 +1,44 @@
3d_armor/textures/3d_armor_helmet_wood.png:head
3d_armor/textures/3d_armor_chestplate_wood.png:torso
3d_armor/textures/3d_armor_leggings_wood.png:legs
3d_armor/textures/3d_armor_boots_wood.png:feet
3d_armor/textures/3d_armor_helmet_cactus.png:head
3d_armor/textures/3d_armor_chestplate_cactus.png:torso
3d_armor/textures/3d_armor_leggings_cactus.png:legs
3d_armor/textures/3d_armor_boots_cactus.png:feet
3d_armor/textures/3d_armor_helmet_steel.png:head
3d_armor/textures/3d_armor_chestplate_steel.png:torso
3d_armor/textures/3d_armor_leggings_steel.png:legs
3d_armor/textures/3d_armor_boots_steel.png:feet
3d_armor/textures/3d_armor_helmet_bronze.png:head
3d_armor/textures/3d_armor_chestplate_bronze.png:torso
3d_armor/textures/3d_armor_leggings_bronze.png:legs
3d_armor/textures/3d_armor_boots_bronze.png:feet
3d_armor/textures/3d_armor_helmet_gold.png:head
3d_armor/textures/3d_armor_chestplate_gold.png:torso
3d_armor/textures/3d_armor_leggings_gold.png:legs
3d_armor/textures/3d_armor_boots_gold.png:feet
3d_armor/textures/3d_armor_helmet_diamond.png:head
3d_armor/textures/3d_armor_chestplate_diamond.png:torso
3d_armor/textures/3d_armor_leggings_diamond.png:legs
3d_armor/textures/3d_armor_boots_diamond.png:feet
3d_armor/textures/3d_armor_helmet_mithril.png:head
3d_armor/textures/3d_armor_chestplate_mithril.png:torso
3d_armor/textures/3d_armor_leggings_mithril.png:legs
3d_armor/textures/3d_armor_boots_mithril.png:feet
3d_armor/textures/3d_armor_helmet_crystal.png:head
3d_armor/textures/3d_armor_chestplate_crystal.png:torso
3d_armor/textures/3d_armor_leggings_crystal.png:legs
3d_armor/textures/3d_armor_boots_crystal.png:feet
3d_armor/textures/3d_armor_helmet_admin.png:head
3d_armor/textures/3d_armor_chestplate_admin.png:torso
3d_armor/textures/3d_armor_leggings_admin.png:legs
3d_armor/textures/3d_armor_boots_admin.png:feet

View File

@ -1,6 +1,3 @@
-- support for i18n
local S = armor_i18n.gettext
local armor_stand_formspec = "size[8,7]" .. local armor_stand_formspec = "size[8,7]" ..
default.gui_bg .. default.gui_bg ..
default.gui_bg_img .. default.gui_bg_img ..
@ -19,18 +16,6 @@ local armor_stand_formspec = "size[8,7]" ..
local elements = {"head", "torso", "legs", "feet"} local elements = {"head", "torso", "legs", "feet"}
local function drop_armor(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for _, element in pairs(elements) do
local stack = inv:get_stack("armor_"..element, 1)
if stack and stack:get_count() > 0 then
armor.drop_armor(pos, stack)
inv:set_stack("armor_"..element, 1, nil)
end
end
end
local function get_stand_object(pos) local function get_stand_object(pos)
local object = nil local object = nil
local objects = minetest.get_objects_inside_radius(pos, 0.5) or {} local objects = minetest.get_objects_inside_radius(pos, 0.5) or {}
@ -113,40 +98,8 @@ local function has_locked_armor_stand_privilege(meta, player)
return true return true
end end
local function add_hidden_node(pos, player)
local p = {x=pos.x, y=pos.y + 1, z=pos.z}
local name = player:get_player_name()
local node = minetest.get_node(p)
if node.name == "air" and not minetest.is_protected(pos, name) then
minetest.set_node(p, {name="3d_armor_stand:top"})
end
end
local function remove_hidden_node(pos)
local p = {x=pos.x, y=pos.y + 1, z=pos.z}
local node = minetest.get_node(p)
if node.name == "3d_armor_stand:top" then
minetest.remove_node(p)
end
end
minetest.register_node("3d_armor_stand:top", {
description = S("Armor stand top"),
paramtype = "light",
drawtype = "plantlike",
sunlight_propagates = true,
walkable = true,
pointable = false,
diggable = false,
buildable_to = false,
drop = "",
groups = {not_in_creative_inventory = 1},
on_blast = function() end,
tiles = {"3d_armor_trans.png"},
})
minetest.register_node("3d_armor_stand:armor_stand", { minetest.register_node("3d_armor_stand:armor_stand", {
description = S("Armor stand"), description = "Armor stand",
drawtype = "mesh", drawtype = "mesh",
mesh = "3d_armor_stand.obj", mesh = "3d_armor_stand.obj",
tiles = {"3d_armor_stand.png"}, tiles = {"3d_armor_stand.png"},
@ -155,17 +108,14 @@ minetest.register_node("3d_armor_stand:armor_stand", {
walkable = false, walkable = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {-0.5,-0.5,-0.5, 0.5,1.4,0.5}
{-0.25, -0.4375, -0.25, 0.25, 1.4, 0.25},
{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
},
}, },
groups = {choppy=2, oddly_breakable_by_hand=2}, groups = {choppy=2, oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", armor_stand_formspec) meta:set_string("formspec", armor_stand_formspec)
meta:set_string("infotext", S("Armor Stand")) meta:set_string("infotext", "Armor Stand")
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, element in pairs(elements) do for _, element in pairs(elements) do
inv:set_size("armor_"..element, 1) inv:set_size("armor_"..element, 1)
@ -181,9 +131,8 @@ minetest.register_node("3d_armor_stand:armor_stand", {
end end
return true return true
end, end,
after_place_node = function(pos, placer) after_place_node = function(pos)
minetest.add_entity(pos, "3d_armor_stand:armor_entity") minetest.add_entity(pos, "3d_armor_stand:armor_entity")
add_hidden_node(pos, placer)
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack) allow_metadata_inventory_put = function(pos, listname, index, stack)
local def = stack:get_definition() or {} local def = stack:get_definition() or {}
@ -204,17 +153,20 @@ minetest.register_node("3d_armor_stand:armor_stand", {
end, end,
after_destruct = function(pos) after_destruct = function(pos)
update_entity(pos) update_entity(pos)
remove_hidden_node(pos)
end, end,
on_blast = function(pos) on_blast = function(pos)
drop_armor(pos) local object = get_stand_object(pos)
armor.drop_armor(pos, "3d_armor_stand:armor_stand") if object then
minetest.remove_node(pos) object:remove()
end
minetest.after(1, function(pos)
update_entity(pos)
end, pos)
end, end,
}) })
minetest.register_node("3d_armor_stand:locked_armor_stand", { minetest.register_node("3d_armor_stand:locked_armor_stand", {
description = S("Locked Armor stand"), description = "Protected Armor stand",
drawtype = "mesh", drawtype = "mesh",
mesh = "3d_armor_stand.obj", mesh = "3d_armor_stand.obj",
tiles = {"3d_armor_stand_locked.png"}, tiles = {"3d_armor_stand_locked.png"},
@ -223,17 +175,14 @@ minetest.register_node("3d_armor_stand:locked_armor_stand", {
walkable = false, walkable = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {-0.5,-0.5,-0.5, 0.5,1.4,0.5}
{-0.25, -0.4375, -0.25, 0.25, 1.4, 0.25},
{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
},
}, },
groups = {choppy=2, oddly_breakable_by_hand=2}, groups = {choppy=2, oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", armor_stand_formspec) meta:set_string("formspec", armor_stand_formspec)
meta:set_string("infotext", S("Armor Stand")) meta:set_string("infotext", "Armor Stand")
meta:set_string("owner", "") meta:set_string("owner", "")
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _, element in pairs(elements) do for _, element in pairs(elements) do
@ -253,25 +202,25 @@ minetest.register_node("3d_armor_stand:locked_armor_stand", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
minetest.add_entity(pos, "3d_armor_stand:armor_entity") minetest.add_entity(pos, "3d_armor_stand:armor_entity")
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "") meta:set_string("infotext", "Protected Armor Stand")
meta:set_string("infotext", S("Armor Stand (owned by @1)", meta:get_string("owner"))) --meta:set_string("owner", placer:get_player_name() or "")
add_hidden_node(pos, placer) --meta:set_string("infotext", "Armor Stand (owned by " ..
--meta:get_string("owner") .. ")")
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if not has_locked_armor_stand_privilege(meta, player) then
return 0
end
local def = stack:get_definition() or {} local def = stack:get_definition() or {}
local groups = def.groups or {} local groups = def.groups or {}
if groups[listname] then if groups[listname] then
if not minetest.is_protected(pos, player:get_player_name()) then
return 1 return 1
end end
end
return 0 return 0
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if not has_locked_armor_stand_privilege(meta, player) then if minetest.is_protected(pos, player:get_player_name()) then
return 0 return 0
end end
return stack:get_count() return stack:get_count()
@ -287,10 +236,15 @@ minetest.register_node("3d_armor_stand:locked_armor_stand", {
end, end,
after_destruct = function(pos) after_destruct = function(pos)
update_entity(pos) update_entity(pos)
remove_hidden_node(pos)
end, end,
on_blast = function(pos) on_blast = function(pos)
-- Not affected by TNT local object = get_stand_object(pos)
if object then
object:remove()
end
minetest.after(1, function(pos)
update_entity(pos)
end, pos)
end, end,
}) })
@ -299,7 +253,7 @@ minetest.register_entity("3d_armor_stand:armor_entity", {
visual = "mesh", visual = "mesh",
mesh = "3d_armor_entity.obj", mesh = "3d_armor_entity.obj",
visual_size = {x=1, y=1}, visual_size = {x=1, y=1},
collisionbox = {0,0,0,0,0,0}, collisionbox = {-0.1,-0.4,-0.1, 0.1,1.3,0.1},
textures = {"3d_armor_trans.png"}, textures = {"3d_armor_trans.png"},
pos = nil, pos = nil,
timer = 0, timer = 0,
@ -310,35 +264,31 @@ minetest.register_entity("3d_armor_stand:armor_entity", {
update_entity(pos) update_entity(pos)
end end
end, end,
on_blast = function(self, damage) on_step = function(self, dtime)
local drops = {} if not self.pos then
local node = minetest.get_node(self.pos) return
if node.name == "3d_armor_stand:armor_stand" then end
drop_armor(self.pos) self.timer = self.timer + dtime
if self.timer > 1 then
self.timer = 0
local pos = self.object:getpos()
if pos then
if vector.equals(vector.round(pos), self.pos) then
return
end
end
update_entity(self.pos)
self.object:remove() self.object:remove()
end end
return false, false, drops
end, end,
}) })
minetest.register_abm({
nodenames = {"3d_armor_stand:locked_armor_stand", "3d_armor_stand:armor_stand"},
interval = 15,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local num
num = #minetest.get_objects_inside_radius(pos, 0.5)
if num > 0 then return end
update_entity(pos)
end
})
minetest.register_craft({ minetest.register_craft({
output = "3d_armor_stand:armor_stand", output = "3d_armor_stand:armor_stand",
recipe = { recipe = {
{"", "group:fence", ""}, {"default:fence_wood"},
{"", "group:fence", ""}, {"default:fence_wood"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, {"default:cobble"},
} }
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -7,9 +7,8 @@ local function play_sound_effect(player, name)
if not disable_sounds and player then if not disable_sounds and player then
local pos = player:getpos() local pos = player:getpos()
if pos then if pos then
minetest.sound_play({ minetest.sound_play(name, {
pos = pos, pos = pos,
name = name,
max_hear_distance = 10, max_hear_distance = 10,
gain = 0.5, gain = 0.5,
}) })

View File

@ -0,0 +1,11 @@
shields/textures/shields_shield_wood.png:shield
shields/textures/shields_shield_enhanced_wood.png:shield
shields/textures/shields_shield_cactus.png:shield
shields/textures/shields_shield_enhanced_cactus.png:shield
shields/textures/shields_shield_steel.png:shield
shields/textures/shields_shield_bronze.png:shield
shields/textures/shields_shield_gold.png:shield
shields/textures/shields_shield_diamond.png:shield
shields/textures/shields_shield_mithril.png:shield
shields/textures/shields_shield_crystal.png:shield
shields/textures/shields_shield_admin.png:shield

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B