1 local S
= minetest
.get_translator("mcl_heads")
3 local mod_doc
= minetest
.get_modpath("doc")
4 local mod_screwdriver
= minetest
.get_modpath("screwdriver")
7 if minetest
.get_modpath("mcl_armor") then
8 equip_armor
= armor
.on_armor_use
13 local function addhead(name
, texture
, desc
, longdesc
, rangemob
, rangefactor
)
14 local on_rotate_floor
, on_rotate_wall
15 if mod_screwdriver
then
16 on_rotate_floor
= function(pos
, node
, user
, mode
, new_param2
)
17 if mode
== screwdriver
.ROTATE_AXIS
then
18 node
.name
= node
.name
.. "_wall"
19 node
.param2
= minetest
.dir_to_wallmounted(minetest
.facedir_to_dir(node
.param2
))
20 minetest
.set_node(pos
, node
)
24 on_rotate_wall
= function(pos
, node
, user
, mode
, new_param2
)
25 if mode
== screwdriver
.ROTATE_AXIS
then
26 node
.name
= string.sub(node
.name
, 1, string.len(node
.name
)-5)
27 node
.param2
= minetest
.dir_to_facedir(minetest
.wallmounted_to_dir(node
.param2
))
28 minetest
.set_node(pos
, node
)
34 minetest
.register_node("mcl_heads:"..name
, {
36 _doc_items_longdesc
= longdesc
,
38 is_ground_content
= false,
42 { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, },
45 groups
= {handy
=1, armor_head
=1,non_combat_armor
=1, head
=1, deco_block
=1, dig_by_piston
=1},
46 -- The head textures are based off the textures of an actual mob.
48 -- Note: bottom texture is overlaid over top texture to get rid of possible transparency.
49 -- This is required for skeleton skull and wither skeleton skull.
50 "[combine:16x16:-4,4="..texture
, -- top
51 "([combine:16x16:-4,4="..texture
..")^([combine:16x16:-12,4="..texture
..")", -- bottom
52 "[combine:16x16:-12,0="..texture
, -- left
53 "[combine:16x16:4,0="..texture
, -- right
54 "[combine:16x16:-20,0="..texture
, -- back
55 "[combine:16x16:-4,0="..texture
, -- front
59 paramtype2
= "facedir",
60 sunlight_propagates
= true,
64 fixed
= { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, },
66 sounds
= mcl_sounds
.node_sound_defaults({
67 footstep
= {name
="default_hard_footstep", gain
=0.3}
69 on_place
= function(itemstack
, placer
, pointed_thing
)
70 if pointed_thing
.type ~= "node" then
71 -- no interaction possible with entities, for now.
75 local under
= pointed_thing
.under
76 local node
= minetest
.get_node(under
)
77 local def
= minetest
.registered_nodes
[node
.name
]
78 if not def
then return itemstack
end
80 -- Call on_rightclick if the pointed node defines it
81 if placer
and not placer
:get_player_control().sneak
then
82 if minetest
.registered_nodes
[node
.name
] and minetest
.registered_nodes
[node
.name
].on_rightclick
then
83 return minetest
.registered_nodes
[node
.name
].on_rightclick(under
, node
, placer
, itemstack
) or itemstack
87 local above
= pointed_thing
.above
88 local diff
= {x
= under
.x
- above
.x
, y
= under
.y
- above
.y
, z
= under
.z
- above
.z
}
89 local wdir
= minetest
.dir_to_wallmounted(diff
)
91 local itemstring
= itemstack
:get_name()
92 local fakestack
= ItemStack(itemstack
)
93 local idef
= fakestack
:get_definition()
95 if wdir
== 0 or wdir
== 1 then
96 return minetest
.item_place(itemstack
, placer
, pointed_thing
)
98 retval
= fakestack
:set_name("mcl_heads:"..name
.."_wall")
105 itemstack
, success
= minetest
.item_place(fakestack
, placer
, pointed_thing
, wdir
)
106 itemstack
:set_name(itemstring
)
109 on_secondary_use
= equip_armor
,
111 on_rotate
= on_rotate_floor
,
113 _mcl_armor_mob_range_mob
= rangemob
,
114 _mcl_armor_mob_range_factor
= rangefactor
,
115 _mcl_blast_resistance
= 1,
119 minetest
.register_node("mcl_heads:"..name
.."_wall", {
120 _doc_items_create_entry
= false,
121 drawtype
= "nodebox",
122 is_ground_content
= false,
124 type = "wallmounted",
125 wall_bottom
= { -0.25, -0.5, -0.25, 0.25, 0.0, 0.25, },
126 wall_top
= { -0.25, 0.0, -0.25, 0.25, 0.5, 0.25, },
127 wall_side
= { -0.5, -0.25, -0.25, 0.0, 0.25, 0.25, },
129 groups
= {handy
=1, head
=1, deco_block
=1, dig_by_piston
=1, not_in_creative_inventory
=1},
130 -- The head textures are based off the textures of an actual mob.
132 { name
= "[combine:16x16:-4,-4="..texture
, align_style
= "world" }, -- front
133 { name
= "[combine:16x16:-20,-4="..texture
, align_style
= "world" }, -- back
134 { name
= "[combine:16x16:-8,-4="..texture
, align_style
= "world" }, -- left
135 { name
= "[combine:16x16:0,-4="..texture
, align_style
= "world" }, -- right
136 { name
= "([combine:16x16:-4,0="..texture
..")^[transformR180", align_style
= "node" }, -- top
137 { name
= "([combine:16x16:-4,8="..texture
..")^([combine:16x16:-12,8="..texture
..")", align_style
= "node" }, -- bottom
141 paramtype2
= "wallmounted",
142 sunlight_propagates
= true,
144 sounds
= mcl_sounds
.node_sound_defaults({
145 footstep
= {name
="default_hard_footstep", gain
=0.3}
147 drop
= "mcl_heads:"..name
,
148 on_rotate
= on_rotate_wall
,
149 _mcl_blast_resistance
= 1,
154 doc
.add_entry_alias("nodes", "mcl_heads:" .. name
, "nodes", "mcl_heads:" .. name
.. "_wall")
159 addhead("zombie", "mcl_heads_zombie_node.png", S("Zombie Head"), S("A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet, which reduces the detection range of zombies by 50%."), "mobs_mc:zombie", 0.5)
160 addhead("creeper", "mcl_heads_creeper_node.png", S("Creeper Head"), S("A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet, which reduces the detection range of creepers by 50%."), "mobs_mc:creeper", 0.5)
161 -- Original Minecraft name: “Head”
162 addhead("steve", "mcl_heads_steve_node.png", S("Human Head"), S("A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection."))
163 addhead("skeleton", "mcl_heads_skeleton_node.png", S("Skeleton Skull"), S("A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet, which reduces the detection range of skeletons by 50%."), "mobs_mc:skeleton", 0.5)
164 addhead("wither_skeleton", "mcl_heads_wither_skeleton_node.png", S("Wither Skeleton Skull"), S("A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection."))