forked from VoxeLibre/VoxeLibre
Check protection when placing painting
This commit is contained in:
parent
f0d511bd4a
commit
3bd160f414
|
@ -6,6 +6,14 @@ local S = minetest.get_translator("mcl_paintings")
|
||||||
|
|
||||||
local wood = "[combine:16x16:-192,0=mcl_paintings_paintings.png"
|
local wood = "[combine:16x16:-192,0=mcl_paintings_paintings.png"
|
||||||
|
|
||||||
|
local is_protected = function(pos, name)
|
||||||
|
if minetest.is_protected(pos, name) then
|
||||||
|
minetest.record_protection_violation(pos, name)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if there's a painting for provided painting size.
|
-- Check if there's a painting for provided painting size.
|
||||||
-- If yes, returns the arguments.
|
-- If yes, returns the arguments.
|
||||||
-- If not, returns the next smaller available painting.
|
-- If not, returns the next smaller available painting.
|
||||||
|
@ -224,21 +232,31 @@ minetest.register_craftitem("mcl_paintings:painting", {
|
||||||
if not xsize then
|
if not xsize then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, exmax = size_to_minmax_entity(xsize)
|
local _, exmax = size_to_minmax_entity(xsize)
|
||||||
local _, eymax = size_to_minmax_entity(ysize)
|
local _, eymax = size_to_minmax_entity(ysize)
|
||||||
local pposa = vector.subtract(ppos, vector.multiply(dir, 0.5-5/256))
|
local pposa = vector.subtract(ppos, vector.multiply(dir, 0.5-5/256))
|
||||||
|
local name = placer:get_player_name()
|
||||||
local pexmax
|
local pexmax
|
||||||
local peymax = eymax - 0.5
|
local peymax = eymax - 0.5
|
||||||
|
local n
|
||||||
if negative then
|
if negative then
|
||||||
pexmax = -exmax + 0.5
|
pexmax = -exmax + 0.5
|
||||||
|
n = -1
|
||||||
else
|
else
|
||||||
pexmax = exmax - 0.5
|
pexmax = exmax - 0.5
|
||||||
|
n = 1
|
||||||
end
|
end
|
||||||
|
if is_protected(ppos, name) then return itemstack end
|
||||||
|
local ppos2
|
||||||
if dir.z ~= 0 then
|
if dir.z ~= 0 then
|
||||||
pposa = vector.add(pposa, {x=pexmax, y=peymax, z=0})
|
pposa = vector.add(pposa, {x=pexmax, y=peymax, z=0})
|
||||||
|
ppos2 = vector.add(ppos, {x = (xsize-1)*n, y = ysize-1, z = 0})
|
||||||
else
|
else
|
||||||
pposa = vector.add(pposa, {x=0, y=peymax, z=pexmax})
|
pposa = vector.add(pposa, {x=0, y=peymax, z=pexmax})
|
||||||
|
ppos2 = vector.add(ppos, {x = 0, y = ysize-1, z = (xsize-1)*n})
|
||||||
end
|
end
|
||||||
|
if is_protected(ppos2, name) then return itemstack end
|
||||||
local painting, pid = get_random_painting(xsize, ysize)
|
local painting, pid = get_random_painting(xsize, ysize)
|
||||||
if not painting then
|
if not painting then
|
||||||
minetest.log("error", "[mcl_paintings] No painting found for size "..xsize..","..ysize.."!")
|
minetest.log("error", "[mcl_paintings] No painting found for size "..xsize..","..ysize.."!")
|
||||||
|
|
Loading…
Reference in New Issue