forked from VoxeLibre/VoxeLibre
Allow to combine slabs from below
This commit is contained in:
parent
72a9eef09c
commit
f3805ab395
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
stairs = {}
|
stairs = {}
|
||||||
|
|
||||||
local function place_slab(itemstack, placer, pointed_thing)
|
local function place_slab_normal(itemstack, placer, pointed_thing)
|
||||||
local p0 = pointed_thing.under
|
local p0 = pointed_thing.under
|
||||||
local p1 = pointed_thing.above
|
local p1 = pointed_thing.above
|
||||||
|
|
||||||
|
@ -159,15 +159,16 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
||||||
local wield_item = itemstack:get_name()
|
local wield_item = itemstack:get_name()
|
||||||
local creative_enabled = minetest.setting_getbool("creative_mode")
|
local creative_enabled = minetest.setting_getbool("creative_mode")
|
||||||
|
|
||||||
if under and wield_item == under.name then
|
|
||||||
-- place slab using under node orientation
|
-- place slab using under node orientation
|
||||||
local dir = minetest.dir_to_facedir(vector.subtract(
|
local dir = vector.subtract(pointed_thing.above, pointed_thing.under)
|
||||||
pointed_thing.above, pointed_thing.under), true)
|
|
||||||
|
|
||||||
local p2 = under.param2
|
local p2 = under.param2
|
||||||
|
|
||||||
-- combine two slabs if possible
|
-- combine two slabs if possible
|
||||||
if wield_item == under.name then
|
-- Requirements: Same slab material, must be placed on top of lower slab, or on bottom of upper slab
|
||||||
|
if (wield_item == under.name or wield_item == minetest.registered_nodes[under.name]._mcl_other_slab_half) and
|
||||||
|
not ((dir.y >= 0 and minetest.get_item_group(under.name, "slab_top") == 1) or
|
||||||
|
(dir.y <= 0 and minetest.get_item_group(under.name, "slab_top") == 0)) then
|
||||||
|
|
||||||
if not recipeitem then
|
if not recipeitem then
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -192,27 +193,13 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
-- No combination possible: Place slab normally
|
||||||
|
|
||||||
-- Placing a slab on an upside down slab should make it right-side up.
|
|
||||||
if p2 >= 20 and dir == 8 then
|
|
||||||
p2 = p2 - 20
|
|
||||||
-- same for the opposite case: slab below normal slab
|
|
||||||
elseif p2 <= 3 and dir == 4 then
|
|
||||||
p2 = p2 + 20
|
|
||||||
end
|
|
||||||
|
|
||||||
-- else attempt to place node with proper param2
|
|
||||||
minetest.item_place_node(ItemStack(wield_item), placer, pointed_thing, p2)
|
|
||||||
if not creative_enabled then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
else
|
else
|
||||||
return place_slab(itemstack, placer, pointed_thing)
|
return place_slab_normal(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
_mcl_hardness = hardness,
|
_mcl_hardness = hardness,
|
||||||
|
_mcl_other_slab_half = upper_slab,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node(":"..lower_slab, slabdef)
|
minetest.register_node(":"..lower_slab, slabdef)
|
||||||
|
@ -230,6 +217,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
||||||
topdef._doc_items_longdesc = nil
|
topdef._doc_items_longdesc = nil
|
||||||
topdef._doc_items_usagehelp = nil
|
topdef._doc_items_usagehelp = nil
|
||||||
topdef.drop = lower_slab
|
topdef.drop = lower_slab
|
||||||
|
topdef._mcl_other_slab_half = lower_slab
|
||||||
topdef.node_box = {
|
topdef.node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.5, 0, -0.5, 0.5, 0.5, 0.5},
|
fixed = {-0.5, 0, -0.5, 0.5, 0.5, 0.5},
|
||||||
|
|
Loading…
Reference in New Issue