<commit_before>local armors_no_shields = { ["3d_armor:helmet_hardenedleather"] = true,["3d_armor:chestplate_hardenedleather"] = true,
							["3d_armor:leggings_hardenedleather"] = true,["3d_armor:boots_hardenedleather"] = true,
							["3d_armor:helmet_reinforcedleather"] = true,["3d_armor:chestplate_reinforcedleather"] = true,
							["3d_armor:leggings_reinforcedleather"] = true,["3d_armor:boots_reinforcedleather"] = true,
} -- modif MFF (crabman/24/06/2015)


ARMOR_INIT_DELAY = 1
ARMOR_INIT_TIMES = 1
ARMOR_BONES_DELAY = 1
ARMOR_UPDATE_TIME = 1
ARMOR_DROP = minetest.get_modpath("bones") ~= nil
ARMOR_DESTROY = false
ARMOR_LEVEL_MULTIPLIER = 1
ARMOR_HEAL_MULTIPLIER = 1
ARMOR_RADIATION_MULTIPLIER = 1
ARMOR_MATERIALS = {
	wood = "group:wood",
	cactus = "default:cactus",
	steel = "default:steel_ingot",
	bronze = "default:bronze_ingot",
	diamond = "default:diamond",
	gold = "default:gold_ingot",
	mithril = "default:mithril_ingot",
	crystal = "ethereal:crystal_ingot",
	-- Hunter armors (A déc-ommenter quand activation de l'armure au total)
	hardenedleather = "3d_armor:hardenedleather",
	reinforcedleather = "3d_armor:reinforcedleather",
	-- Warrior armors
	blackmithril = "3d_armor:blackmithril_ingot"
	-- Wizard armors
	--armor = "xxx",
	--armor = "xxx",
}
ARMOR_FIRE_PROTECT = minetest.get_modpath("ethereal") ~= nil
ARMOR_FIRE_NODES = {
	{"default:lava_source",     5, 8},
	{"default:lava_flowing",    5, 8},
	{"fire:basic_flame",        3, 4},
	{"fire:permanent_flame",    3, 4},
	{"ethereal:crystal_spike",  2, 1},
	{"ethereal:fire_flower",    2, 1},
	{"default:torch",           1, 1},
}

local skin_mod = nil
local inv_mod = nil

local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
local worldpath = minetest.get_worldpath()
local input = io.open(modpath.."/armor.conf", "r")
if input then
	dofile(modpath.."/armor.conf")
	input:close()
	input = nil
end
input = io.open(worldpath.."/armor.conf", "r")
if input then
	dofile(worldpath.."/armor.conf")
	input:close()
	input = nil
end
if not minetest.get_modpath("ethereal") then
	ARMOR_MATERIALS.crystal = nil
end

armor = {
	timer = 0,
	elements = {"head", "torso", "legs", "feet"},
	physics = {"jump","speed","gravity"},
	formspec = "size[8,8.5]image[2,0.75;2,4;armor_preview]"
		.."list[current_player;main;0,4.5;8,4;]"
		.."list[current_player;craft;4,1;3,3;]"
		.."list[current_player;craftpreview;7,2;1,1;]"
		.."listring[current_player;main]"
		.."listring[current_player;craft]",
	textures = {},
	default_skin = "character",
	version = "0.4.5",
}

if minetest.get_modpath("inventory_plus") then
	inv_mod = "inventory_plus"
	armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
		.."image[2.5,0.75;2,4;armor_preview]"
		.."label[5,1;Level: armor_level]"
		.."label[5,1.5;Heal:  armor_heal]"
		.."label[5,2;Fire:  armor_fire]"
		.."label[5,2.5;Radiation:  armor_radiation]"
		.."list[current_player;main;0,4.5;8,4;]"
	if minetest.get_modpath("crafting") then
		inventory_plus.get_formspec = function(player, page)
		end
	end
elseif minetest.get_modpath("unified_inventory") then
	inv_mod = "unified_inventory"
	unified_inventory.register_button("armor", {
		type = "image",
		image = "inventory_plus_armor.png",
		tooltip = "Armor inventory",
		show_with = false, --Modif MFF (Crabman 30/06/2015)
	})
	unified_inventory.register_page("armor", {
		get_formspec = function(player, perplayer_formspec)
			local fy = perplayer_formspec.formspec_y
			local name = player:get_player_name()
			local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"
				.."label[0,0;Armor]"
				.."list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"
				.."image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"
				.."label[5.0,"..(fy + 0.0)..";Level: "..armor.def[name].level.."]"
				.."label[5.0,"..(fy + 0.5)..";Heal:  "..armor.def[name].heal.."]"
				.."label[5.0,"..(fy + 1.0)..";Fire:  "..armor.def[name].fire.."]"
				.."label[5.0,"..(fy + 1.5)..";Radiation:  "..armor.def[name].radiation.."]"
				.."listring[current_player;main]"
				.."listring[detached:"..name.."_armor;armor]"
			return {formspec=formspec}
		end,
	})
elseif minetest.get_modpath("inventory_enhanced") then
	inv_mod = "inventory_enhanced"
end

if minetest.get_modpath("skins") then
	skin_mod = "skins"
elseif minetest.get_modpath("simple_skins") then
	skin_mod = "simple_skins"
elseif minetest.get_modpath("u_skins") then
	skin_mod = "u_skins"
elseif minetest.get_modpath("wardrobe") then
	skin_mod = "wardrobe"
end

armor.def = {
	state = 0,
	count = 0,
}

armor.update_player_visuals = function(self, player)
	if not player then
		return
	end
	local name = player:get_player_name()
	if self.textures[name] then
		default.player_set_textures(player, {
			self.textures[name].skin,
			self.textures[name].armor,
			self.textures[name].wielditem,
		})
	end
end

armor.set_player_armor = function(self, player)
	local name, player_inv = armor:get_valid_player(player, "[set_player_armor]")
	if not name then
		return
	end
	local armor_texture = "3d_armor_trans.png"
	local armor_level = 0
	local armor_heal = 0
	local armor_fire = 0
	local armor_water = 0
	local armor_radiation = 0
	local state = 0
	local items = 0
	local elements = {}
	local textures = {}
	local physics_o = {speed=1,gravity=1,jump=1}
	local material = {type=nil, count=1}
	local preview = ""
	for _,v in ipairs(self.elements) do
		elements[v] = false
	end
	for i=1, 6 do
		local stack = player_inv:get_stack("armor", i)
		local item = stack:get_name()
		if stack:get_count() == 1 then
			local def = stack:get_definition()
			for k, v in pairs(elements) do
				if v == false then
					local level = def.groups["armor_"..k]
					if level then
						local texture = item:gsub("%:", "_")
						table.insert(textures, texture..".png")
						if preview == "" then
							preview = texture .. "_preview.png"
						elseif stack:get_name():find("shield") then -- //MFF(Mg|09/05/15)
							preview = preview.. "^" .. texture.."_preview.png"
						else
							preview = texture .. "_preview.png^" .. preview
						end
						armor_level = armor_level + level
						state = state + stack:get_wear()
						items = items + 1
						armor_heal = armor_heal + (def.groups["armor_heal"] or 0)
						armor_fire = armor_fire + (def.groups["armor_fire"] or 0)
						armor_water = armor_water + (def.groups["armor_water"] or 0)
						armor_radiation = armor_radiation + (def.groups["armor_radiation"] or 0)
						for kk,vv in ipairs(self.physics) do
							local o_value = def.groups["physics_"..vv]
							if o_value then
								physics_o[vv] = physics_o[vv] + o_value
							end
						end
						local mat = string.match(item, "%:.+_(.+)$")
						if material.type then
							if material.type == mat then
								material.count = material.count + 1
							end
						else<commit_msg>fix previews of enchanted armor with xdecor<commit_after>local armors_no_shields = { ["3d_armor:helmet_hardenedleather"] = true,["3d_armor:chestplate_hardenedleather"] = true,
							["3d_armor:leggings_hardenedleather"] = true,["3d_armor:boots_hardenedleather"] = true,
							["3d_armor:helmet_reinforcedleather"] = true,["3d_armor:chestplate_reinforcedleather"] = true,
							["3d_armor:leggings_reinforcedleather"] = true,["3d_armor:boots_reinforcedleather"] = true,
} -- modif MFF (crabman/24/06/2015)


ARMOR_INIT_DELAY = 1
ARMOR_INIT_TIMES = 1
ARMOR_BONES_DELAY = 1
ARMOR_UPDATE_TIME = 1
ARMOR_DROP = minetest.get_modpath("bones") ~= nil
ARMOR_DESTROY = false
ARMOR_LEVEL_MULTIPLIER = 1
ARMOR_HEAL_MULTIPLIER = 1
ARMOR_RADIATION_MULTIPLIER = 1
ARMOR_MATERIALS = {
	wood = "group:wood",
	cactus = "default:cactus",
	steel = "default:steel_ingot",
	bronze = "default:bronze_ingot",
	diamond = "default:diamond",
	gold = "default:gold_ingot",
	mithril = "default:mithril_ingot",
	crystal = "ethereal:crystal_ingot",
	-- Hunter armors (A déc-ommenter quand activation de l'armure au total)
	hardenedleather = "3d_armor:hardenedleather",
	reinforcedleather = "3d_armor:reinforcedleather",
	-- Warrior armors
	blackmithril = "3d_armor:blackmithril_ingot"
	-- Wizard armors
	--armor = "xxx",
	--armor = "xxx",
}
ARMOR_FIRE_PROTECT = minetest.get_modpath("ethereal") ~= nil
ARMOR_FIRE_NODES = {
	{"default:lava_source",     5, 8},
	{"default:lava_flowing",    5, 8},
	{"fire:basic_flame",        3, 4},
	{"fire:permanent_flame",    3, 4},
	{"ethereal:crystal_spike",  2, 1},
	{"ethereal:fire_flower",    2, 1},
	{"default:torch",           1, 1},
}

local skin_mod = nil
local inv_mod = nil

local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
local worldpath = minetest.get_worldpath()
local input = io.open(modpath.."/armor.conf", "r")
if input then
	dofile(modpath.."/armor.conf")
	input:close()
	input = nil
end
input = io.open(worldpath.."/armor.conf", "r")
if input then
	dofile(worldpath.."/armor.conf")
	input:close()
	input = nil
end
if not minetest.get_modpath("ethereal") then
	ARMOR_MATERIALS.crystal = nil
end

armor = {
	timer = 0,
	elements = {"head", "torso", "legs", "feet"},
	physics = {"jump","speed","gravity"},
	formspec = "size[8,8.5]image[2,0.75;2,4;armor_preview]"
		.."list[current_player;main;0,4.5;8,4;]"
		.."list[current_player;craft;4,1;3,3;]"
		.."list[current_player;craftpreview;7,2;1,1;]"
		.."listring[current_player;main]"
		.."listring[current_player;craft]",
	textures = {},
	default_skin = "character",
	version = "0.4.5",
}

if minetest.get_modpath("inventory_plus") then
	inv_mod = "inventory_plus"
	armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
		.."image[2.5,0.75;2,4;armor_preview]"
		.."label[5,1;Level: armor_level]"
		.."label[5,1.5;Heal:  armor_heal]"
		.."label[5,2;Fire:  armor_fire]"
		.."label[5,2.5;Radiation:  armor_radiation]"
		.."list[current_player;main;0,4.5;8,4;]"
	if minetest.get_modpath("crafting") then
		inventory_plus.get_formspec = function(player, page)
		end
	end
elseif minetest.get_modpath("unified_inventory") then
	inv_mod = "unified_inventory"
	unified_inventory.register_button("armor", {
		type = "image",
		image = "inventory_plus_armor.png",
		tooltip = "Armor inventory",
		show_with = false, --Modif MFF (Crabman 30/06/2015)
	})
	unified_inventory.register_page("armor", {
		get_formspec = function(player, perplayer_formspec)
			local fy = perplayer_formspec.formspec_y
			local name = player:get_player_name()
			local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"
				.."label[0,0;Armor]"
				.."list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"
				.."image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"
				.."label[5.0,"..(fy + 0.0)..";Level: "..armor.def[name].level.."]"
				.."label[5.0,"..(fy + 0.5)..";Heal:  "..armor.def[name].heal.."]"
				.."label[5.0,"..(fy + 1.0)..";Fire:  "..armor.def[name].fire.."]"
				.."label[5.0,"..(fy + 1.5)..";Radiation:  "..armor.def[name].radiation.."]"
				.."listring[current_player;main]"
				.."listring[detached:"..name.."_armor;armor]"
			return {formspec=formspec}
		end,
	})
elseif minetest.get_modpath("inventory_enhanced") then
	inv_mod = "inventory_enhanced"
end

if minetest.get_modpath("skins") then
	skin_mod = "skins"
elseif minetest.get_modpath("simple_skins") then
	skin_mod = "simple_skins"
elseif minetest.get_modpath("u_skins") then
	skin_mod = "u_skins"
elseif minetest.get_modpath("wardrobe") then
	skin_mod = "wardrobe"
end

armor.def = {
	state = 0,
	count = 0,
}

armor.update_player_visuals = function(self, player)
	if not player then
		return
	end
	local name = player:get_player_name()
	if self.textures[name] then
		default.player_set_textures(player, {
			self.textures[name].skin,
			self.textures[name].armor,
			self.textures[name].wielditem,
		})
	end
end

armor.set_player_armor = function(self, player)
	local name, player_inv = armor:get_valid_player(player, "[set_player_armor]")
	if not name then
		return
	end
	local armor_texture = "3d_armor_trans.png"
	local armor_level = 0
	local armor_heal = 0
	local armor_fire = 0
	local armor_water = 0
	local armor_radiation = 0
	local state = 0
	local items = 0
	local elements = {}
	local textures = {}
	local physics_o = {speed=1,gravity=1,jump=1}
	local material = {type=nil, count=1}
	local preview = ""
	for _,v in ipairs(self.elements) do
		elements[v] = false
	end
	for i=1, 6 do
		local stack = player_inv:get_stack("armor", i)
		local item = stack:get_name()
		if stack:get_count() == 1 then
			local def = stack:get_definition()
			for k, v in pairs(elements) do
				if v == false then
					local level = def.groups["armor_"..k]
					if level then
						local texture = item:gsub("%:", "_")
						if texture:find("enchanted") then --MFF xdecor enchanting preview fix
							texture = texture:gsub("_enchanted", "")
							texture = texture:gsub("_strong", "")
							texture = texture:gsub("_speed", "")
						end
						table.insert(textures, texture..".png")
						if preview == "" then
							preview = texture .. "_preview.png"
						elseif stack:get_name():find("shield") then -- //MFF(Mg|09/05/15)
							preview = preview.. "^" .. texture.."_preview.png"
						else
							preview = texture .. "_preview.png^" .. preview
						end
						armor_level = armor_level + level
						state = state + stack:get_wear()
						items = items + 1
						armor_heal = armor_heal + (def.groups["armor_heal"] or 0)
						armor_fire = armor_fire + (def.groups["armor_fire"] or 0)
						armor_water = armor_water + (def.groups["armor_water"] or 0)
						armor_radiation = armor_radiation + (def.groups["armor_radiation"] or 0)
						for kk,vv in ipairs(self.physics) do
							local o_value = def.groups["physics_"..vv]
							if o_value then
								physics_o[vv] = physics_o[vv] + o_value
							end
						end
						local mat = string.match(item, "%:.+_(.+)$")
						if material.type then
							if material.type == mat then
								material.count = material.count + 1
							end
						else
{'fraction_non_alphanumeric': 0.16376884784647572, 'fraction_numerical': 0.02467354447731044, 'mean_word_length': 4.0646693459992695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6937935', 'n_tokens_mistral': 6265, 'n_tokens_neox': 5418, 'n_words': 968}