Skip to content

Commit

Permalink
Make homedecor_beds compatible with sorcerykid's beds mod
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jan 6, 2025
1 parent 5cde938 commit 6d3edea
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions homedecor_bedroom/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ local kbed_cbox = {
}
}

local beds_compat = {
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
return itemstack
end,
}

local bed_def = minetest.registered_nodes["beds:bed"]
local bed_on_rightclick = bed_def and bed_def.on_rightclick or nil
if bed_def then
if bed_def.on_rightclick then
beds_compat.on_rightclick = bed_def.on_rightclick
end
beds_compat.transforms = bed_def.transforms
end

homedecor.register("bed_regular", {
mesh = "homedecor_bed_regular.obj",
Expand Down Expand Up @@ -73,11 +84,12 @@ homedecor.register("bed_regular", {
homedecor.bed_expansion(pos, clicker, itemstack, pointed_thing, true)
elseif core.global_exists("beds") then
beds.on_rightclick(pos, clicker)
elseif bed_on_rightclick then
bed_on_rightclick(pos, node, clicker)
else bed_on_rightclick then
beds_compat.on_rightclick(pos, node, clicker, itemstack, pointed_thing)
end
return itemstack
end,
transforms = beds_compat.transforms,
crafts = {
{
recipe = {
Expand Down Expand Up @@ -116,12 +128,13 @@ homedecor.register("bed_extended", {
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if core.global_exists("beds") then
beds.on_rightclick(pos, clicker)
elseif bed_on_rightclick then
bed_on_rightclick(pos, node, clicker)
else
beds_compat.on_rightclick(pos, node, clicker, itemstack, pointed_thing)
end
return itemstack
end,
drop = "homedecor:bed_regular"
drop = "homedecor:bed_regular",
transforms = beds_compat.transforms,
})

homedecor.register("bed_kingsize", {
Expand Down Expand Up @@ -159,11 +172,12 @@ homedecor.register("bed_kingsize", {
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if core.global_exists("beds") then
beds.on_rightclick(pos, clicker)
elseif bed_on_rightclick then
bed_on_rightclick(pos, node, clicker)
else
beds_compat.on_rightclick(pos, node, clicker, itemstack, pointed_thing)
end
return itemstack
end,
transforms = beds_compat.transforms,
crafts = {
{
recipe = {
Expand Down

0 comments on commit 6d3edea

Please sign in to comment.