forked from VoxeLibre/VoxeLibre
Compare commits
2 Commits
b320d008ca
...
e5a260b563
Author | SHA1 | Date |
---|---|---|
Dehydrate6684 | e5a260b563 | |
Dehydrate6684 | 9b2b8ee56e |
|
@ -11,42 +11,15 @@ local function rotate_climbable(pos, node, user, mode)
|
|||
return false
|
||||
end
|
||||
|
||||
---Checks the direction (param2) of a ladder and a trapdoor and determine if they are
|
||||
---facing the same direction.
|
||||
---
|
||||
---@param ladder integer The param2 value of the ladder.
|
||||
---@param trapdoor integer The param2 value of the trapdoor.
|
||||
---@return boolean If the ladder and trapdoor are in the same direction.
|
||||
function mcl_core.check_direction(ladder, trapdoor)
|
||||
local convert_table = {
|
||||
{ 1, 23 },
|
||||
{ 3, 21 },
|
||||
{ 0, 20 },
|
||||
{ 2, 22 },
|
||||
}
|
||||
|
||||
local conversion = convert_table[ladder - 1];
|
||||
if not conversion then
|
||||
return false
|
||||
elseif conversion[1] == trapdoor or conversion[2] == trapdoor then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---Updates the trapdoor above (if any).
|
||||
---
|
||||
---@param pos mt.Vector The position of the ladder.
|
||||
---@param ladder integer The param2 value of the ladder.
|
||||
---@param event "place" | "destruct" The place or destruct event.
|
||||
local function update_trapdoor(pos, ladder, 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
|
||||
and mcl_core.check_direction(ladder, top_node.param2) then
|
||||
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")
|
||||
|
@ -142,11 +115,10 @@ minetest.register_node("mcl_core:ladder", {
|
|||
return itemstack
|
||||
end,
|
||||
after_destruct = function(pos, old)
|
||||
update_trapdoor(pos, old.param2, "destruct")
|
||||
mcl_core.update_trapdoor(pos, "destruct")
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
local me = minetest.get_node(pos)
|
||||
update_trapdoor(pos, me.param2, "place")
|
||||
mcl_core.update_trapdoor(pos, "place")
|
||||
end,
|
||||
_mcl_blast_resistance = 0.4,
|
||||
_mcl_hardness = 0.4,
|
||||
|
@ -186,7 +158,8 @@ minetest.register_node("mcl_core:vine", {
|
|||
flammable = 2,
|
||||
fire_encouragement = 15,
|
||||
fire_flammability = 100,
|
||||
foliage_palette_wallmounted = 1
|
||||
foliage_palette_wallmounted = 1,
|
||||
ladder = 1
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
drop = "",
|
||||
|
@ -258,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,
|
||||
|
|
|
@ -79,8 +79,7 @@ function mcl_doors:register_trapdoor(name, def)
|
|||
-- Checking if there is something underneath the trapdoor
|
||||
if bottom_node then
|
||||
local is_ladder = minetest.get_item_group(bottom_node.name, "ladder")
|
||||
local same_direction = mcl_core.check_direction(bottom_node.param2, me.param2)
|
||||
if is_ladder > 0 and same_direction then
|
||||
if is_ladder > 0 then
|
||||
name_end = "_ladder"
|
||||
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