Move world-related functions to mcl_worlds

This commit is contained in:
Wuzzy 2017-11-24 03:10:02 +01:00
parent 06ef86ddd3
commit b0c87f74fe
35 changed files with 212 additions and 202 deletions

View file

@ -2,7 +2,7 @@ mcl_init
mesecons
mcl_sounds
mcl_tnt
mcl_util
mcl_worlds
mcl_core
mcl_nether
3d_armor_stand

View file

@ -173,7 +173,7 @@ local dispenserdef = {
elseif iname == "mcl_buckets:bucket_water" or iname == "mcl_buckets:bucket_lava" then
-- Place water/lava source
if dropnodedef.buildable_to then
local _, dim = mcl_util.y_to_layer(droppos.y)
local dim = mcl_worlds.pos_to_dimension(droppos)
if iname == "mcl_buckets:bucket_water" then
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = droppos, gain = 0.25, max_hear_distance = 16})

View file

@ -1,5 +1,5 @@
mcl_sounds?
mcl_util?
mcl_worlds?
mcl_wool?
mcl_dye?
mcl_tnt?

View file

@ -162,8 +162,8 @@ function mcl_beds.on_rightclick(pos, player)
if player:get_attribute("mcl_beds:sleeping") == "true" then
return
end
if minetest.get_modpath("mcl_init") then
local _, dim = mcl_util.y_to_layer(pos.y)
if minetest.get_modpath("mcl_worlds") then
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" or dim == "end" then
-- Bed goes BOOM in the Nether or End.
minetest.remove_node(pos)

View file

@ -1,2 +1,3 @@
mcl_worlds
mcl_core?
doc?

View file

@ -251,7 +251,7 @@ if mod_mcl_core then
return false
-- Evaporate water if used in Nether (except on cauldron)
else
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16})
return false
@ -263,7 +263,7 @@ if mod_mcl_core then
-- Lava bucket
mcl_buckets.register_liquid(
function(pos)
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" then
return "mcl_nether:nether_lava_source"
else

View file

@ -1,4 +1,4 @@
mcl_init
mcl_util
mcl_worlds
mesecons
doc?

View file

@ -89,10 +89,10 @@ minetest.register_globalstep(function(dtime)
local players = minetest.get_connected_players()
for p, player in ipairs(players) do
for s, stack in ipairs(player:get_inventory():get_list("main")) do
local _, dim = mcl_util.y_to_layer(player:getpos().y)
local dim = mcl_worlds.pos_to_dimension(player:get_pos())
local frame
-- Clocks do not work in certain zones
if not mcl_util.clock_works(player:getpos()) then
if not mcl_worlds.clock_works(player:getpos()) then
frame = random_frame
else
frame = now

View file

@ -1,4 +1,4 @@
mcl_core
mcl_util
mcl_worlds
mesecons
doc?

View file

@ -29,10 +29,10 @@ minetest.register_globalstep(function(dtime)
end
if has_compass(player) then
local pos = player:getpos()
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local compass_image
-- Compasses do not work in certain zones
if not mcl_util.compass_works(pos) then
if not mcl_worlds.compass_works(pos) then
compass_image = random_frame
else
local spawn = {x=0,y=0,z=0}

View file

@ -1,5 +1,6 @@
mcl_init
mcl_sounds
mcl_util
mcl_worlds
doc_items
doc?

View file

@ -321,7 +321,7 @@ minetest.register_node("mcl_core:dirt_with_grass", {
footstep = {name="default_grass_footstep", gain=0.4},
}),
on_construct = function(pos)
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local dry
if dim == "nether" then
dry = true
@ -651,7 +651,7 @@ minetest.register_node("mcl_core:bedrock", {
end,
_on_ignite = function(player, pointed_thing)
local pos = pointed_thing.under
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z}
local fn = minetest.get_node(flame_pos)
if dim == "end" and fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then
@ -788,7 +788,7 @@ minetest.register_node("mcl_core:ice", {
-- Create a water source if ice is destroyed and there was something below it
local below = {x=pos.x, y=pos.y-1, z=pos.z}
local belownode = minetest.get_node(below)
local _, dim = mcl_util.y_to_layer(below.y)
local dim = mcl_worlds.pos_to_dimension(below)
if dim ~= "nether" and belownode.name ~= "air" and belownode.name ~= "ignore" and belownode.name ~= "mcl_core:void" then
minetest.set_node(pos, {name="mcl_core:water_source"})
end
@ -817,7 +817,7 @@ for i=0,3 do
-- Increase age of frosted age or turn to water source if too old
local nn = minetest.get_node(pos).name
local age = tonumber(string.sub(nn, -1))
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if age == nil then return end
if age < 3 then
minetest.swap_node(pos, { name = "mcl_core:frosted_ice_"..(age+1) })

View file

@ -1,4 +1,4 @@
mcl_core
mcl_util
mcl_worlds
mcl_sounds
mcl_portals?

View file

@ -77,7 +77,7 @@ minetest.register_node("mcl_fire:fire", {
local bpos = {x=pos.x, y=pos.y-1, z=pos.z}
local under = minetest.get_node(bpos).name
local _, dim = mcl_util.y_to_layer(bpos.y)
local dim = mcl_worlds.pos_to_dimension(bpos)
if under == "mcl_nether:magma" or under == "mcl_nether:netherrack" or (under == "mcl_core:bedrock" and dim == "end") then
minetest.swap_node(pos, {name = "mcl_fire:eternal_fire"})
end

View file

@ -1,5 +1,5 @@
mcl_init
mcl_util
mcl_worlds
mcl_core
mcl_nether
mcl_end

View file

@ -200,7 +200,7 @@ minetest.register_abm({
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel
if obj:is_player() or lua_entity then
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
local objpos = obj:getpos()
if objpos == nil then
@ -263,7 +263,7 @@ minetest.register_abm({
-- Teleport
obj:set_pos(target)
if obj:is_player() then
-- Look towards the End island
-- Look towards the main End island
if dim ~= "end" then
obj:set_look_horizontal(math.pi/2)
end

View file

@ -289,7 +289,7 @@ end
-- Returns true on success and false on failure.
function mcl_portals.light_nether_portal(pos)
-- Only allow to make portals in Overworld and Nether
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim ~= "overworld" and dim ~= "nether" then
return false
end
@ -433,7 +433,7 @@ minetest.register_abm({
end
-- Teleport
obj:setpos(target)
obj:set_pos(target)
if obj:is_player() then
minetest.sound_play("mcl_portals_teleport", {pos=target, gain=0.5, max_hear_distance = 16})
end
@ -469,7 +469,7 @@ minetest.override_item("mcl_core:obsidian", {
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal")
-- Achievement for finishing a Nether portal TO the Nether
local _, dim = mcl_util.y_to_layer(pos.y)
local dim = mcl_worlds.pos_to_dimension(pos)
if minetest.get_modpath("awards") and dim ~= "nether" and user:is_player() then
awards.unlock(user:get_player_name(), "mcl:buildNetherPortal")
end