2022-08-29 21:09:00 +03:00
|
|
|
local mcl_skins_enabled = minetest.global_exists("mcl_skins")
|
2019-03-05 13:43:09 +03:00
|
|
|
|
2022-08-29 21:09:00 +03:00
|
|
|
-- This is a fake node that should never be placed in the world
|
|
|
|
local node_def = {
|
|
|
|
description = "",
|
|
|
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
|
|
|
|
visual_scale = 1,
|
|
|
|
wield_scale = {x=1,y=1,z=1},
|
|
|
|
paramtype = "light",
|
|
|
|
drawtype = "mesh",
|
|
|
|
node_placement_prediction = "",
|
|
|
|
on_construct = function(pos)
|
|
|
|
local name = get_node(pos).name
|
|
|
|
local message = "[mcl_meshhand] Trying to construct " .. name .. " at " .. minetest.pos_to_string(pos)
|
|
|
|
minetest.log("error", message)
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
end,
|
|
|
|
drop = "",
|
|
|
|
on_drop = function() return "" end,
|
|
|
|
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
|
|
|
|
range = minetest.registered_items[""].range
|
|
|
|
}
|
2019-03-10 03:11:29 +03:00
|
|
|
|
2022-08-29 21:09:00 +03:00
|
|
|
if mcl_skins_enabled then
|
|
|
|
-- Generate a node for every skin
|
2022-09-06 20:51:43 +03:00
|
|
|
local list = mcl_skins.get_skin_list()
|
|
|
|
for _, skin in pairs(list) do
|
|
|
|
if skin.slim_arms then
|
2022-08-29 21:09:00 +03:00
|
|
|
local female = table.copy(node_def)
|
2022-09-06 20:51:43 +03:00
|
|
|
female._mcl_hand_id = skin.id
|
2022-08-29 21:09:00 +03:00
|
|
|
female.mesh = "mcl_meshhand_female.b3d"
|
2022-09-06 20:51:43 +03:00
|
|
|
female.tiles = {skin.texture}
|
|
|
|
minetest.register_node("mcl_meshhand:" .. skin.id, female)
|
|
|
|
else
|
|
|
|
local male = table.copy(node_def)
|
|
|
|
male._mcl_hand_id = skin.id
|
|
|
|
male.mesh = "mcl_meshhand.b3d"
|
|
|
|
male.tiles = {skin.texture}
|
|
|
|
minetest.register_node("mcl_meshhand:" .. skin.id, male)
|
2022-08-29 21:09:00 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
node_def._mcl_hand_id = "hand"
|
|
|
|
node_def.mesh = "mcl_meshhand.b3d"
|
|
|
|
node_def.tiles = {"character.png"}
|
|
|
|
minetest.register_node("mcl_meshhand:hand", node_def)
|
2019-09-19 13:20:31 +03:00
|
|
|
end
|
2019-03-05 13:43:09 +03:00
|
|
|
|
2022-08-29 21:09:00 +03:00
|
|
|
if mcl_skins_enabled then
|
|
|
|
-- Change the player's hand to their skin
|
|
|
|
mcl_skins.register_on_set_skin(function(player)
|
2022-09-06 20:51:43 +03:00
|
|
|
local node_id = mcl_skins.get_node_id_by_player(player)
|
2022-08-29 21:09:00 +03:00
|
|
|
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:" .. node_id)
|
2019-09-19 13:20:31 +03:00
|
|
|
end)
|
|
|
|
else
|
2019-03-05 13:43:09 +03:00
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:hand")
|
|
|
|
end)
|
|
|
|
end
|