Загрузка данных
dens = $int(Density, 60, 5, 100)$
maxL = $int(Max Layers, 5, 1, 8)$
skyOnly = $boolean(Sky Only, true)$
denySlabs = $boolean(Deny Slabs, true)$
denyStairs = $boolean(Deny Stairs, true)$
denyLeaves = $boolean(Deny Leaves, true)$
deny1 = $blockState(Deny 1, barrier)$
deny2 = $blockState(Deny 2, glass)$
deny3 = $blockState(Deny 3, oak_planks)$
l1 = $blockState(L1, snow)$
l2 = $blockState(L2, snow)$
l3 = $blockState(L3, snow)$
l4 = $blockState(L4, snow)$
l5 = $blockState(L5, snow)$
l6 = $blockState(L6, snow)$
l7 = $blockState(L7, snow)$
l8 = $blockState(L8, snow)$
function isOpen(b)
if b == blocks.air then return true end
if b == blocks.cave_air then return true end
if b == blocks.void_air then return true end
return false
end
function hardBan(b)
if b == blocks.packed_ice then return true end
if b == blocks.blue_ice then return true end
if b == blocks.deepslate then return true end
if b == blocks.cobbled_deepslate then return true end
if b == blocks.polished_deepslate then return true end
if b == blocks.chiseled_deepslate then return true end
if b == blocks.deepslate_bricks then return true end
if b == blocks.cracked_deepslate_bricks then return true end
if b == blocks.deepslate_tiles then return true end
if b == blocks.cracked_deepslate_tiles then return true end
if b == blocks.reinforced_deepslate then return true end
if b == blocks.infested_deepslate then return true end
if b == blocks.deepslate_coal_ore then return true end
if b == blocks.deepslate_iron_ore then return true end
if b == blocks.deepslate_copper_ore then return true end
if b == blocks.deepslate_gold_ore then return true end
if b == blocks.deepslate_redstone_ore then return true end
if b == blocks.deepslate_emerald_ore then return true end
if b == blocks.deepslate_lapis_ore then return true end
if b == blocks.deepslate_diamond_ore then return true end
if b == blocks.lantern then return true end
if b == blocks.soul_lantern then return true end
return false
end
function denied(b, st)
if hardBan(b) then return true end
if b == deny1 or st == deny1 then return true end
if b == deny2 or st == deny2 then return true end
if b == deny3 or st == deny3 then return true end
if isBlockTagged then
if denySlabs and isBlockTagged(b, "slabs") then return true end
if denyStairs and isBlockTagged(b, "stairs") then return true end
if denyLeaves and isBlockTagged(b, "leaves") then return true end
if isBlockTagged(b, "fences") then return true end
if isBlockTagged(b, "walls") then return true end
if isBlockTagged(b, "fence_gates") then return true end
end
return false
end
function okGround(b, st)
if isOpen(b) then return false end
if b == blocks.water then return false end
if b == blocks.snow then return false end
if b == blocks.snow_block then return false end
if denied(b, st) then return false end
if isSolid(b) == false then return false end
return true
end
function layerOf(st)
if getBlockProperty then
v = getBlockProperty(st, "layers")
if v == "1" or v == 1 then return 1 end
if v == "2" or v == 2 then return 2 end
if v == "3" or v == 3 then return 3 end
if v == "4" or v == 4 then return 4 end
if v == "5" or v == 5 then return 5 end
if v == "6" or v == 6 then return 6 end
if v == "7" or v == 7 then return 7 end
if v == "8" or v == 8 then return 8 end
end
if st == l8 then return 8 end
if st == l7 then return 7 end
if st == l6 then return 6 end
if st == l5 then return 5 end
if st == l4 then return 4 end
if st == l3 then return 3 end
if st == l2 then return 2 end
return 1
end
function snowOf(n)
if n < 1 then n = 1 end
if n > 8 then n = 8 end
if withBlockProperty then
return withBlockProperty(blocks.snow, "layers=" .. n)
end
if n == 1 then return l1 end
if n == 2 then return l2 end
if n == 3 then return l3 end
if n == 4 then return l4 end
if n == 5 then return l5 end
if n == 6 then return l6 end
if n == 7 then return l7 end
return l8
end
function clearAbove(px, py, pz)
if skyOnly == false then
return true
end
t = 1
while t <= 120 do
if isOpen(getBlock(px, py + t, pz)) == false then
return false
end
t = t + 1
end
return true
end
function sideIsEdge(px, py, pz)
base = getBlock(px, py - 1, pz)
baseSt = getBlockState(px, py - 1, pz)
if isOpen(base) then
return true
end
if denied(base, baseSt) then
return true
end
if isSolid(base) == false then
return true
end
side = getBlock(px, py, pz)
sideSt = getBlockState(px, py, pz)
if side ~= blocks.snow and denied(side, sideSt) then
return true
end
return false
end
function edgeLimit(px, py, pz)
bad = 0
if sideIsEdge(px + 1, py, pz) then bad = bad + 1 end
if sideIsEdge(px - 1, py, pz) then bad = bad + 1 end
if sideIsEdge(px, py, pz + 1) then bad = bad + 1 end
if sideIsEdge(px, py, pz - 1) then bad = bad + 1 end
if bad >= 2 then
return 1
end
if bad == 1 then
return 2
end
return maxL
end
function putSnow(px, py, pz, n)
if n < 1 then
return
end
cap = edgeLimit(px, py, pz)
if n > cap then
n = cap
end
if n > maxL then
n = maxL
end
if n > 8 then
n = 8
end
if n < 1 then
return
end
setBlock(px, py, pz, snowOf(n))
end
function ensureAtLeast(px, py, pz, n)
if n < 1 then
return
end
if clearAbove(px, py, pz) == false then
return
end
n = n
cap = edgeLimit(px, py, pz)
if n > cap then
n = cap
end
here = getBlock(px, py, pz)
if here == blocks.snow then
cur = layerOf(getBlockState(px, py, pz))
if cur < n then
putSnow(px, py, pz, n)
end
return
end
if isOpen(here) then
base = getBlock(px, py - 1, pz)
baseSt = getBlockState(px, py - 1, pz)
if okGround(base, baseSt) then
putSnow(px, py, pz, n)
end
return
end
if denied(here, getBlockState(px, py, pz)) then
return
end
if okGround(here, getBlockState(px, py, pz)) == false then
return
end
above = getBlock(px, py + 1, pz)
if above == blocks.snow then
cur = layerOf(getBlockState(px, py + 1, pz))
if cur < n then
putSnow(px, py + 1, pz, n)
end
return
end
if isOpen(above) then
putSnow(px, py + 1, pz, n)
end
end
function slopeAround(px, py, pz, peak)
if peak < 3 then
return
end
need = peak - 1
if need < 1 then
need = 1
end
ensureAtLeast(px + 1, py, pz, need)
ensureAtLeast(px - 1, py, pz, need)
ensureAtLeast(px, py, pz + 1, need)
ensureAtLeast(px, py, pz - 1, need)
end
function addLayer(px, py, pz, current_limit)
n = layerOf(getBlockState(px, py, pz)) + 1
if n > current_limit then
return
end
if n > maxL then
return
end
if n > 8 then
return
end
cap = edgeLimit(px, py, pz)
if n > cap then
n = cap
end
putSnow(px, py, pz, n)
slopeAround(px, py, pz, n)
end
nse = getSimplexNoise(x * 0.15, 3, z * 0.15, 23)
if nse * 100 > dens then
return nil
end
noise_max = 1 + (nse * 100) / (dens / maxL)
noise_max = noise_max - noise_max % 1
if noise_max < 1 then
noise_max = 1
end
if noise_max > maxL then
noise_max = maxL
end
firstH = 1
if nse > 0.40 then
firstH = 2
end
if nse > 0.68 then
firstH = 3
end
if firstH > noise_max then
firstH = noise_max
end
if firstH > maxL then
firstH = maxL
end
b = getBlock(x, y, z)
st = getBlockState(x, y, z)
up = getBlock(x, y + 1, z)
dn = getBlock(x, y - 1, z)
dnSt = getBlockState(x, y - 1, z)
if b == blocks.snow then
if clearAbove(x, y, z) == false then
return nil
end
addLayer(x, y, z, noise_max)
return nil
end
if isOpen(b) == false then
if denied(b, st) then
return nil
end
if up == blocks.snow then
if clearAbove(x, y + 1, z) == false then
return nil
end
addLayer(x, y + 1, z, noise_max)
return nil
end
if isOpen(up) == false then
return nil
end
if okGround(b, st) == false then
return nil
end
if clearAbove(x, y, z) == false then
return nil
end
putSnow(x, y + 1, z, firstH)
slopeAround(x, y + 1, z, firstH)
return nil
end
if dn == blocks.snow then
if clearAbove(x, y - 1, z) == false then
return nil
end
addLayer(x, y - 1, z, noise_max)
return nil
end
if okGround(dn, dnSt) == false then
return nil
end
if clearAbove(x, y - 1, z) == false then
return nil
end
putSnow(x, y, z, firstH)
slopeAround(x, y, z, firstH)
return nil