Add nether wood doors+trapdoors

This commit is contained in:
3raven 2022-03-06 23:27:32 +00:00
parent 926382b6dc
commit 7bc43e4e82
5 changed files with 851 additions and 0 deletions

View File

@ -0,0 +1,43 @@
License of source code:
-----------------------
Copyright (C) 2012 PilzAdam
modified by BlockMen (added sounds, glassdoor, trapdoor)
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.
License of sounds
--------------------------------------
Opening-Sound created by CGEffex (CC BY 3.0), modified by BlockMen
doors_door_open.ogg
Closing-Sound created by bennstir (CC BY 3.0)
doors_door_close.ogg
Steel door sounds open & close (CC-BY-3.0) by HazMatt
- http://www.freesound.org/people/HazMattt/sounds/187283/
doors_steel_door_open.ogg
doors_steel_door_close.ogg
License/authors of texture files
--------------------------------------
CC-BY-SA 4.0
Modified from the textures of mcl_mushroom and XSSheep's Pixel Perfection Legacy by Github user 3raven :
mcl_doors_door_crimson_lower.png
mcl_doors_door_warped_lower.png
mcl_doors_trapdoor_crimson.png
mcl_doors_door_crimson.png
mcl_doors_door_warped.png
mcl_doors_trapdoor_crimson_side.png
mcl_doors_door_crimson_side_lower.png
mcl_doors_door_warped_side_lower.png
mcl_doors_trapdoor_warped.png
mcl_doors_door_crimson_side_upper.png
mcl_doors_door_warped_side_upper.png
mcl_doors_trapdoor_warped_side.png
mcl_doors_door_crimson_upper.png
mcl_doors_door_warped_upper.png

View File

@ -0,0 +1,15 @@
-- Register aliases
local doornames = {
["door_crimson"] = "crimson_door",
["door_warped"] = "warped_door",
}
for oldname, newname in pairs(doornames) do
minetest.register_alias("doors:"..oldname, "mclx_doors:"..newname)
minetest.register_alias("doors:"..oldname.."_t_1", "mclx_doors:"..newname.."_t_1")
minetest.register_alias("doors:"..oldname.."_b_1", "mclx_doors:"..newname.."_b_1")
minetest.register_alias("doors:"..oldname.."_t_2", "mclx_doors:"..newname.."_t_2")
minetest.register_alias("doors:"..oldname.."_b_2", "mclx_doors:"..newname.."_b_2")
end

View File

