Fixes bug with stalactite placement

This commit is contained in:
Oversword 2021-06-07 17:04:31 +00:00 committed by Vanessa Dannenberg
parent 70df655a42
commit d87d8e51f5

View File

@ -85,19 +85,34 @@ minetest.register_node("cavestuff:stalactite_1",{
node_box = {
type = "fixed",
fixed = {
{-0.187500,0.425000,-0.150003,0.162500,0.500000,0.162500},
{-0.112500,0.162500,-0.100000,0.087500,0.475000,0.087500},
{-0.062500,-0.275000,-0.062500,0.062500,0.500000,0.062500},
{-0.037500,-0.837500,0.037500,0.037500,0.500000,-0.025000},
{-0.187500,-0.425000,-0.150003,0.162500,-0.500000,0.162500},
{-0.112500,-0.162500,-0.100000,0.087500,-0.475000,0.087500},
{-0.062500,0.275000,-0.062500,0.062500,-0.500000,0.062500},
{-0.037500,0.837500,0.037500,0.037500,-0.500000,-0.025000},
}
},
on_place = function(itemstack, placer, pointed_thing)
local pt = pointed_thing
if minetest.get_node(pt.under).name=="default:stone"
and minetest.get_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}).name=="air"
and minetest.get_node({x=pt.under.x, y=pt.under.y-2, z=pt.under.z}).name=="air" then
minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..math.random(1,3)})
local dir = vector.subtract(pointed_thing.above, pointed_thing.under)
local base = pointed_thing.under
local place = vector.add(base, dir)
local above = vector.add(place, dir)
if not placer then return end
local playername = placer:get_player_name()
if minetest.is_protected(place, playername)
or minetest.is_protected(above, playername) then
minetest.record_protection_violation(place, playername)
return
end
if minetest.get_node(base).name == "default:stone"
and minetest.get_node(place).name == "air"
and minetest.get_node(above).name == "air"
then
minetest.swap_node(place, {
name = "cavestuff:stalactite_"..math.random(1,3),
param2 = minetest.dir_to_wallmounted(vector.multiply(dir, -1))
})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
@ -116,10 +131,10 @@ minetest.register_node("cavestuff:stalactite_2",{
node_box = {
type = "fixed",
fixed = {
{-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500},
{-0.112500,0.112500,-0.100000,0.087500,0.475000,0.087500},
{-0.062500,-0.675000,-0.062500,0.062500,0.500000,0.062500},
{-0.037500,-0.975000,0.037500,0.037500,0.500000,-0.025000},
{-0.187500,-0.387500,-0.150003,0.162500,-0.500000,0.162500},
{-0.112500,-0.112500,-0.100000,0.087500,-0.475000,0.087500},
{-0.062500,0.675000,-0.062500,0.062500,-0.500000,0.062500},
{-0.037500,0.975000,0.037500,0.037500,-0.500000,-0.025000},
}
},
})
@ -134,10 +149,10 @@ minetest.register_node("cavestuff:stalactite_3",{
node_box = {
type = "fixed",
fixed = {
{-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500},
{-0.112500,0.037500,-0.100000,0.087500,0.475000,0.087500},
{-0.062500,-0.437500,-0.062500,0.062500,0.500000,0.062500},
{-0.037500,-1.237500,0.037500,0.037500,0.500000,-0.025000},
{-0.187500,-0.387500,-0.150003,0.162500,-0.500000,0.162500},
{-0.112500,-0.037500,-0.100000,0.087500,-0.475000,0.087500},
{-0.062500,0.437500,-0.062500,0.062500,-0.500000,0.062500},
{-0.037500,1.237500,0.037500,0.037500,-0.500000,-0.025000},
}
},
})