mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-24 20:03:45 +01:00
Merge pull request 'Update trapdoor climbable behavior' (#3938) from Dehydrate6684/MineClone2:trapdoor-ladder into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3938 Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
This commit is contained in:
commit
fdf823fff6
@ -11,9 +11,36 @@ local function rotate_climbable(pos, node, user, mode)
|
||||
return false
|
||||
end
|
||||
|
||||
---Updates the trapdoor above (if any).
|
||||
---
|
||||
---@param pos mt.Vector The position of the ladder.
|
||||
---@param event "place" | "destruct" The place or destruct event.
|
||||
function mcl_core.update_trapdoor(pos, event)
|
||||
local top_pos = vector.offset(pos, 0, 1, 0)
|
||||
local top_node = minetest.get_node_or_nil(top_pos)
|
||||
|
||||
if top_node and minetest.get_item_group(top_node.name, "trapdoor") == 2 then
|
||||
local new_name = top_node.name
|
||||
if event == "place" then
|
||||
new_name = string.gsub(new_name, "open$", "ladder")
|
||||
elseif event == "destruct" then
|
||||
new_name = string.gsub(new_name, "ladder$", "open")
|
||||
end
|
||||
|
||||
-- If node above is an opened trapdoor
|
||||
minetest.swap_node(top_pos, {
|
||||
name = new_name,
|
||||
param1 = top_node.param1,
|
||||
param2 = top_node.param2,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: Move ladders into their own API.
|
||||
minetest.register_node("mcl_core:ladder", {
|
||||
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."),
|
||||
_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."),
|
||||
drawtype = "signlike",
|
||||
is_ground_content = false,
|
||||
tiles = { "default_ladder.png" },
|
||||
@ -33,7 +60,14 @@ minetest.register_node("mcl_core:ladder", {
|
||||
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},
|
||||
groups = {
|
||||
handy = 1,
|
||||
axey = 1,
|
||||
attached_node = 1,
|
||||
deco_block = 1,
|
||||
dig_by_piston = 1,
|
||||
ladder = 1
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_wood_defaults(),
|
||||
node_placement_prediction = "",
|
||||
-- Restrict placement of ladders
|
||||
@ -80,7 +114,12 @@ minetest.register_node("mcl_core:ladder", {
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
after_destruct = function(pos, old)
|
||||
mcl_core.update_trapdoor(pos, "destruct")
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
mcl_core.update_trapdoor(pos, "place")
|
||||
end,
|
||||
_mcl_blast_resistance = 0.4,
|
||||
_mcl_hardness = 0.4,
|
||||
on_rotate = rotate_climbable,
|
||||
@ -89,7 +128,8 @@ minetest.register_node("mcl_core:ladder", {
|
||||
|
||||
minetest.register_node("mcl_core:vine", {
|
||||
description = S("Vines"),
|
||||
_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."),
|
||||
_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."),
|
||||
drawtype = "signlike",
|
||||
tiles = { "mcl_core_vine.png" },
|
||||
color = "#48B518",
|
||||
@ -107,9 +147,19 @@ minetest.register_node("mcl_core:vine", {
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {
|
||||
handy = 1, axey = 1, shearsy = 1, swordy = 1, deco_block = 1,
|
||||
dig_by_piston = 1, destroy_by_lava_flow = 1, compostability = 50,
|
||||
flammable = 2, fire_encouragement = 15, fire_flammability = 100, foliage_palette_wallmounted = 1
|
||||
handy = 1,
|
||||
axey = 1,
|
||||
shearsy = 1,
|
||||
swordy = 1,
|
||||
deco_block = 1,
|
||||
dig_by_piston = 1,
|
||||
destroy_by_lava_flow = 1,
|
||||
compostability = 50,
|
||||
flammable = 2,
|
||||
fire_encouragement = 15,
|
||||
fire_flammability = 100,
|
||||
foliage_palette_wallmounted = 1,
|
||||
ladder = 1
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
drop = "",
|
||||
@ -181,6 +231,12 @@ minetest.register_node("mcl_core:vine", {
|
||||
minetest.registered_nodes[node.name].on_dig(below, node, digger)
|
||||
end
|
||||
end,
|
||||
after_destruct = function(pos, old)
|
||||
mcl_core.update_trapdoor(pos, "destruct")
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
mcl_core.update_trapdoor(pos, "place")
|
||||
end,
|
||||
|
||||
|
||||
_mcl_blast_resistance = 0.2,
|
||||
|
@ -72,7 +72,18 @@ function mcl_doors:register_trapdoor(name, def)
|
||||
-- Open
|
||||
else
|
||||
minetest.sound_play(def.sound_open, { pos = pos, gain = 0.3, max_hear_distance = 16 }, true)
|
||||
tmp_node = {name=name.."_open", param1=me.param1, param2=me.param2}
|
||||
|
||||
local bottom_node = minetest.get_node_or_nil(vector.offset(pos, 0, -1, 0))
|
||||
local name_end = "_open"
|
||||
|
||||
-- Checking if there is something underneath the trapdoor
|
||||
if bottom_node then
|
||||
local is_ladder = minetest.get_item_group(bottom_node.name, "ladder")
|
||||
if is_ladder > 0 then
|
||||
name_end = "_ladder"
|
||||
end
|
||||
end
|
||||
tmp_node = { name = name .. name_end, param1 = me.param1, param2 = me.param2 }
|
||||
end
|
||||
minetest.set_node(pos, tmp_node)
|
||||
end
|
||||
@ -89,9 +100,11 @@ function mcl_doors:register_trapdoor(name, def)
|
||||
longdesc = def._doc_items_longdesc
|
||||
if not longdesc then
|
||||
if def.only_redstone_can_open then
|
||||
longdesc = S("Trapdoors are horizontal barriers which can be opened or closed and climbed like a ladder when open. They occupy the upper or lower part of a block, depending on how they have been placed. This trapdoor can only be opened or closed by redstone power.")
|
||||
longdesc = S(
|
||||
"Trapdoors are horizontal barriers which can be opened or closed and climbed like a ladder when open. They occupy the upper or lower part of a block, depending on how they have been placed. This trapdoor can only be opened or closed by redstone power.")
|
||||
else
|
||||
longdesc = S("Trapdoors are horizontal barriers which can be opened or closed and climbed like a ladder when open. They occupy the upper or lower part of a block, depending on how they have been placed. This trapdoor can be opened or closed by hand or redstone power.")
|
||||
longdesc = S(
|
||||
"Trapdoors are horizontal barriers which can be opened or closed and climbed like a ladder when open. They occupy the upper or lower part of a block, depending on how they have been placed. This trapdoor can be opened or closed by hand or redstone power.")
|
||||
end
|
||||
end
|
||||
usagehelp = def._doc_items_usagehelp
|
||||
@ -128,7 +141,7 @@ function mcl_doors:register_trapdoor(name, def)
|
||||
_doc_items_usagehelp = usagehelp,
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_closed,
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
use_texture_alpha = "clip",
|
||||
inventory_image = def.inventory_image,
|
||||
wield_image = def.wield_image,
|
||||
is_ground_content = false,
|
||||
@ -145,11 +158,13 @@ function mcl_doors:register_trapdoor(name, def)
|
||||
fixed = {
|
||||
{ -8 / 16, -8 / 16, -8 / 16, 8 / 16, -5 / 16, 8 / 16 }, },
|
||||
},
|
||||
mesecons = {effector = {
|
||||
mesecons = {
|
||||
effector = {
|
||||
action_on = (function(pos, node)
|
||||
punch(pos)
|
||||
end),
|
||||
}},
|
||||
}
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local p0 = pointed_thing.under
|
||||
local p1 = pointed_thing.above
|
||||
@ -193,16 +208,44 @@ function mcl_doors:register_trapdoor(name, def)
|
||||
|
||||
groups_open.trapdoor = 2
|
||||
groups_open.not_in_creative_inventory = 1
|
||||
-- Non-climbable opened
|
||||
minetest.register_node(name .. "_open", {
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_open,
|
||||
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
|
||||
use_texture_alpha = "clip",
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
pointable = true,
|
||||
groups = groups_open,
|
||||
_mcl_hardness = def._mcl_hardness,
|
||||
_mcl_blast_resistance = def._mcl_blast_resistance,
|
||||
sounds = def.sounds,
|
||||
drop = name,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, 5 / 16, 0.5, 0.5, 0.5 }
|
||||
},
|
||||
on_rightclick = on_rightclick,
|
||||
mesecons = {
|
||||
effector = {
|
||||
action_off = (function(pos, node)
|
||||
punch(pos)
|
||||
end),
|
||||
}
|
||||
},
|
||||
on_rotate = on_rotate,
|
||||
})
|
||||
|
||||
-- Climbable opened
|
||||
minetest.register_node(name .. "_ladder", {
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_open,
|
||||
use_texture_alpha = "clip",
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
-- TODO: Implement Minecraft behaviour: Climbable if directly above
|
||||
-- ladder w/ matching orientation.
|
||||
-- Current behavour: Always climbable
|
||||
climbable = true,
|
||||
sunlight_propagates = true,
|
||||
pointable = true,
|
||||
@ -216,16 +259,17 @@ function mcl_doors:register_trapdoor(name, def)
|
||||
fixed = { -0.5, -0.5, 5 / 16, 0.5, 0.5, 0.5 }
|
||||
},
|
||||
on_rightclick = on_rightclick,
|
||||
mesecons = {effector = {
|
||||
mesecons = {
|
||||
effector = {
|
||||
action_off = (function(pos, node)
|
||||
punch(pos)
|
||||
end),
|
||||
}},
|
||||
}
|
||||
},
|
||||
on_rotate = on_rotate,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", name, "nodes", name .. "_open")
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -215,9 +215,23 @@ minetest.register_node("mcl_sculk:vein", {
|
||||
type = "wallmounted",
|
||||
},
|
||||
groups = {
|
||||
handy = 1, axey = 1, shearsy = 1, swordy = 1, deco_block = 1,
|
||||
dig_by_piston = 1, destroy_by_lava_flow = 1, sculk = 1, dig_by_water = 1,
|
||||
handy = 1,
|
||||
axey = 1,
|
||||
shearsy = 1,
|
||||
swordy = 1,
|
||||
deco_block = 1,
|
||||
dig_by_piston = 1,
|
||||
destroy_by_lava_flow = 1,
|
||||
sculk = 1,
|
||||
dig_by_water = 1,
|
||||
ladder = 1
|
||||
},
|
||||
after_destruct = function(pos, old)
|
||||
mcl_core.update_trapdoor(pos, "destruct")
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
mcl_core.update_trapdoor(pos, "place")
|
||||
end,
|
||||
sounds = sounds,
|
||||
drop = "",
|
||||
_mcl_shears_drop = true,
|
||||
|
Loading…
Reference in New Issue
Block a user