move mcl_armor_trims to mcl_armor
@ -85,6 +85,22 @@ function mcl_armor.equip_on_use(itemstack, player, pointed_thing)
|
||||
return mcl_armor.equip(itemstack, player)
|
||||
end
|
||||
|
||||
local function get_armor_texture(textures, name, modname, itemname, itemstring)
|
||||
local core_texture = textures[name] or modname .. "_" .. itemname .. ".png"
|
||||
if type(core_texture) == "function" then return core_texture end
|
||||
mcl_armor.trims.core_textures[itemstring] = core_texture
|
||||
local func = function(obj, itemstack)
|
||||
local overlay = itemstack:get_meta():get_string("mcl_armor:trim_overlay")
|
||||
local core_armor_texture = mcl_armor.trims.core_textures[itemstack:get_name()]
|
||||
|
||||
if overlay == "" then return core_armor_texture end -- key not present; armor not trimmed
|
||||
|
||||
return core_armor_texture .. overlay
|
||||
end
|
||||
|
||||
return func
|
||||
end
|
||||
|
||||
function mcl_armor.register_set(def)
|
||||
local modname = minetest.get_current_modname()
|
||||
local groups = def.groups or {}
|
||||
@ -134,7 +150,7 @@ function mcl_armor.register_set(def)
|
||||
_on_unequip = on_unequip_callbacks[name] or def.on_unequip,
|
||||
_on_break = on_break_callbacks[name] or def.on_break,
|
||||
_mcl_armor_element = name,
|
||||
_mcl_armor_texture = textures[name] or modname .. "_" .. itemname .. ".png",
|
||||
_mcl_armor_texture = get_armor_texture(textures, name, modname, itemname, itemstring),
|
||||
_mcl_upgradable = def._mcl_upgradable,
|
||||
_mcl_upgrade_item = upgrade_item
|
||||
})
|
||||
@ -255,3 +271,43 @@ function mcl_armor.update(obj)
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_armor.trim(itemstack, overlay, color_string)
|
||||
local def = itemstack:get_definition()
|
||||
if not def._mcl_armor_texture and not mcl_armor.trims.blacklisted[itemstack:get_name()] then return end
|
||||
local meta = itemstack:get_meta()
|
||||
|
||||
local piece_overlay = overlay
|
||||
local inv_overlay = ""
|
||||
local piece_type = def._mcl_armor_element
|
||||
|
||||
if piece_type == "head" then --helmet
|
||||
inv_overlay = "^(helmet_trim.png"
|
||||
piece_overlay = piece_overlay .. "_helmet"
|
||||
elseif piece_type == "torso" then --chestplate
|
||||
inv_overlay = "^(chestplate_trim.png"
|
||||
piece_overlay = piece_overlay .. "_chestplate"
|
||||
elseif piece_type == "legs" then --leggings
|
||||
inv_overlay = "^(leggings_trim.png"
|
||||
piece_overlay = piece_overlay .. "_leggings"
|
||||
elseif piece_type == "feet" then --boots
|
||||
inv_overlay = "^(boots_trim.png"
|
||||
piece_overlay = piece_overlay .. "_boots"
|
||||
end
|
||||
local color = mcl_armor.trims.colors[color_string]
|
||||
inv_overlay = inv_overlay .. "^[colorize:" .. color .. ":150)"
|
||||
piece_overlay = piece_overlay .. ".png"
|
||||
|
||||
piece_overlay = "^(" .. piece_overlay .. "^[colorize:" .. color .. ":150)"
|
||||
|
||||
meta:set_string("mcl_armor:trim_overlay" , piece_overlay) -- set textures to render on the player, will work for clients below 5.8 as well
|
||||
meta:set_string("mcl_armor:inv", inv_overlay) -- make 5.8+ clients display the fancy inv image, older ones will see no change in the *inventory* image
|
||||
meta:set_string("inventory_image", def.inventory_image .. inv_overlay) -- dont use reload_inv_image as it's a one liner in this enviorment
|
||||
end
|
||||
|
||||
function mcl_armor.reload_trim_inv_image(itemstack)
|
||||
local meta = itemstack:get_meta()
|
||||
local inv_overlay = meta:get_string("mcl_armor:inv")
|
||||
local def = itemstack:get_definition()
|
||||
if inv_overlay == "" then return end
|
||||
meta:set_string("inventory_image", def.inventory_image .. inv_overlay)
|
||||
end
|
@ -53,6 +53,12 @@ mcl_armor = {
|
||||
}
|
||||
},
|
||||
player_view_range_factors = {},
|
||||
trims = {
|
||||
core_textures = {},
|
||||
blacklisted = {["mcl_armor:elytra"]=true, ["mcl_armor:elytra_enchanted"]=true},
|
||||
overlays = {"sentry","dune","coast","wild","tide","ward","vex","rib","snout","eye","spire"},
|
||||
colors = {["amethyst"]="#8246a5",["gold"]="#ce9627",["emerald"]="#1b9958",["copper"]="#c36447",["diamond"]="#5faed8",["iron"]="#938e88",["lapis"]="#1c306b",["netherite"]="#302a26",["quartz"]="#c9bcb9",["redstone"]="#af2c23"},
|
||||
},
|
||||
}
|
||||
|
||||
local modpath = minetest.get_modpath("mcl_armor")
|
||||
@ -62,3 +68,4 @@ dofile(modpath .. "/player.lua")
|
||||
dofile(modpath .. "/damage.lua")
|
||||
dofile(modpath .. "/register.lua")
|
||||
dofile(modpath .. "/alias.lua")
|
||||
dofile(modpath .. "/trims.lua")
|
||||
|
@ -21,3 +21,6 @@ Iron Boots=Eisenstiefel
|
||||
Golden Boots=Goldstiefel
|
||||
Diamond Boots=Diamantstiefel
|
||||
Chain Boots=Kettenstiefel
|
||||
|
||||
|
||||
Smithing Template '@1'=Schiedevorlage '@1'
|
@ -37,6 +37,7 @@ Protection=
|
||||
Reduces most types of damage by 4% for each level.=
|
||||
Thorns=
|
||||
Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.=
|
||||
|
||||
Chainmail Helmet=
|
||||
Chainmail Chestplate=
|
||||
Chainmail Leggings=
|
||||
@ -51,3 +52,6 @@ Increases underwater mining speed.=
|
||||
Shooting consumes no regular arrows.=
|
||||
Shoot 3 arrows at the cost of one.=
|
||||
Aqua Affinity=
|
||||
|
||||
#Translations for armor trims
|
||||
Smithing Template '@1'=
|
||||
|
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 382 B |
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 150 B After Width: | Height: | Size: 150 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 373 B |
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 153 B After Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 165 B |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 389 B |
Before Width: | Height: | Size: 202 B After Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 237 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 162 B After Width: | Height: | Size: 162 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 340 B |
Before Width: | Height: | Size: 300 B After Width: | Height: | Size: 300 B |
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 378 B |
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
Before Width: | Height: | Size: 278 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |
@ -2,7 +2,7 @@ local modname = minetest.get_current_modname()
|
||||
local mod_registername = modname .. ":"
|
||||
local S = minetest.get_translator(modname)
|
||||
|
||||
for _, template_name in pairs(mcl_armor_trims.overlays) do
|
||||
for _, template_name in pairs(mcl_armor.trims.overlays) do
|
||||
minetest.register_craftitem(mod_registername .. template_name, {
|
||||
description = S("Smithing Template '@1'", template_name),
|
||||
inventory_image = template_name .. "_armor_trim_smithing_template.png",
|
@ -1,77 +0,0 @@
|
||||
--TODO: put this mod entirely into mcl_armor
|
||||
|
||||
mcl_armor_trims = {
|
||||
blacklisted = {["mcl_farming:pumpkin_face"]=true, ["mcl_armor:elytra"]=true, ["mcl_armor:elytra_enchanted"]=true},
|
||||
overlays = {"sentry","dune","coast","wild","tide","ward","vex","rib","snout","eye","spire"},
|
||||
colors = {["amethyst"]="#8246a5",["gold"]="#ce9627",["emerald"]="#1b9958",["copper"]="#c36447",["diamond"]="#5faed8",["iron"]="#938e88",["lapis"]="#1c306b",["netherite"]="#302a26",["quartz"]="#c9bcb9",["redstone"]="#af2c23"},
|
||||
old_textures = {}
|
||||
}
|
||||
|
||||
local function override_items()
|
||||
for itemname, itemdef in pairs(minetest.registered_tools) do
|
||||
if itemdef._mcl_armor_texture and type(itemdef._mcl_armor_texture) == "string" and not mcl_armor_trims.blacklisted[itemname] then
|
||||
mcl_armor_trims.old_textures[itemname] = itemdef._mcl_armor_texture
|
||||
minetest.override_item(itemname, {
|
||||
_mcl_armor_texture = function(obj, itemstack)
|
||||
local overlay = itemstack:get_meta():get_string("mcl_armor_trims:trim_overlay")
|
||||
local old_armor_texture = mcl_armor_trims.old_textures[itemstack:get_name()]
|
||||
if type(old_armor_texture) == "function" then
|
||||
old_armor_texture = old_armor_texture(obj, itemstack)
|
||||
end
|
||||
|
||||
if overlay == "" then -- key not present; armor not trimmed
|
||||
return old_armor_texture
|
||||
end
|
||||
|
||||
return old_armor_texture .. overlay
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mcl_armor_trims.trim(itemstack, overlay, color_string)
|
||||
local def = itemstack:get_definition()
|
||||
if not def._mcl_armor_texture and not mcl_armor_trims.blacklisted[itemstack:get_name()] then
|
||||
return
|
||||
end
|
||||
local meta = itemstack:get_meta()
|
||||
|
||||
local piece_overlay = overlay
|
||||
local inv_overlay = ""
|
||||
local piece_type = def._mcl_armor_element
|
||||
|
||||
if piece_type == "head" then --helmet
|
||||
inv_overlay = "^(helmet_trim.png"
|
||||
piece_overlay = piece_overlay .. "_helmet"
|
||||
elseif piece_type == "torso" then --chestplate
|
||||
inv_overlay = "^(chestplate_trim.png"
|
||||
piece_overlay = piece_overlay .. "_chestplate"
|
||||
elseif piece_type == "legs" then --leggings
|
||||
inv_overlay = "^(leggings_trim.png"
|
||||
piece_overlay = piece_overlay .. "_leggings"
|
||||
elseif piece_type == "feet" then --boots
|
||||
inv_overlay = "^(boots_trim.png"
|
||||
piece_overlay = piece_overlay .. "_boots"
|
||||
end
|
||||
local color = mcl_armor_trims.colors[color_string]
|
||||
inv_overlay = inv_overlay .. "^[colorize:" .. color .. ":150)"
|
||||
piece_overlay = piece_overlay .. ".png"
|
||||
|
||||
piece_overlay = "^(" .. piece_overlay .. "^[colorize:" .. color .. ":150)"
|
||||
|
||||
meta:set_string("mcl_armor_trims:trim_overlay" , piece_overlay) -- set textures to render on the player, will work for clients below 5.8 as well
|
||||
meta:set_string("mcl_armor_trims:inv", inv_overlay) -- make 5.8+ clients display the fancy inv image, older ones will see no change in the *inventory* image
|
||||
meta:set_string("inventory_image", def.inventory_image .. inv_overlay) -- dont use reload_inv_image as it's a one liner in this enviorment
|
||||
end
|
||||
|
||||
function mcl_armor_trims.reload_inv_image(itemstack)
|
||||
local meta = itemstack:get_meta()
|
||||
local inv_overlay = meta:get_string("mcl_armor_trims:inv")
|
||||
local def = itemstack:get_definition()
|
||||
if inv_overlay == "" then return end
|
||||
meta:set_string("inventory_image", def.inventory_image .. inv_overlay)
|
||||
end
|
||||
|
||||
minetest.register_on_mods_loaded(override_items)
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/templates.lua")
|
@ -1,2 +0,0 @@
|
||||
# textdomain: mcl_armor_trims
|
||||
Smithing Template '@1'=Schiedevorlage '@1'
|
@ -1,2 +0,0 @@
|
||||
# textdomain: mcl_armor_trims
|
||||
Smithing Template '@1'
|
@ -1,4 +0,0 @@
|
||||
name = mcl_armor_trims
|
||||
author = chmodsayshello
|
||||
optional_depends = mcl_armor
|
||||
depends = mcl_enchanting, mcl_core, mcl_end
|
@ -34,7 +34,7 @@ function mcl_smithing_table.upgrade_item(itemstack)
|
||||
end
|
||||
|
||||
itemstack:set_name(upgrade_item)
|
||||
mcl_armor_trims.reload_inv_image(itemstack)
|
||||
mcl_armor.reload_trim_inv_image(itemstack)
|
||||
|
||||
-- Reload the ToolTips of the tool
|
||||
|
||||
@ -90,10 +90,10 @@ function mcl_smithing_table.upgrade_trimmed(itemstack, color_mineral, template)
|
||||
local material_name = color_mineral:get_name()
|
||||
material_name = smithing_materials[material_name]
|
||||
|
||||
local overlay = template:get_name():gsub("mcl_armor_trims:","")
|
||||
local overlay = template:get_name():gsub("mcl_armor:","")
|
||||
|
||||
--trimming process
|
||||
mcl_armor_trims.trim(itemstack, overlay, material_name)
|
||||
mcl_armor.trim(itemstack, overlay, material_name)
|
||||
--itemstack:set_name(itemstack:get_name() .. "_trimmed_" .. overlay .. "_" .. material_name)
|
||||
tt.reload_itemstack_description(itemstack)
|
||||
|
||||
@ -155,13 +155,13 @@ minetest.register_node("mcl_smithing_table:table", {
|
||||
if
|
||||
listname == "upgrade_item"
|
||||
and string.find(stack:get_name(),"mcl_armor:") -- allow any armor piece to go in (in case the player wants to trim them)
|
||||
and not mcl_armor_trims.blacklisted[stack:get_name()]
|
||||
and not mcl_armor.trims.blacklisted[stack:get_name()]
|
||||
|
||||
or listname == "mineral"
|
||||
and mcl_smithing_table.is_smithing_mineral(stack:get_name())
|
||||
|
||||
or listname == "template"
|
||||
and string.find(stack:get_name(),"mcl_armor_trims")
|
||||
and string.find(stack:get_name(),"mcl_armor")
|
||||
then
|
||||
return stack:get_count()
|
||||
end
|
||||
|
@ -1,2 +1,2 @@
|
||||
name = mcl_smithing_table
|
||||
depends = mcl_colors, mcl_formspec, mcl_anvils, mcl_armor_trims
|
||||
depends = mcl_colors, mcl_formspec, mcl_armor
|
||||
|