also check amor variable while integrating with 3D Armor

This commit is contained in:
Leonard-Orlando Menzel 2024-01-22 22:38:17 +01:00 committed by GitHub
parent 8408a73851
commit 7c4ce99986
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 28 deletions

View File

@ -512,35 +512,39 @@ minetest.register_craftitem("animalia:net", {
-----------
if minetest.get_modpath("3d_armor") then
table.insert(armor.attributes, "heavy_pelt")
armor:register_armor("animalia:coat_bear_pelt", {
description = "Bear Pelt Coat",
inventory_image = "animalia_inv_coat_bear_pelt.png",
groups = {armor_torso = 1, armor_heal = 0, armor_heavy_pelt = 1, armor_use = 1000},
armor_groups = {fleshy = 5}
})
minetest.register_on_punchplayer(function(player, hitter, _, _, _, damage)
local name = player:get_player_name()
if name
and (armor.def[name].heavy_pelt or 0) > 0 then
local hit_ip = hitter:is_player()
if hit_ip and minetest.is_protected(player:get_pos(), "") then
return
else
local player_pos = player:get_pos()
if not player_pos then return end
local biome_data = minetest.get_biome_data(player_pos)
if biome_data.heat < 50 then
player:set_hp(player:get_hp() - (damage / 1.5))
return true
if amor ~= nil then
table.insert(armor.attributes, "heavy_pelt")
armor:register_armor("animalia:coat_bear_pelt", {
description = "Bear Pelt Coat",
inventory_image = "animalia_inv_coat_bear_pelt.png",
groups = {armor_torso = 1, armor_heal = 0, armor_heavy_pelt = 1, armor_use = 1000},
armor_groups = {fleshy = 5}
})
minetest.register_on_punchplayer(function(player, hitter, _, _, _, damage)
local name = player:get_player_name()
if name
and (armor.def[name].heavy_pelt or 0) > 0 then
local hit_ip = hitter:is_player()
if hit_ip and minetest.is_protected(player:get_pos(), "") then
return
else
local player_pos = player:get_pos()
if not player_pos then return end
local biome_data = minetest.get_biome_data(player_pos)
if biome_data.heat < 50 then
player:set_hp(player:get_hp() - (damage / 1.5))
return true
end
end
end
end
end)
end)
else
minetest.log("warning", "Animalia: Conflicts with other mods, couldnt properly integrate with 3D_armor")
end
end
-----------
@ -778,4 +782,4 @@ minetest.register_on_craft(function(itemstack, _, old_craft_grid)
end
end
end
end)
end)