2019-03-05 13:43:09 +03:00
|
|
|
local has_mcl_skins = minetest.get_modpath("mcl_skins") ~= nil
|
|
|
|
|
2019-03-10 03:11:29 +03:00
|
|
|
local def = minetest.registered_items[""]
|
|
|
|
|
2019-09-19 13:20:31 +03:00
|
|
|
local list
|
2019-03-05 13:43:09 +03:00
|
|
|
-- mcl_skins is enabled
|
|
|
|
if has_mcl_skins == true then
|
2019-09-19 13:20:31 +03:00
|
|
|
list = mcl_skins.list
|
2019-03-05 13:43:09 +03:00
|
|
|
else
|
2019-09-19 13:20:31 +03:00
|
|
|
list = { "hand" }
|
|
|
|
end
|
|
|
|
|
|
|
|
--generate a node for every skin
|
|
|
|
for _,texture in pairs(list) do
|
|
|
|
-- This is a fake node that should never be placed in the world
|
|
|
|
minetest.register_node("mcl_meshhand:"..texture, {
|
2019-03-05 13:43:09 +03:00
|
|
|
description = "",
|
2019-09-19 13:20:31 +03:00
|
|
|
tiles = {texture..".png"},
|
2021-02-18 16:00:17 +03:00
|
|
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false,
|
2019-03-05 13:43:09 +03:00
|
|
|
visual_scale = 1,
|
|
|
|
wield_scale = {x=1,y=1,z=1},
|
|
|
|
paramtype = "light",
|
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "mcl_meshhand.b3d",
|
2019-09-19 13:31:50 +03:00
|
|
|
-- Prevent construction
|
2019-03-05 13:43:09 +03:00
|
|
|
node_placement_prediction = "",
|
2019-09-19 13:04:41 +03:00
|
|
|
on_construct = function(pos)
|
2019-09-19 13:20:31 +03:00
|
|
|
minetest.log("error", "[mcl_meshhand] Trying to construct mcl_meshhand:"..texture.." at "..minetest.pos_to_string(pos))
|
2019-09-19 13:04:41 +03:00
|
|
|
minetest.remove_node(pos)
|
|
|
|
end,
|
2019-09-19 13:20:31 +03:00
|
|
|
drop = "",
|
|
|
|
on_drop = function()
|
|
|
|
return ""
|
|
|
|
end,
|
2019-09-19 13:04:41 +03:00
|
|
|
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
|
2019-03-10 03:11:29 +03:00
|
|
|
range = def.range,
|
2021-05-02 18:03:39 +03:00
|
|
|
_mcl_hand_id = texture,
|
|
|
|
})
|
2021-02-27 02:01:30 +03:00
|
|
|
|
|
|
|
minetest.register_node("mcl_meshhand:"..texture.. "_female", {
|
|
|
|
description = "",
|
|
|
|
tiles = {texture..".png"},
|
|
|
|
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",
|
|
|
|
mesh = "mcl_meshhand_female.b3d",
|
|
|
|
-- Prevent construction
|
|
|
|
node_placement_prediction = "",
|
|
|
|
on_construct = function(pos)
|
|
|
|
minetest.log("error", "[mcl_meshhand] Trying to construct mcl_meshhand:"..texture.." at "..minetest.pos_to_string(pos))
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
end,
|
|
|
|
drop = "",
|
|
|
|
on_drop = function()
|
|
|
|
return ""
|
|
|
|
end,
|
|
|
|
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
|
|
|
|
range = def.range,
|
2021-05-02 18:03:39 +03:00
|
|
|
_mcl_hand_id = texture .. "_female",
|
|
|
|
})
|
2019-09-19 13:20:31 +03:00
|
|
|
end
|
2019-03-05 13:43:09 +03:00
|
|
|
|
2019-09-19 13:20:31 +03:00
|
|
|
if has_mcl_skins == true then
|
|
|
|
--change the player's hand to their skin
|
|
|
|
mcl_skins.register_on_set_skin(function(player, skin)
|
2021-02-27 02:01:30 +03:00
|
|
|
local meta = mcl_skins.meta[skin]
|
|
|
|
if meta.gender == "female" then
|
|
|
|
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin.."_female")
|
|
|
|
else
|
|
|
|
player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin)
|
|
|
|
end
|
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
|