forked from MineClone5/MineClone5
#365 Make compatibility run on minetest-5.1.1
This commit is contained in:
parent
a9ea0e8037
commit
42fe0441de
|
@ -4,26 +4,31 @@ mcl_vars = mcl_vars or {}
|
|||
local modname = minetest.get_current_modname()
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
local math = math
|
||||
local math_ceil = math.ceil
|
||||
local math_floor = math.floor
|
||||
local math_abs = math.abs
|
||||
local minetest_get_node = minetest.get_node
|
||||
|
||||
if not bit then
|
||||
bit = {}
|
||||
function bit.bxor(a, b)
|
||||
-- fake! mock! speedify for now! TODO: make proper xor bitwise
|
||||
return math.ceil(math.abs(math.floor(a/0.14) * b * 1.001 + b))
|
||||
return math_ceil(math_abs(math_floor(a/0.14) * b * 1.001 + b))
|
||||
end
|
||||
end
|
||||
|
||||
function math.round(x)
|
||||
if x >= 0 then
|
||||
return math.floor(x + 0.5)
|
||||
return math_floor(x + 0.5)
|
||||
end
|
||||
return math.ceil(x - 0.5)
|
||||
return math_ceil(x - 0.5)
|
||||
end
|
||||
|
||||
dofile(modpath .. "/vector.lua")
|
||||
|
||||
local minetest_get_node = minetest.get_node
|
||||
|
||||
mcl_compatibility.sort_nodes = function(nodes)
|
||||
local nodes = nodes
|
||||
if not nodes then return {} end
|
||||
for _, pos in pairs(nodes) do
|
||||
if not pos.x or not pos.y or not pos.z then
|
||||
|
@ -34,22 +39,28 @@ mcl_compatibility.sort_nodes = function(nodes)
|
|||
for _, pos in pairs(nodes) do
|
||||
local node = minetest_get_node(pos)
|
||||
local name = node.name
|
||||
if not new_nodes[name] then
|
||||
local ref = new_nodes[name]
|
||||
if not ref then
|
||||
new_nodes[name] = { pos }
|
||||
else
|
||||
table.insert(new_nodes[name], pos)
|
||||
ref[#ref + 1] = pos
|
||||
end
|
||||
end
|
||||
return new_nodes
|
||||
end
|
||||
|
||||
local sort_nodes = mcl_compatibility.sort_nodes
|
||||
|
||||
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
|
||||
minetest.find_nodes_in_area = function(pos1, pos2, nodenames, grouped)
|
||||
if not grouped then
|
||||
return minetest_find_nodes_in_area(pos1, pos2, nodenames)
|
||||
end
|
||||
local nodes, num = minetest_find_nodes_in_area(pos1, pos2, nodenames, grouped)
|
||||
if not grouped or not nodes or next(nodes) == nil then
|
||||
if not nodes or next(nodes) == nil then
|
||||
return nodes, num
|
||||
end
|
||||
return mcl_compatibility.sort_nodes(nodes)
|
||||
return sort_nodes(nodes)
|
||||
end
|
||||
|
||||
function mcl_vars.pos_to_block(pos)
|
||||
|
@ -65,7 +76,7 @@ function mcl_vars.get_chunk_number(pos)
|
|||
end
|
||||
|
||||
function mcl_vars.is_generated(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local node = minetest_get_node(pos)
|
||||
if not node then return false end
|
||||
if node.name == "ignore" then return false end
|
||||
return true
|
||||
|
@ -73,10 +84,10 @@ end
|
|||
|
||||
function mcl_vars.get_node(p, force, us_timeout)
|
||||
if not p or not p.x or not p.y or not p.z then return {name="error"} end
|
||||
local node = minetest.get_node(p)
|
||||
local node = minetest_get_node(p)
|
||||
if node.name ~= "ignore" then return node end
|
||||
minetest.get_voxel_manip():read_from_map(p, p)
|
||||
return minetest.get_node(pos)
|
||||
return minetest_get_node(pos)
|
||||
end
|
||||
|
||||
mcl_vars.mg_overworld_min = -62
|
||||
|
@ -98,3 +109,17 @@ mcl_vars.mg_end_platform_pos = { x = 100, y = -26999, z = 0 }
|
|||
mcl_vars.mg_realm_barrier_overworld_end_max = -2062
|
||||
mcl_vars.mg_realm_barrier_overworld_end_min = -2073
|
||||
mcl_vars.mg_dungeons = true
|
||||
|
||||
if not minetest.register_on_authplayer then
|
||||
minetest.register_on_authplayer = function(callback_function)
|
||||
minetest.register_on_prejoinplayer(function(name, ip)
|
||||
callback_function(name, ip, true)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if not minetest.colorspec_to_colorstring then
|
||||
minetest.colorspec_to_colorstring = function(colorspec)
|
||||
return '#334455'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = doc
|
||||
author = Wuzzy
|
||||
description = A simple in-game documentation system which enables mods to add help entries based on templates.
|
||||
optional_depends = unified_inventory, sfinv_buttons, central_message, inventory_plus
|
||||
optional_depends = unified_inventory, sfinv_buttons, central_message, inventory_plus, mcl_compatibility
|
||||
|
|
|
@ -2,3 +2,4 @@ name = mcl_meshhand
|
|||
author = jordan4ibanez
|
||||
description = Applies the player skin texture to the hand.
|
||||
depends = mcl_tools, mcl_skins
|
||||
optional_depends = mcl_compatibility
|
||||
|
|
Loading…
Reference in New Issue