3 minetest
.register_node("mcl_core:ladder", {
4 description
= "Ladder",
5 _doc_items_longdesc
= "A piece of ladder which allows you to climb vertically. Ladders can only be placed on the side of solid blocks and not on glass, leaves, ice, slabs, glowstone, nor sea lanterns.",
7 is_ground_content
= false,
8 tiles
= {"default_ladder.png"},
9 inventory_image
= "default_ladder.png",
10 wield_image
= "default_ladder.png",
12 sunlight_propagates
= true,
13 paramtype2
= "wallmounted",
18 wall_side
= { -0.5, -0.5, -0.5, -7/16, 0.5, 0.5 },
22 wall_side
= { -0.5, -0.5, -0.5, -7/16, 0.5, 0.5 },
25 groups
= {handy
=1,axey
=1, attached_node
=1, deco_block
=1, dig_by_piston
=1},
26 sounds
= mcl_sounds
.node_sound_wood_defaults(),
27 node_placement_prediction
= "",
28 -- Restrict placement of ladders
29 on_place
= function(itemstack
, placer
, pointed_thing
)
30 if pointed_thing
.type ~= "node" then
31 -- no interaction possible with entities
35 local under
= pointed_thing
.under
36 local node
= minetest
.get_node(under
)
37 local def
= minetest
.registered_nodes
[node
.name
]
41 local groups
= def
.groups
43 -- Don't allow to place the ladder at particular nodes
44 if (groups
and (groups
.glass
or groups
.leaves
or groups
.slab
)) or
45 node
.name
== "mcl_core:ladder" or node
.name
== "mcl_core:ice" or node
.name
== "mcl_nether:glowstone" or node
.name
== "mcl_ocean:sea_lantern" then
49 -- Check special rightclick action of pointed node
50 if def
and def
.on_rightclick
then
51 if not placer
:get_player_control().sneak
then
52 return def
.on_rightclick(under
, node
, placer
, itemstack
,
53 pointed_thing
) or itemstack
, false
56 local above
= pointed_thing
.above
58 -- Ladders may not be placed on ceiling or floor
59 if under
.y
~= above
.y
then
62 local idef
= itemstack
:get_definition()
63 local success
= minetest
.item_place_node(itemstack
, placer
, pointed_thing
)
66 if idef
.sounds
and idef
.sounds
.place
then
67 minetest
.sound_play(idef
.sounds
.place
, {pos
=above
, gain
=1})
73 _mcl_blast_resistance
= 2,
78 minetest
.register_node("mcl_core:vine", {
79 description
= "Vines",
80 _doc_items_longdesc
= "Vines are climbable blocks which can be placed on the sides solid full-cube blocks. Vines very slowly grow upwards and downwards.",
81 drawtype
= "signlike",
82 tiles
= {"mcl_core_vine.png"},
83 inventory_image
= "mcl_core_vine.png",
84 wield_image
= "mcl_core_vine.png",
86 sunlight_propagates
= true,
87 paramtype2
= "wallmounted",
95 groups
= {handy
=1,axey
=1,shearsy
=1,swordy
=1, flammable
=2,deco_block
=1,destroy_by_lava_flow
=1,dig_by_piston
=1},
96 sounds
= mcl_sounds
.node_sound_leaves_defaults(),
98 _mcl_shears_drop
= true,
99 node_placement_prediction
= "",
100 -- Restrict placement of vines
101 on_place
= function(itemstack
, placer
, pointed_thing
)
102 if pointed_thing
.type ~= "node" then
103 -- no interaction possible with entities
107 local under
= pointed_thing
.under
108 local node
= minetest
.get_node(under
)
109 local def
= minetest
.registered_nodes
[node
.name
]
110 if not def
then return itemstack
end
111 local groups
= def
.groups
113 -- Check special rightclick action of pointed node
114 if def
and def
.on_rightclick
then
115 if not placer
:get_player_control().sneak
then
116 return def
.on_rightclick(under
, node
, placer
, itemstack
,
117 pointed_thing
) or itemstack
, false
121 -- Only place on full cubes
122 if not mcl_core
.supports_vines(node
.name
) then
126 local above
= pointed_thing
.above
128 -- Vines may not be placed on top or below another block
129 if under
.y
~= above
.y
then
132 local idef
= itemstack
:get_definition()
133 local itemstack
, success
= minetest
.item_place_node(itemstack
, placer
, pointed_thing
)
136 if idef
.sounds
and idef
.sounds
.place
then
137 minetest
.sound_play(idef
.sounds
.place
, {pos
=above
, gain
=1})
143 -- If destroyed, also a “dependant” vine below it.
144 -- A vine is dependant if it hangs from this node and has no supporting block.
145 after_destruct
= function(pos
, oldnode
)
146 local below
= {x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
}
147 local belownode
= minetest
.get_node(below
)
148 if belownode
.name
== oldnode
.name
and (not mcl_core
.check_vines_supported(below
, belownode
)) then
149 minetest
.remove_node(below
)
154 _mcl_blast_resistance
= 1,