diff --git a/nodes.lua b/nodes.lua index 5153996..aa3cc4b 100644 --- a/nodes.lua +++ b/nodes.lua @@ -172,6 +172,12 @@ xdecor.register("crate", { sounds = default.node_sound_wood_defaults() }) +xdecor.register("cushion_block", { + tiles = {"xdecor_cushion.png"}, + groups = {snappy=3, flammable=3, fall_damage_add_percent=-75, not_in_creative_inventory=1}, + drop = "xdecor:cushion 2" +}) + local function door_access(door) return door:find("prison") end diff --git a/sitting.lua b/sitting.lua index c336d4e..8306fe4 100644 --- a/sitting.lua +++ b/sitting.lua @@ -82,9 +82,23 @@ xdecor.register("cushion", { on_place = minetest.rotate_node, node_box = xdecor.nodebox.slab_y(0.5), can_dig = dig, - on_rightclick = function(pos, node, clicker) + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) pos.y = pos.y + 0 sit(pos, node, clicker) + + local wield_item = clicker:get_wielded_item():get_name() + if wield_item == "xdecor:cushion" and clicker:get_player_control().sneak then + local player_name = clicker:get_player_name() + if minetest.is_protected(pos, player_name) then + minetest.record_protection_violation(pos, player_name) + return + end + minetest.set_node(pos, {name="xdecor:cushion_block", param2=node.param2}) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + return itemstack + end + end end })