2017-07-07 14:52:28 +00:00
-- Climbable nodes
2019-03-07 22:40:43 +00:00
local S = minetest.get_translator ( " mcl_core " )
2017-07-07 14:52:28 +00:00
2019-12-09 16:51:35 +00:00
local rotate_climbable = function ( pos , node , user , mode )
if mode == screwdriver.ROTATE_FACE then
local r = screwdriver.rotate . wallmounted ( pos , node , mode )
node.param2 = r
minetest.swap_node ( pos , node )
return true
end
return false
end
2017-07-07 14:52:28 +00:00
minetest.register_node ( " mcl_core:ladder " , {
2019-03-07 22:40:43 +00:00
description = S ( " Ladder " ) ,
_doc_items_longdesc = S ( " 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. " ) ,
2017-07-07 14:52:28 +00:00
drawtype = " signlike " ,
is_ground_content = false ,
tiles = { " default_ladder.png " } ,
inventory_image = " default_ladder.png " ,
wield_image = " default_ladder.png " ,
paramtype = " light " ,
sunlight_propagates = true ,
paramtype2 = " wallmounted " ,
walkable = true ,
climbable = true ,
node_box = {
type = " wallmounted " ,
wall_side = { - 0.5 , - 0.5 , - 0.5 , - 7 / 16 , 0.5 , 0.5 } ,
} ,
selection_box = {
type = " wallmounted " ,
wall_side = { - 0.5 , - 0.5 , - 0.5 , - 7 / 16 , 0.5 , 0.5 } ,
} ,
stack_max = 64 ,
groups = { handy = 1 , axey = 1 , attached_node = 1 , deco_block = 1 , dig_by_piston = 1 } ,
sounds = mcl_sounds.node_sound_wood_defaults ( ) ,
node_placement_prediction = " " ,
-- Restrict placement of ladders
on_place = function ( itemstack , placer , pointed_thing )
if pointed_thing.type ~= " node " then
-- no interaction possible with entities
return itemstack
end
local under = pointed_thing.under
local node = minetest.get_node ( under )
local def = minetest.registered_nodes [ node.name ]
if not def then
return itemstack
end
local groups = def.groups
-- Don't allow to place the ladder at particular nodes
if ( groups and ( groups.glass or groups.leaves or groups.slab ) ) or
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
return itemstack
end
-- Check special rightclick action of pointed node
if def and def.on_rightclick then
if not placer : get_player_control ( ) . sneak then
return def.on_rightclick ( under , node , placer , itemstack ,
pointed_thing ) or itemstack , false
end
end
local above = pointed_thing.above
-- Ladders may not be placed on ceiling or floor
if under.y ~= above.y then
return itemstack
end
local idef = itemstack : get_definition ( )
local success = minetest.item_place_node ( itemstack , placer , pointed_thing )
if success then
if idef.sounds and idef.sounds . place then
2020-04-06 22:55:45 +00:00
minetest.sound_play ( idef.sounds . place , { pos = above , gain = 1 } , true )
2017-07-07 14:52:28 +00:00
end
end
return itemstack
end ,
2020-04-15 11:27:29 +00:00
_mcl_blast_resistance = 0.4 ,
2017-07-07 14:52:28 +00:00
_mcl_hardness = 0.4 ,
2019-12-09 16:51:35 +00:00
on_rotate = rotate_climbable ,
2017-07-07 14:52:28 +00:00
} )
minetest.register_node ( " mcl_core:vine " , {
2019-03-07 22:40:43 +00:00
description = S ( " Vines " ) ,
2019-03-09 02:58:41 +00:00
_doc_items_longdesc = S ( " Vines are climbable blocks which can be placed on the sides of solid full-cube blocks. Vines slowly grow and spread. " ) ,
2017-07-07 14:52:28 +00:00
drawtype = " signlike " ,
tiles = { " mcl_core_vine.png " } ,
inventory_image = " mcl_core_vine.png " ,
wield_image = " mcl_core_vine.png " ,
paramtype = " light " ,
sunlight_propagates = true ,
paramtype2 = " wallmounted " ,
walkable = false ,
climbable = true ,
buildable_to = true ,
selection_box = {
type = " wallmounted " ,
} ,
stack_max = 64 ,
2020-04-18 21:24:42 +00:00
groups = { handy = 1 , axey = 1 , shearsy = 1 , swordy = 1 , flammable = 2 , deco_block = 1 , destroy_by_lava_flow = 1 , dig_by_piston = 1 , fire_encouragement = 15 , fire_flammability = 100 } ,
2017-07-07 14:52:28 +00:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
drop = " " ,
2017-08-03 00:27:55 +00:00
_mcl_shears_drop = true ,
2017-07-07 14:52:28 +00:00
node_placement_prediction = " " ,
-- Restrict placement of vines
on_place = function ( itemstack , placer , pointed_thing )
if pointed_thing.type ~= " node " then
-- no interaction possible with entities
return itemstack
end
local under = pointed_thing.under
local node = minetest.get_node ( under )
local def = minetest.registered_nodes [ node.name ]
if not def then return itemstack end
-- Check special rightclick action of pointed node
if def and def.on_rightclick then
if not placer : get_player_control ( ) . sneak then
return def.on_rightclick ( under , node , placer , itemstack ,
pointed_thing ) or itemstack , false
end
end
-- Only place on full cubes
if not mcl_core.supports_vines ( node.name ) then
2017-11-02 22:21:04 +00:00
return itemstack
2017-07-07 14:52:28 +00:00
end
local above = pointed_thing.above
-- Vines may not be placed on top or below another block
if under.y ~= above.y then
return itemstack
end
local idef = itemstack : get_definition ( )
local itemstack , success = minetest.item_place_node ( itemstack , placer , pointed_thing )
if success then
if idef.sounds and idef.sounds . place then
2020-04-06 22:55:45 +00:00
minetest.sound_play ( idef.sounds . place , { pos = above , gain = 1 } , true )
2017-07-07 14:52:28 +00:00
end
end
return itemstack
end ,
2019-02-22 05:08:48 +00:00
-- If dug, also dig a “dependant” vine below it.
2017-08-12 02:11:07 +00:00
-- A vine is dependant if it hangs from this node and has no supporting block.
2019-02-22 05:08:48 +00:00
on_dig = function ( pos , node , digger )
2017-08-12 02:11:07 +00:00
local below = { x = pos.x , y = pos.y - 1 , z = pos.z }
local belownode = minetest.get_node ( below )
2019-02-22 05:08:48 +00:00
minetest.node_dig ( pos , node , digger )
if belownode.name == node.name and ( not mcl_core.check_vines_supported ( below , belownode ) ) then
minetest.registered_nodes [ node.name ] . on_dig ( below , node , digger )
2017-08-12 02:11:07 +00:00
end
end ,
2017-07-07 14:52:28 +00:00
2020-04-15 11:27:29 +00:00
_mcl_blast_resistance = 0.2 ,
2017-07-07 14:52:28 +00:00
_mcl_hardness = 0.2 ,
2019-12-09 16:51:35 +00:00
on_rotate = false ,
2017-07-07 14:52:28 +00:00
} )