Commit 5bd9eac0 authored by ClaudiusMinimus's avatar ClaudiusMinimus
Browse files

merged in master

parents e695ad8c 4cb83e53
Pipeline #345 failed with stage
...@@ -41,8 +41,6 @@ minetest.register_alias("locked_chest", "default:chest_locked") ...@@ -41,8 +41,6 @@ minetest.register_alias("locked_chest", "default:chest_locked")
minetest.register_alias("cobble", "default:cobble") minetest.register_alias("cobble", "default:cobble")
minetest.register_alias("mossycobble", "default:mossycobble") minetest.register_alias("mossycobble", "default:mossycobble")
minetest.register_alias("steelblock", "default:steelblock") minetest.register_alias("steelblock", "default:steelblock")
minetest.register_alias("nyancat", "default:nyancat")
minetest.register_alias("nyancat_rainbow", "default:nyancat_rainbow")
minetest.register_alias("sapling", "default:sapling") minetest.register_alias("sapling", "default:sapling")
minetest.register_alias("apple", "default:apple") minetest.register_alias("apple", "default:apple")
...@@ -79,4 +77,3 @@ minetest.register_alias("default:pinewood", "default:pine_wood") ...@@ -79,4 +77,3 @@ minetest.register_alias("default:pinewood", "default:pine_wood")
minetest.register_alias("default:ladder", "default:ladder_wood") minetest.register_alias("default:ladder", "default:ladder_wood")
minetest.register_alias("default:sign_wall", "default:sign_wall_wood") minetest.register_alias("default:sign_wall", "default:sign_wall_wood")
...@@ -888,18 +888,6 @@ minetest.register_craft({ ...@@ -888,18 +888,6 @@ minetest.register_craft({
burntime = 30, burntime = 30,
}) })
minetest.register_craft({
type = "fuel",
recipe = "default:nyancat",
burntime = 1,
})
minetest.register_craft({
type = "fuel",
recipe = "default:nyancat_rainbow",
burntime = 1,
})
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "group:sapling", recipe = "group:sapling",
...@@ -935,4 +923,3 @@ minetest.register_craft({ ...@@ -935,4 +923,3 @@ minetest.register_craft({
recipe = "default:dry_grass_1", recipe = "default:dry_grass_1",
burntime = 2, burntime = 2,
}) })
...@@ -120,6 +120,7 @@ default.cool_lava = function(pos, node) ...@@ -120,6 +120,7 @@ default.cool_lava = function(pos, node)
end end
minetest.register_abm({ minetest.register_abm({
label = "Lava cooling",
nodenames = {"default:lava_source", "default:lava_flowing"}, nodenames = {"default:lava_source", "default:lava_flowing"},
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 1, interval = 1,
...@@ -134,6 +135,7 @@ minetest.register_abm({ ...@@ -134,6 +135,7 @@ minetest.register_abm({
-- --
-- optimized helper to put all items in an inventory into a drops list -- optimized helper to put all items in an inventory into a drops list
-- --
function default.get_inventory_drops(pos, inventory, drops) function default.get_inventory_drops(pos, inventory, drops)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
local n = #drops local n = #drops
...@@ -198,6 +200,7 @@ function default.grow_papyrus(pos, node) ...@@ -198,6 +200,7 @@ function default.grow_papyrus(pos, node)
end end
minetest.register_abm({ minetest.register_abm({
label = "Grow cactus",
nodenames = {"default:cactus"}, nodenames = {"default:cactus"},
neighbors = {"group:sand"}, neighbors = {"group:sand"},
interval = 12, interval = 12,
...@@ -208,6 +211,7 @@ minetest.register_abm({ ...@@ -208,6 +211,7 @@ minetest.register_abm({
}) })
minetest.register_abm({ minetest.register_abm({
label = "Grow papyrus",
nodenames = {"default:papyrus"}, nodenames = {"default:papyrus"},
neighbors = {"default:dirt", "default:dirt_with_grass"}, neighbors = {"default:dirt", "default:dirt_with_grass"},
interval = 14, interval = 14,
...@@ -235,6 +239,7 @@ end ...@@ -235,6 +239,7 @@ end
-- --
-- Fence registration helper -- Fence registration helper
-- --
function default.register_fence(name, def) function default.register_fence(name, def)
minetest.register_craft({ minetest.register_craft({
output = name .. " 4", output = name .. " 4",
...@@ -281,16 +286,7 @@ end ...@@ -281,16 +286,7 @@ end
-- Leafdecay -- Leafdecay
-- --
default.leafdecay_trunk_cache = {} -- Prevent decay of placed leaves
default.leafdecay_enable_cache = true
-- Spread the load of finding trunks
default.leafdecay_trunk_find_allow_accumulator = 0
minetest.register_globalstep(function(dtime)
local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second)
end)
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
if placer and not placer:get_player_control().sneak then if placer and not placer:get_player_control().sneak then
...@@ -300,79 +296,44 @@ default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) ...@@ -300,79 +296,44 @@ default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
end end
end end
-- Leafdecay ABM
minetest.register_abm({ minetest.register_abm({
label = "Leaf decay",
nodenames = {"group:leafdecay"}, nodenames = {"group:leafdecay"},
neighbors = {"air", "group:liquid"}, neighbors = {"air"},
-- A low interval and a high inverse chance spreads the load
interval = 2, interval = 2,
chance = 5, chance = 10,
catch_up = false,
action = function(p0, node, _, _)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")") action = function(pos, node, _, _)
local do_preserve = false -- Check if leaf is placed
local d = minetest.registered_nodes[node.name].groups.leafdecay if node.param2 ~= 0 then
if not d or d == 0 then
--print("not groups.leafdecay")
return
end
local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return return
end end
local p0_hash = nil
if default.leafdecay_enable_cache then local rad = minetest.registered_nodes[node.name].groups.leafdecay
p0_hash = minetest.hash_node_position(p0) -- Assume ignore is a trunk, to make this
local trunkp = default.leafdecay_trunk_cache[p0_hash] -- work at the border of a loaded area
if trunkp then if minetest.find_node_near(pos, rad, {"ignore", "group:tree"}) then
local n = minetest.get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing
-- work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and
reg.groups.tree ~= 0) then
--print("cached trunk still exists")
return
end
--print("cached trunk is invalid")
-- Cache is invalid
table.remove(default.leafdecay_trunk_cache, p0_hash)
end
end
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
return return
end end
default.leafdecay_trunk_find_allow_accumulator = -- Drop stuff
default.leafdecay_trunk_find_allow_accumulator - 1 local itemstacks = minetest.get_node_drops(node.name)
-- Assume ignore is a trunk, to make the thing for _, itemname in ipairs(itemstacks) do
-- work at the border of the active area if itemname ~= node.name or
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"}) minetest.get_item_group(node.name, "leafdecay_drop") ~= 0 then
if p1 then local p_drop = {
do_preserve = true x = pos.x - 0.5 + math.random(),
if default.leafdecay_enable_cache then y = pos.y - 0.5 + math.random(),
--print("caching trunk") z = pos.z - 0.5 + math.random(),
-- Cache the trunk }
default.leafdecay_trunk_cache[p0_hash] = p1 minetest.add_item(p_drop, itemname)
end
end
if not do_preserve then
-- Drop stuff other than the node itself
local itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
itemname ~= n0.name then
local p_drop = {
x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(),
}
minetest.add_item(p_drop, itemname)
end
end end
-- Remove node
minetest.remove_node(p0)
nodeupdate(p0)
end end
-- Remove node
minetest.remove_node(pos)
nodeupdate(pos)
end end
}) })
...@@ -382,6 +343,7 @@ minetest.register_abm({ ...@@ -382,6 +343,7 @@ minetest.register_abm({
-- --
minetest.register_abm({ minetest.register_abm({
label = "Grass spread",
nodenames = {"default:dirt"}, nodenames = {"default:dirt"},
neighbors = { neighbors = {
"default:dirt_with_grass", "default:dirt_with_grass",
...@@ -433,11 +395,13 @@ minetest.register_abm({ ...@@ -433,11 +395,13 @@ minetest.register_abm({
end end
}) })
-- --
-- Grass and dry grass removed in darkness -- Grass and dry grass removed in darkness
-- --
minetest.register_abm({ minetest.register_abm({
label = "Grass covered",
nodenames = { nodenames = {
"default:dirt_with_grass", "default:dirt_with_grass",
"default:dirt_with_dry_grass", "default:dirt_with_dry_grass",
...@@ -464,6 +428,7 @@ minetest.register_abm({ ...@@ -464,6 +428,7 @@ minetest.register_abm({
-- --
minetest.register_abm({ minetest.register_abm({
label = "Moss growth",
nodenames = {"default:cobble", "stairs:slab_cobble", "stairs:stair_cobble"}, nodenames = {"default:cobble", "stairs:slab_cobble", "stairs:stair_cobble"},
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 16, interval = 16,
...@@ -479,3 +444,43 @@ minetest.register_abm({ ...@@ -479,3 +444,43 @@ minetest.register_abm({
end end
end end
}) })
--
-- Checks if specified volume intersects a protected volume
--
function default.intersects_protection(minp, maxp, player_name, interval)
-- 'interval' is the largest allowed interval for the 3D lattice of checks
-- Compute the optimal float step 'd' for each axis so that all corners and
-- borders are checked. 'd' will be smaller or equal to 'interval'.
-- Subtracting 1e-4 ensures that the max co-ordinate will be reached by the
-- for loop (which might otherwise not be the case due to rounding errors).
local d = {}
for _, c in pairs({"x", "y", "z"}) do
if maxp[c] > minp[c] then
d[c] = (maxp[c] - minp[c]) / math.ceil((maxp[c] - minp[c]) / interval) - 1e-4
elseif maxp[c] == minp[c] then
d[c] = 1 -- Any value larger than 0 to avoid division by zero
else -- maxp[c] < minp[c], print error and treat as protection intersected
minetest.log("error", "maxp < minp in 'default.intersects_protection()'")
return true
end
end
for zf = minp.z, maxp.z, d.z do
local z = math.floor(zf + 0.5)
for yf = minp.y, maxp.y, d.y do
local y = math.floor(yf + 0.5)
for xf = minp.x, maxp.x, d.x do
local x = math.floor(xf + 0.5)
if minetest.is_protected({x = x, y = y, z = z}, player_name) then
return true
end
end
end
end
return false
end
...@@ -35,14 +35,16 @@ default.gui_survival_form = "size[8,8.5]".. ...@@ -35,14 +35,16 @@ default.gui_survival_form = "size[8,8.5]"..
default.get_hotbar_bg(0,4.25) default.get_hotbar_bg(0,4.25)
-- Load files -- Load files
dofile(minetest.get_modpath("default").."/functions.lua") local default_path = minetest.get_modpath("default")
dofile(minetest.get_modpath("default").."/trees.lua")
dofile(minetest.get_modpath("default").."/nodes.lua") dofile(default_path.."/functions.lua")
dofile(minetest.get_modpath("default").."/furnace.lua") dofile(default_path.."/trees.lua")
dofile(minetest.get_modpath("default").."/tools.lua") dofile(default_path.."/nodes.lua")
dofile(minetest.get_modpath("default").."/craftitems.lua") dofile(default_path.."/furnace.lua")
dofile(minetest.get_modpath("default").."/crafting.lua") dofile(default_path.."/tools.lua")
dofile(minetest.get_modpath("default").."/mapgen.lua") dofile(default_path.."/craftitems.lua")
dofile(minetest.get_modpath("default").."/player.lua") dofile(default_path.."/crafting.lua")
dofile(minetest.get_modpath("default").."/aliases.lua") dofile(default_path.."/mapgen.lua")
dofile(minetest.get_modpath("default").."/legacy.lua") dofile(default_path.."/player.lua")
dofile(default_path.."/aliases.lua")
dofile(default_path.."/legacy.lua")
...@@ -49,7 +49,7 @@ function default.register_ores() ...@@ -49,7 +49,7 @@ function default.register_ores()
-- Clay -- Clay
-- This first to avoid clay in sand blobs -- This first to avoid clay in sand blobs
minetest.register_ore({ minetest.register_ore({
ore_type = "blob", ore_type = "blob",
ore = "default:clay", ore = "default:clay",
wherein = {"default:sand"}, wherein = {"default:sand"},
...@@ -70,7 +70,7 @@ function default.register_ores() ...@@ -70,7 +70,7 @@ function default.register_ores()
-- Sand -- Sand
minetest.register_ore({ minetest.register_ore({
ore_type = "blob", ore_type = "blob",
ore = "default:sand", ore = "default:sand",
wherein = {"default:stone", "default:sandstone", wherein = {"default:stone", "default:sandstone",
...@@ -1464,73 +1464,16 @@ function default.register_decorations() ...@@ -1464,73 +1464,16 @@ function default.register_decorations()
end end
--
-- Generate nyan cats
--
-- All mapgens except singlenode
function default.make_nyancat(pos, facedir, length)
local tailvec = {x = 0, y = 0, z = 0}
if facedir == 0 then
tailvec.z = 1
elseif facedir == 1 then
tailvec.x = 1
elseif facedir == 2 then
tailvec.z = -1
elseif facedir == 3 then
tailvec.x = -1
else
facedir = 0
tailvec.z = 1
end
local p = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(p, {name = "default:nyancat", param2 = facedir})
for i = 1, length do
p.x = p.x + tailvec.x
p.z = p.z + tailvec.z
minetest.set_node(p, {name = "default:nyancat_rainbow", param2 = facedir})
end
end
function default.generate_nyancats(minp, maxp, seed)
local height_min = -31000
local height_max = -32
if maxp.y < height_min or minp.y > height_max then
return
end
local y_min = math.max(minp.y, height_min)
local y_max = math.min(maxp.y, height_max)
local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
local pr = PseudoRandom(seed + 9324342)
local max_num_nyancats = math.floor(volume / (16 * 16 * 16))
for i = 1, max_num_nyancats do
if pr:next(0, 1000) == 0 then
local x0 = pr:next(minp.x, maxp.x)
local y0 = pr:next(minp.y, maxp.y)
local z0 = pr:next(minp.z, maxp.z)
local p0 = {x = x0, y = y0, z = z0}
default.make_nyancat(p0, pr:next(0, 3), pr:next(3, 15))
end
end
end
-- --
-- Detect mapgen to select functions -- Detect mapgen to select functions
-- --
-- Mods using singlenode mapgen can call these functions to enable
-- the use of minetest.generate_ores or minetest.generate_decorations
local mg_name = minetest.get_mapgen_setting("mg_name") local mg_name = minetest.get_mapgen_setting("mg_name")
if mg_name == "v6" then if mg_name == "v6" then
default.register_ores() default.register_ores()
default.register_mgv6_decorations() default.register_mgv6_decorations()
minetest.register_on_generated(default.generate_nyancats) else
elseif mg_name ~= "singlenode" then
default.register_biomes() default.register_biomes()
default.register_ores() default.register_ores()
default.register_decorations() default.register_decorations()
minetest.register_on_generated(default.generate_nyancats)
end end
...@@ -178,8 +178,6 @@ Misc ...@@ -178,8 +178,6 @@ Misc
---- ----
default:cloud default:cloud
default:nyancat
default:nyancat_rainbow
--]] --]]
...@@ -424,6 +422,7 @@ minetest.register_node("default:snow", { ...@@ -424,6 +422,7 @@ minetest.register_node("default:snow", {
paramtype = "light", paramtype = "light",
buildable_to = true, buildable_to = true,
floodable = true, floodable = true,
walkable = false,
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
...@@ -487,7 +486,7 @@ minetest.register_node("default:wood", { ...@@ -487,7 +486,7 @@ minetest.register_node("default:wood", {
place_param2 = 0, place_param2 = 0,
tiles = {"default_wood.png"}, tiles = {"default_wood.png"},
is_ground_content = false, is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1}, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
...@@ -502,9 +501,6 @@ minetest.register_node("default:sapling", { ...@@ -502,9 +501,6 @@ minetest.register_node("default:sapling", {
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
on_timer = default.grow_sapling, on_timer = default.grow_sapling,
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
end,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
...@@ -512,6 +508,23 @@ minetest.register_node("default:sapling", { ...@@ -512,6 +508,23 @@ minetest.register_node("default:sapling", {
groups = {snappy = 2, dig_immediate = 3, flammable = 2, groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1}, attached_node = 1, sapling = 1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
end,
on_place = function(itemstack, placer, pointed_thing)
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
"default:sapling",
-- minp, maxp to be checked, relative to sapling pos
-- minp_relative.y = 1 because sapling pos has been checked
{x = -2, y = 1, z = -2},
{x = 2, y = 6, z = 2},
-- maximum interval of interior volume check
4)
return itemstack
end,
}) })
minetest.register_node("default:leaves", { minetest.register_node("default:leaves", {
...@@ -589,7 +602,7 @@ minetest.register_node("default:junglewood", { ...@@ -589,7 +602,7 @@ minetest.register_node("default:junglewood", {
place_param2 = 0, place_param2 = 0,
tiles = {"default_junglewood.png"}, tiles = {"default_junglewood.png"},
is_ground_content = false, is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1}, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
...@@ -626,9 +639,6 @@ minetest.register_node("default:junglesapling", { ...@@ -626,9 +639,6 @@ minetest.register_node("default:junglesapling", {
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
on_timer = default.grow_sapling, on_timer = default.grow_sapling,
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
end,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
...@@ -636,6 +646,23 @@ minetest.register_node("default:junglesapling", { ...@@ -636,6 +646,23 @@ minetest.register_node("default:junglesapling", {
groups = {snappy = 2, dig_immediate = 3, flammable = 2, groups = {snappy = 2, dig_immediate = 3, flammable = 2,
attached_node = 1, sapling = 1}, attached_node = 1, sapling = 1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
end,
on_place = function(itemstack, placer, pointed_thing)
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
"default:junglesapling",
-- minp, maxp to be checked, relative to sapling pos
-- minp_relative.y = 1 because sapling pos has been checked