merge upstream
This commit is contained in:
commit
2e451bd11e
236 changed files with 7780 additions and 2577 deletions
|
@ -1,5 +1,3 @@
|
|||
-- mods/default/functions.lua
|
||||
|
||||
--
|
||||
-- Sounds
|
||||
--
|
||||
|
@ -117,6 +115,21 @@ function default.node_sound_water_defaults(table)
|
|||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_snow_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name = "default_snow_footstep", gain = 0.2}
|
||||
table.dig = table.dig or
|
||||
{name = "default_snow_footstep", gain = 0.3}
|
||||
table.dug = table.dug or
|
||||
{name = "default_snow_footstep", gain = 0.3}
|
||||
table.place = table.place or
|
||||
{name = "default_place_node", gain = 1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Lavacooling
|
||||
--
|
||||
|
@ -149,7 +162,7 @@ if minetest.settings:get_bool("enable_lavacooling") ~= false then
|
|||
label = "Lava cooling",
|
||||
nodenames = {"default:lava_source", "default:lava_flowing"},
|
||||
neighbors = {"group:cools_lava", "group:water"},
|
||||
interval = 1,
|
||||
interval = 2,
|
||||
chance = 2,
|
||||
catch_up = false,
|
||||
action = function(...)
|
||||
|
@ -158,8 +171,9 @@ if minetest.settings:get_bool("enable_lavacooling") ~= false then
|
|||
})
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- 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)
|
||||
|
@ -174,11 +188,12 @@ function default.get_inventory_drops(pos, inventory, drops)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Papyrus and cactus growing
|
||||
--
|
||||
|
||||
-- wrapping the functions in abm action is necessary to make overriding them possible
|
||||
-- Wrapping the functions in ABM action is necessary to make overriding them possible
|
||||
|
||||
function default.grow_cactus(pos, node)
|
||||
if node.param2 >= 4 then
|
||||
|
@ -255,7 +270,7 @@ minetest.register_abm({
|
|||
|
||||
|
||||
--
|
||||
-- dig upwards
|
||||
-- Dig upwards
|
||||
--
|
||||
|
||||
function default.dig_up(pos, node, digger)
|
||||
|
@ -286,7 +301,22 @@ function default.register_fence(name, def)
|
|||
-- Allow almost everything to be overridden
|
||||
local default_fields = {
|
||||
paramtype = "light",
|
||||
drawtype = "fencelike",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
|
||||
-- connect_top =
|
||||
-- connect_bottom =
|
||||
connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
|
||||
{-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
|
||||
connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
|
||||
{-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
|
||||
connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
|
||||
{-1/16,-5/16,1/8,1/16,-3/16,1/2}},
|
||||
connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
|
||||
{1/8,-5/16,-1/16,1/2,-3/16,1/16}},
|
||||
},
|
||||
connects_to = {"group:fence", "group:wood", "group:tree", "group:wall"},
|
||||
inventory_image = fence_texture,
|
||||
wield_image = fence_texture,
|
||||
tiles = { def.texture },
|
||||
|
@ -299,7 +329,72 @@ function default.register_fence(name, def)
|
|||
groups = {},
|
||||
}
|
||||
for k, v in pairs(default_fields) do
|
||||
if not def[k] then
|
||||
if def[k] == nil then
|
||||
def[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
-- Always add to the fence group, even if no group provided
|
||||
def.groups.fence = 1
|
||||
|
||||
def.texture = nil
|
||||
def.material = nil
|
||||
|
||||
minetest.register_node(name, def)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Fence rail registration helper
|
||||
--
|
||||
|
||||
function default.register_fence_rail(name, def)
|
||||
minetest.register_craft({
|
||||
output = name .. " 16",
|
||||
recipe = {
|
||||
{ def.material, def.material },
|
||||
{ "", ""},
|
||||
{ def.material, def.material },
|
||||
}
|
||||
})
|
||||
|
||||
local fence_rail_texture = "default_fence_rail_overlay.png^" .. def.texture ..
|
||||
"^default_fence_rail_overlay.png^[makealpha:255,126,126"
|
||||
-- Allow almost everything to be overridden
|
||||
local default_fields = {
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {
|
||||
{-1/16, 3/16, -1/16, 1/16, 5/16, 1/16},
|
||||
{-1/16, -3/16, -1/16, 1/16, -5/16, 1/16}
|
||||
},
|
||||
-- connect_top =
|
||||
-- connect_bottom =
|
||||
connect_front = {
|
||||
{-1/16, 3/16, -1/2, 1/16, 5/16, -1/16},
|
||||
{-1/16, -5/16, -1/2, 1/16, -3/16, -1/16}},
|
||||
connect_left = {
|
||||
{-1/2, 3/16, -1/16, -1/16, 5/16, 1/16},
|
||||
{-1/2, -5/16, -1/16, -1/16, -3/16, 1/16}},
|
||||
connect_back = {
|
||||
{-1/16, 3/16, 1/16, 1/16, 5/16, 1/2},
|
||||
{-1/16, -5/16, 1/16, 1/16, -3/16, 1/2}},
|
||||
connect_right = {
|
||||
{1/16, 3/16, -1/16, 1/2, 5/16, 1/16},
|
||||
{1/16, -5/16, -1/16, 1/2, -3/16, 1/16}},
|
||||
},
|
||||
connects_to = {"group:fence", "group:wall"},
|
||||
inventory_image = fence_rail_texture,
|
||||
wield_image = fence_rail_texture,
|
||||
tiles = {def.texture},
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {},
|
||||
}
|
||||
for k, v in pairs(default_fields) do
|
||||
if def[k] == nil then
|
||||
def[k] = v
|
||||
end
|
||||
end
|
||||
|
@ -321,7 +416,7 @@ end
|
|||
-- Prevent decay of placed leaves
|
||||
|
||||
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if placer and placer:is_player() and not placer:get_player_control().sneak then
|
||||
local node = minetest.get_node(pos)
|
||||
node.param2 = 1
|
||||
minetest.set_node(pos, node)
|
||||
|
@ -388,6 +483,7 @@ function default.register_leafdecay(def)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Convert dirt to something that fits the environment
|
||||
--
|
||||
|
@ -488,63 +584,7 @@ minetest.register_abm({
|
|||
|
||||
|
||||
--
|
||||
-- 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
|
||||
|
||||
|
||||
--
|
||||
-- Coral death near air
|
||||
--
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:coral_brown", "default:coral_orange"},
|
||||
neighbors = {"air"},
|
||||
interval = 17,
|
||||
chance = 5,
|
||||
catch_up = false,
|
||||
action = function(pos, node)
|
||||
minetest.set_node(pos, {name = "default:coral_skeleton"})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
-- NOTICE: This method is not an official part of the API yet!
|
||||
-- NOTICE: This method is not an official part of the API yet.
|
||||
-- This method may change in future.
|
||||
--
|
||||
|
||||
|
@ -564,7 +604,7 @@ function default.can_interact_with_node(player, pos)
|
|||
return true
|
||||
end
|
||||
|
||||
-- is player wielding the right key?
|
||||
-- Is player wielding the right key?
|
||||
local item = player:get_wielded_item()
|
||||
if item:get_name() == "default:key" then
|
||||
local key_meta = item:get_meta()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue