minetest.register_node('furniture:stool_short', {
   description = 'Short stool',
   drawtype = 'mesh',
   mesh = 'furniture_stool_short.obj',
   tiles = {'furniture_stool_short.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, .375, 0, .375},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, .375, 0, .375},
      },
   groups = {breakable=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:stool_tall', {
   description = 'Tall stool',
   drawtype = 'mesh',
   mesh = 'furniture_stool_tall.obj',
   tiles = {'furniture_stool_tall.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, .375, .5, .375},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, .375, .5, .375},
      },
   groups = {breakable=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:chair', {
   description = 'Chair',
   drawtype = 'mesh',
   mesh = 'furniture_chair.obj',
   tiles = {'furniture_chair.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, .375, 0, .375},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, .375, 0, .375},
      },
   groups = {breakable=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:bench', {
   description = 'Bench',
   drawtype = 'mesh',
   mesh = 'furniture_bench.obj',
   tiles = {'furniture_bench.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, 1.375, 0, .375},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.375, -.5, -.375, 1.375, 0, .375},
      },
   groups = {breakable=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:bench_with_back', {
   description = 'Bench with Back',
   drawtype = 'mesh',
   mesh = 'furniture_bench_with_back.obj',
   tiles = {'furniture_bench_with_back.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {{-.375, -.5, -.375, .5, 0, .45}, --seat
               {-.375, 0, .275, 1.375, .5, .375}} --back
      },
   collision_box = {
      type = 'fixed',
      fixed = {{-.375, -.5, -.375, 1.375, 0, .45},
               {-.375, 0, .275, 1.375, .5, .375}}
      },
   groups = {breakable=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:bench_picnic', {
   description = 'Picnic Table',
   drawtype = 'mesh',
   mesh = 'furniture_bench_picnic.obj',
   tiles = {'furniture_bench_picnic.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {
         {-.375, -.5, -.375, 1.375, 0, 1.375},
         {-.375, 0, -.0625, 1.375, .5, 1.0625}
         }
      },
   collision_box = {
      type = 'fixed',
      fixed = {
         {-.375, -.5, -.375, 1.375, 0, 1.375},
         {-.375, 0, -.0625, 1.375, .5, 1.0625}
         }
      },
   groups = {breakable=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:stool_2', {
   description = 'Short stool',
   drawtype = 'mesh',
   mesh = 'furniture_stool_2.obj',
   tiles = {'furniture_stool_2.png'},
   paramtype = 'light',
   paramtype2 = 'facedir',
   selection_box = {
      type = 'fixed',
      fixed = {-.25, -.5, -.25, .25, .0625, .25},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.25, -.5, -.25, .25, .0625, .25},
      },
   groups = {breakable=1},
})

---Cushioned items. Yay. :P
local dye_table = furniture.dyes

for i in ipairs(dye_table) do
   local name = dye_table[i][1]
   local desc = dye_table[i][2]
   local hex = dye_table[i][3]

   minetest.register_node('furniture:stool_short_'..name, {
      description = 'Short Stool with '..desc..' Cushion',
      drawtype = 'mesh',
      mesh = 'furniture_stool_short_cushion.obj',
      tiles = {'furniture_stool_short.png', 'furniture_cushion_pad.png'},
      overlay_tiles = {'', {name = 'furniture_cushion_pad.png', color = hex}},
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_stain_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {-.375, -.5, -.375, .375, 0, .375},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.375, -.5, -.375, .375, 0, .375},
         },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

   minetest.register_node('furniture:stool_tall_'..name, {
      description = 'Tall Stool with '..desc..' Cushion',
      drawtype = 'mesh',
      mesh = 'furniture_stool_tall_cushion.obj',
      tiles = {'furniture_stool_tall.png', 'furniture_cushion_pad.png'},
      overlay_tiles = {'', {name = 'furniture_cushion_pad.png', color = hex}},
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_stain_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {-.375, -.5, -.375, .375, .5, .375},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.375, -.5, -.375, .375, .5, .375},
         },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

   minetest.register_node('furniture:chair_'..name, {
      description = 'Chair with '..desc..' Cushion',
      drawtype = 'mesh',
      mesh = 'furniture_chair_cushion.obj',
      tiles = {'furniture_chair.png', 'furniture_cushion_pad.png'},
      overlay_tiles = {'', {name = 'furniture_cushion_pad.png', color = hex}},
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_stain_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {-.375, -.5, -.375, .375, 0, .375},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.375, -.5, -.375, .375, 0, .375},
         },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

   minetest.register_node('furniture:chair_waitingroom_'..name, {
      description = 'Modern Chair with '..desc..' Cushion',
      drawtype = 'mesh',
      mesh = 'furniture_chair_waitingroom.obj',
      tiles = {'furniture_chair_waitingroom_frame.png', 'furniture_chair_waitingroom_cushion.png'},
      overlay_tiles = {'', {name = 'furniture_chair_waitingroom_cushion.png', color = hex}},
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_frame_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {
            {-.375, -.5, -.375, .375, 0, .4375},
            {-.375, 0, .3125, .375, .5, .4375}
            }
         },
      collision_box = {
         type = 'fixed',
         fixed = {
            {-.375, -.5, -.375, .375, 0, .375},
            {-.375, 0, .375, .375, .5, .5}
            }
         },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

   minetest.register_node('furniture:Sofa_'..name, {
      description = desc..' Sofa',
      drawtype = 'mesh',
      mesh = 'furniture_sofa.obj',
      tiles = {'furniture_sofa.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_frame_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {
            {-.375, -.5, -.375, .375, 0, .4375},
            {-.375, 0, .3125, .375, .5, .4375}
            }
         },
      collision_box = {
         type = 'fixed',
         fixed = {
            {-.375, -.5, -.375, .375, 0, .375},
            {-.375, 0, .375, .375, .5, .5}
            }
         },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

   minetest.register_node('furniture:cushion_half_'..name, {
      description = desc..' Half Cushion',
      drawtype = 'nodebox',
      tiles = {'furniture_cushion.png^[multiply:'..hex},
      paramtype = 'light',
      node_box = {
         type = 'fixed',
         fixed = {-.5, -.5, -.5, .5, 0, .5},
         },
      groups = {breakable=1, bouncy=25, fall_damage_add_percent=-25},
   })

   minetest.register_node('furniture:cushion_full_'..name, {
      description = desc..' Full Cushion',
      tiles = {'furniture_cushion.png^[multiply:'..hex},
      groups = {breakable=1, bouncy=50, fall_damage_add_percent=-50},
   })
end