@ -0,0 +1,559 @@
local S = minetest.get_translator(minetest.get_current_modname())
local minetest_get_meta = minetest.get_meta
-- This helper function calls on_place_node callbacks.
local function on_place_node(place_to, newnode,
placer, oldnode, itemstack, pointed_thing)
-- Run script hook
for _, callback in pairs(minetest.registered_on_placenodes) do
-- Deep-copy pos, node and pointed_thing because callback can modify them
local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z}
local newnode_copy =
{name = newnode.name, param1 = newnode.param1, param2 = newnode.param2}
local oldnode_copy =
{name = oldnode.name, param1 = oldnode.param1, param2 = oldnode.param2}
local pointed_thing_copy = {
type = pointed_thing.type,
above = vector.new(pointed_thing.above),
under = vector.new(pointed_thing.under),
ref = pointed_thing.ref,
}
callback(place_to_copy, newnode_copy, placer,
oldnode_copy, itemstack, pointed_thing_copy)
end
end
-- Registers a door
-- name: The name of the door
-- def: a table with the folowing fields:
-- description
-- inventory_image
-- groups
-- tiles_bottom: the tiles of the bottom part of the door {front, side}
-- tiles_top: the tiles of the bottom part of the door {front, side}
-- If the following fields are not defined the default values are used
-- node_box_bottom
-- node_box_top
-- selection_box_bottom
-- selection_box_top
-- only_placer_can_open: if true only the player who placed the door can
-- open it
-- only_redstone_can_open: if true, the door can only be opened by redstone,
-- not by rightclicking it
function mclx_doors:register_door(name, def)
def.groups.not_in_creative_inventory = 1
def.groups.dig_by_piston = 1
def.groups.door = 1
def.groups.mesecon_ignore_opaque_dig = 1
if not def.sound_open then
def.sound_open = "doors_door_open"
end
if not def.sound_close then
def.sound_close = "doors_door_close"
end
local box = {{-8/16, -8/16, -8/16, 8/16, 8/16, -5/16}}
if not def.node_box_bottom then
def.node_box_bottom = box
end
if not def.node_box_top then
def.node_box_top = box
end
if not def.selection_box_bottom then
def.selection_box_bottom= box
end
if not def.selection_box_top then
def.selection_box_top = box
end
local longdesc, usagehelp, tt_help
tt_help = def._tt_help
longdesc = def._doc_items_longdesc
if not longdesc then
if def.only_redstone_can_open then
longdesc = S("This door is a 2-block high barrier which can be opened or closed by hand or by redstone power.")
else
longdesc = S("This door is a 2-block high barrier which can only be opened by redstone power, not by hand.")
end
end
usagehelp = def._doc_items_usagehelp
if not usagehelp then
if def.only_redstone_can_open then
usagehelp = S("To open or close this door, send a redstone signal to its bottom half.")
else
usagehelp = S("To open or close this door, rightclick it or send a redstone signal to its bottom half.")
end
end
if not tt_help then
if def.only_redstone_can_open then
tt_help = S("Openable by redstone power")
else
tt_help = S("Openable by players and redstone power")
end
end
local craftitem_groups = { mesecon_conductor_craftable = 1, deco_block = 1 }
if def.groups and def.groups.flammable then
craftitem_groups.flammable = def.groups.flammable
end
minetest.register_craftitem(name, {
description = def.description,
_tt_help = tt_help,
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usagehelp,
inventory_image = def.inventory_image,
stack_max = 64,
groups = craftitem_groups,
on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" or not placer or not placer:is_player() then
return itemstack
end
local pn = placer:get_player_name()
if minetest.is_protected(pointed_thing.above, pn) and minetest.is_protected(pointed_thing.under, pn) then
return itemstack
end
local ptu = pointed_thing.under
local nu = minetest.get_node(ptu)
-- Pointed thing's rightclick action takes precedence, unless player holds down the sneak key
if minetest.registered_nodes[nu.name] and minetest.registered_nodes[nu.name].on_rightclick and not placer:get_player_control().sneak then
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
end
local pt
if minetest.registered_nodes[nu.name] and minetest.registered_nodes[nu.name].buildable_to then
pt = pointed_thing.under
else
pt = pointed_thing.above
end
local pt2 = {x=pt.x, y=pt.y, z=pt.z}
pt2.y = pt2.y+1
local ptname = minetest.get_node(pt).name
local pt2name = minetest.get_node(pt2).name
if
(minetest.registered_nodes[ptname] and not minetest.registered_nodes[ptname].buildable_to) or
(minetest.registered_nodes[pt2name] and not minetest.registered_nodes[pt2name].buildable_to)
then
return itemstack
end
-- get left coordinate for checking if another door is there
local pt_left = {x=pt.x, y=pt.y, z=pt.z}
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
if p2 == 0 then
pt_left.x = pt_left.x-1
elseif p2 == 1 then
pt_left.z = pt_left.z+1
elseif p2 == 2 then
pt_left.x = pt_left.x+1
elseif p2 == 3 then
pt_left.z = pt_left.z-1
end
local left_node = minetest.get_node(pt_left)
-- Set door nodes
minetest.set_node(pt, {name=name.."_b_1", param2=p2})
minetest.set_node(pt2, {name=name.."_t_1", param2=p2})
if def.sounds and def.sounds.place then
minetest.sound_play(def.sounds.place, {pos=pt}, true)
end
if def.only_placer_can_open then
local meta = minetest_get_meta(pt)
meta:set_string("doors_owner", "")
meta = minetest_get_meta(pt2)
meta:set_string("doors_owner", "")
end
local meta1 = minetest_get_meta(pt)
local meta2 = minetest_get_meta(pt2)
-- save mirror state for the correct door
if left_node.name:sub(1, #name) == name then
meta1:set_int("is_mirrored", 1)
meta2:set_int("is_mirrored", 1)
end
-- Save open state. 1 = open. 0 = closed
meta1:set_int("is_open", 0)
meta2:set_int("is_open", 0)
if not minetest.is_creative_enabled(pn) then
itemstack:take_item()
end
on_place_node(pt, minetest.get_node(pt), placer, nu, itemstack, pointed_thing)
on_place_node(pt2, minetest.get_node(pt2), placer, minetest.get_node({x=ptu.x,y=ptu.y+1,z=ptu.z}), itemstack, pointed_thing)
return itemstack
end,
})
local tt = def.tiles_top
local tb = def.tiles_bottom
local function on_open_close(pos, dir, check_name, replace, replace_dir)
local meta1 = minetest_get_meta(pos)
pos.y = pos.y+dir
local meta2 = minetest_get_meta(pos)
-- if name of other door is not the same as check_name -> return
if not minetest.get_node(pos).name == check_name then
return
end
-- swap directions if mirrored
local params = {3,0,1,2}
if meta1:get_int("is_open") == 0 and meta2:get_int("is_mirrored") == 0 or meta1:get_int("is_open") == 1 and meta2:get_int("is_mirrored") == 1 then
params = {1,2,3,0}
end
local p2 = minetest.get_node(pos).param2
local np2 = params[p2+1]
minetest.swap_node(pos, {name=replace_dir, param2=np2})
pos.y = pos.y-dir
minetest.swap_node(pos, {name=replace, param2=np2})
local door_switching_sound
if meta1:get_int("is_open") == 1 then
door_switching_sound = def.sound_close
meta1:set_int("is_open", 0)
meta2:set_int("is_open", 0)
else
door_switching_sound = def.sound_open
meta1:set_int("is_open", 1)
meta2:set_int("is_open", 1)
end
minetest.sound_play(door_switching_sound, {pos = pos, gain = 0.5, max_hear_distance = 16}, true)
end
local function on_mesecons_signal_open(pos, node)
on_open_close(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2")
end
local function on_mesecons_signal_close(pos, node)
if not mesecon.is_powered({x=pos.x,y=pos.y+1,z=pos.z}) then
on_open_close(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1")
end
end
local function on_mesecons_signal_open_top(pos, node)
on_mesecons_signal_open({x=pos.x, y=pos.y-1, z=pos.z}, node)
end
local function on_mesecons_signal_close_top(pos, node)
if not mesecon.is_powered({x=pos.x,y=pos.y-1,z=pos.z}) then
on_mesecons_signal_close({x=pos.x, y=pos.y-1, z=pos.z}, node)
end
end
local function check_player_priv(pos, player)
if not def.only_placer_can_open then
return true
end
local meta = minetest_get_meta(pos)
local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn
end
local on_rightclick
-- Disable on_rightclick if this is a redstone-only door
if not def.only_redstone_can_open then
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_open_close(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2")
end
end
end
minetest.register_node(name.."_b_1", {
tiles = {"blank.png", tt[2].."^[transformFXR90", tb[2], tb[2].."^[transformFX", tb[1], tb[1].."^[transformFX"},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
drop = "",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
_mcl_hardness = def._mcl_hardness,
_mcl_blast_resistance = def._mcl_blast_resistance,
sounds = def.sounds,
after_destruct = function(bottom, oldnode)
local meta_bottom = minetest_get_meta(bottom)
if meta_bottom:get_int("rotation") == 1 then
meta_bottom:set_int("rotation", 0)
else
minetest.add_item(bottom, name)
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then
minetest.remove_node(top)
end
end
end,
on_rightclick = on_rightclick,
mesecons = { effector = {
action_on = on_mesecons_signal_open,
}},
on_rotate = function(bottom, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
minetest.swap_node(bottom, node)
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.name = name .."_t_1"
minetest.swap_node(top, node)
return true
end
return false
end,
can_dig = check_player_priv,
})
if def.only_redstone_can_open then
on_rightclick = nil
else
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_open_close(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2")
end
end
end
minetest.register_node(name.."_t_1", {
tiles = {tt[2].."^[transformR90", "blank.png", tt[2], tt[2].."^[transformFX", tt[1], tt[1].."^[transformFX"},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
drop = "",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_top
},
selection_box = {
type = "fixed",
fixed = def.selection_box_top
},
groups = def.groups,
_mcl_hardness = def._mcl_hardness,
_mcl_blast_resistance = def._mcl_blast_resistance,
sounds = def.sounds,
after_destruct = function(top, oldnode)
local meta_top = minetest_get_meta(top)
if meta_top:get_int("rotation") == 1 then
meta_top:set_int("rotation", 0)
else
local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then
minetest.dig_node(bottom)
end
end
end,
on_rightclick = on_rightclick,
mesecons = { effector = {
action_on = on_mesecons_signal_open_top,
rules = mesecon.rules.flat,
}},
on_rotate = function(top, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(top, node, mode)
minetest.swap_node(top, node)
local bottom = {x=top.x,y=top.y-1,z=top.z}
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.name = name .."_b_1"
minetest.swap_node(bottom, node)
return true
end
return false
end,
can_dig = check_player_priv,
})
if def.only_redstone_can_open then
on_rightclick = nil
else
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_open_close(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1")
end
end
end
minetest.register_node(name.."_b_2", {
tiles = {"blank.png", tt[2].."^[transformFXR90", tb[2].."^[transformI", tb[2].."^[transformFX", tb[1].."^[transformFX", tb[1]},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
drop = "",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
_mcl_hardness = def._mcl_hardness,
_mcl_blast_resistance = def._mcl_blast_resistance,
sounds = def.sounds,
after_destruct = function(bottom, oldnode)
local meta_bottom = minetest_get_meta(bottom)
if meta_bottom:get_int("rotation") == 1 then
meta_bottom:set_int("rotation", 0)
else
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
minetest.add_item(bottom, name)
if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then
minetest.remove_node(top)
end
end
end,
on_rightclick = on_rightclick,
mesecons = { effector = {
action_off = on_mesecons_signal_close,
}},
on_rotate = function(bottom, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
minetest.swap_node(bottom, node)
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.name = name .."_t_2"
minetest.swap_node(top, node)
return true
end
return false
end,
can_dig = check_player_priv,
})
if def.only_redstone_can_open then
on_rightclick = nil
else
on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then
on_open_close(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1")
end
end
end
minetest.register_node(name.."_t_2", {
tiles = {tt[2].."^[transformR90", "blank.png", tt[2].."^[transformI", tt[2].."^[transformFX", tt[1].."^[transformFX", tt[1]},
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = false,
drop = "",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_top
},
selection_box = {
type = "fixed",
fixed = def.selection_box_top
},
groups = def.groups,
_mcl_hardness = def._mcl_hardness,
_mcl_blast_resistance = def._mcl_blast_resistance,
sounds = def.sounds,
after_destruct = function(top, oldnode)
local meta_top = minetest_get_meta(top)
if meta_top:get_int("rotation") == 1 then
meta_top:set_int("rotation", 0)
else
local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then
minetest.dig_node(bottom)
end
end
end,
on_rightclick = on_rightclick,
mesecons = { effector = {
action_off = on_mesecons_signal_close_top,
rules = mesecon.rules.flat,
}},
on_rotate = function(top, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(top, node, mode)
minetest.swap_node(top, node)
local bottom = {x=top.x,y=top.y-1,z=top.z}
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.name = name .."_b_2"
minetest.swap_node(bottom, node)
return true
end
return false
end,
can_dig = check_player_priv,
})
-- Add entry aliases for the Help
if minetest.get_modpath("doc") then
doc.add_entry_alias("craftitems", name, "nodes", name.."_b_1")
doc.add_entry_alias("craftitems", name, "nodes", name.."_b_2")
doc.add_entry_alias("craftitems", name, "nodes", name.."_t_1")
doc.add_entry_alias("craftitems", name, "nodes", name.."_t_2")
end
end

View File

@ -0,0 +1,231 @@
local S = minetest.get_translator(minetest.get_current_modname())
-- Wrapper around mintest.pointed_thing_to_face_pos.
local function get_fpos(placer, pointed_thing)
local fpos
-- Workaround: minetest.pointed_thing_to_face_pos crashes in MT 0.4.16 if
-- pointed_thing.under and pointed_thing.above are equal
-- FIXME: Remove this when MT got fixed.
if not vector.equals(pointed_thing.under, pointed_thing.above) then
-- The happy case: Everything is normal
local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
fpos = finepos.y % 1
else
-- Fallback if both above and under are equal
fpos = 0
end
return fpos
end
---- Trapdoor ----
local on_rotate
if minetest.get_modpath("screwdriver") then
on_rotate = function(pos, node, user, mode, param2)
-- Flip trapdoor vertically
if mode == screwdriver.ROTATE_AXIS then
local minor = node.param2
if node.param2 >= 20 then
minor = node.param2 - 20
if minor == 3 then
minor = 1
elseif minor == 1 then
minor = 3
end
node.param2 = minor
else
if minor == 3 then
minor = 1
elseif minor == 1 then
minor = 3
end
node.param2 = minor
node.param2 = node.param2 + 20
end
minetest.set_node(pos, node)
return true
end
end
end
function mclx_doors:register_trapdoor(name, def)
local groups = table.copy(def.groups)
if groups == nil then
groups = {}
end
groups.mesecon_ignore_opaque_dig = 1
if not def.sound_open then
def.sound_open = "doors_door_open"
end
if not def.sound_close then
def.sound_close = "doors_door_close"
end
local function punch(pos)
local me = minetest.get_node(pos)
local tmp_node
-- Close
if minetest.get_item_group(me.name, "trapdoor") == 2 then
minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 16}, true)
tmp_node = {name=name, param1=me.param1, param2=me.param2}
-- 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}
end
minetest.set_node(pos, tmp_node)
end
local on_rightclick
if not def.only_redstone_can_open then
on_rightclick = function(pos, node, clicker)
punch(pos)
end
end
-- Default help texts
local longdesc, usagehelp, tt_help
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.")
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.")
end
end
usagehelp = def._doc_items_usagehelp
if not usagehelp and not def.only_redstone_can_open then
usagehelp = S("To open or close this trapdoor, rightclick it or send a redstone signal to it.")
end
if def.only_redstone_can_open then
tt_help = S("Openable by redstone power")
else
tt_help = S("Openable by players and redstone power")
end
-- Closed trapdoor
local tile_front = def.tile_front
local tile_side = def.tile_side
if not tile_side then
tile_side = tile_front
end
local tiles_closed = {
tile_front,
tile_front .. "^[transformFY",
tile_side, tile_side,
tile_side, tile_side,
}
local groups_closed = groups
groups_closed.trapdoor = 1
groups_closed.deco_block = 1
minetest.register_node(name, {
description = def.description,
_tt_help = tt_help,
_doc_items_longdesc = longdesc,
_doc_items_usagehelp = usagehelp,
drawtype = "nodebox",
tiles = tiles_closed,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
inventory_image = def.inventory_image,
wield_image = def.wield_image,
is_ground_content = false,
paramtype = "light",
stack_max = 64,
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups_closed,
_mcl_hardness = def._mcl_hardness,
_mcl_blast_resistance = def._mcl_blast_resistance,
sounds = def.sounds,
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, -5/16, 8/16},},
},
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
local param2 = 0
local placer_pos = placer:get_pos()
if placer_pos then
param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
end
local fpos = get_fpos(placer, pointed_thing)
--local origname = itemstack:get_name()
if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5)
or (fpos < -0.5 and fpos > -0.999999999) then
param2 = param2 + 20
if param2 == 21 then
param2 = 23
elseif param2 == 23 then
param2 = 21
end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
on_rightclick = on_rightclick,
on_rotate = on_rotate,
})
-- Open trapdoor
local groups_open = table.copy(groups)
local tiles_open = {
tile_side,
tile_side .. "^[transformR180",
tile_side .. "^[transformR270",
tile_side .. "^[transformR90",
tile_front .. "^[transform46",
tile_front .. "^[transformFY",
}
groups_open.trapdoor = 2
groups_open.not_in_creative_inventory = 1
minetest.register_node(name.."_open", {
drawtype = "nodebox",
tiles = tiles_open,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
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,
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,
})
if minetest.get_modpath("doc") then
doc.add_entry_alias("nodes", name, "nodes", name.."_open")
end
end

View File

@ -0,0 +1,3 @@
name = mclx_doors
depends = mcl_core, mcl_sounds, mesecons
optional_depends = doc, screwdriver