forked from MineClone5/MineClone5
Merge remote-tracking branch 'origin/production'
This commit is contained in:
commit
8e7a4bc677
|
@ -117,7 +117,7 @@ local function filter_item(name, description, lang, filter)
|
|||
else
|
||||
desc = string.lower(minetest.get_translated_string(lang, description))
|
||||
end
|
||||
return string.find(name, filter) or string.find(desc, filter)
|
||||
return string.find(name, filter, nil, true) or string.find(desc, filter, nil, true)
|
||||
end
|
||||
|
||||
local function set_inv_search(filter, player)
|
||||
|
|
|
@ -10,7 +10,7 @@ minetest.register_entity("mcl_end:ender_eye", {
|
|||
|
||||
-- Save and restore age
|
||||
get_staticdata = function(self)
|
||||
return tostring(self._age)
|
||||
return tostring(self._age) or "0"
|
||||
end,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
local age = tonumber(staticdata)
|
||||
|
|
|
@ -2,6 +2,25 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
|||
|
||||
local table = table
|
||||
|
||||
local interval = 35
|
||||
local chance = 11
|
||||
local max_interval = interval * chance
|
||||
|
||||
local time_speed
|
||||
local time_multiplier
|
||||
local current_game_time
|
||||
|
||||
function update_timespeed()
|
||||
time_speed = tonumber(minetest.settings:get("time_speed") or 72)
|
||||
time_multiplier = 86400 / time_speed
|
||||
current_game_time = .0 + ((minetest.get_day_count() + minetest.get_timeofday()) * time_multiplier)
|
||||
minetest.after(5, update_timespeed)
|
||||
end
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
minetest.after(5, update_timespeed)
|
||||
end)
|
||||
|
||||
minetest.register_node("mcl_nether:nether_wart_0", {
|
||||
description = S("Premature Nether Wart (Stage 1)"),
|
||||
_doc_items_longdesc = S("A premature nether wart has just recently been planted on soul sand. Nether wart slowly grows on soul sand in 4 stages (the second and third stages look identical). Although nether wart is home to the Nether, it grows in any dimension."),
|
||||
|
@ -148,35 +167,68 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", {
|
|||
|
||||
local names = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"}
|
||||
|
||||
local function grow(pos, node)
|
||||
local step = nil
|
||||
for i, name in ipairs(names) do
|
||||
if name == node.name then
|
||||
step = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if not step then return end
|
||||
local new_node = {name = names[step + 1]}
|
||||
if not new_node.name then
|
||||
new_node.name = "mcl_nether:nether_wart"
|
||||
end
|
||||
new_node.param = node.param
|
||||
new_node.param2 = node.param2
|
||||
minetest.set_node(pos, new_node)
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Nether wart growth",
|
||||
nodenames = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"},
|
||||
neighbors = {"group:soil_nether_wart"},
|
||||
interval = 35,
|
||||
chance = 11,
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y-1
|
||||
if minetest.get_item_group(minetest.get_node(pos).name, "soil_nether_wart") == 0 then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
local step = nil
|
||||
for i,name in ipairs(names) do
|
||||
if name == node.name then
|
||||
step = i
|
||||
break
|
||||
grow(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("gametime", tostring(current_game_time))
|
||||
end
|
||||
end
|
||||
if step == nil then
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "Nether wart growth update",
|
||||
name = "mcl_nether:growth_warts",
|
||||
nodenames = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y-1
|
||||
if minetest.get_item_group(minetest.get_node(pos).name, "soil_nether_wart") == 0 then
|
||||
return
|
||||
end
|
||||
local new_node = {name=names[step+1]}
|
||||
if new_node.name == nil then
|
||||
new_node.name = "mcl_nether:nether_wart"
|
||||
pos.y = pos.y+1
|
||||
local meta = minetest.get_meta(pos)
|
||||
local last_game_time = tonumber(meta:get_string("gametime"))
|
||||
if not last_game_time then return end
|
||||
|
||||
local real_seconds = last_game_time - current_game_time
|
||||
if real_seconds < interval then return end
|
||||
|
||||
local threshold = math.random(interval, max_interval)
|
||||
local i = 0
|
||||
while real_seconds >= threshold and i < 4 do
|
||||
grow(pos, node)
|
||||
real_seconds = real_seconds - threshold
|
||||
threshold = math.random(interval, max_interval)
|
||||
i = i + 1
|
||||
end
|
||||
new_node.param = node.param
|
||||
new_node.param2 = node.param2
|
||||
minetest.set_node(pos, new_node)
|
||||
end
|
||||
})
|
||||
|
||||
|
|
|
@ -1224,13 +1224,7 @@ local function generate_underground_mushrooms(minp, maxp, seed)
|
|||
end
|
||||
end
|
||||
|
||||
local nether_wart_chance
|
||||
if v6 then
|
||||
nether_wart_chance = 85
|
||||
else
|
||||
nether_wart_chance = 170
|
||||
end
|
||||
-- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart
|
||||
-- Generate Nether decorations manually: Eternal fire, mushrooms
|
||||
-- Minetest's API does not support decorations in caves yet. :-(
|
||||
local function generate_nether_decorations(minp, maxp, seed)
|
||||
if c_nether == nil then
|
||||
|
@ -1292,15 +1286,6 @@ local function generate_nether_decorations(minp, maxp, seed)
|
|||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Nether wart on soul sand
|
||||
-- TODO: Spawn in Nether fortresses
|
||||
special_deco(ssand, function(bpos)
|
||||
if pr_nether:next(1, nether_wart_chance) == 1 then
|
||||
minetest.set_node(bpos, {name = "mcl_nether:nether_wart"})
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
-- Generate basic layer-based nodes: void, bedrock, realm barrier, lava seas, etc.
|
||||
|
@ -1589,6 +1574,7 @@ mcl_mapgen.register_mapgen_block_lvm(basic_safe, 1)
|
|||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
dofile(modpath .. "/clay.lua")
|
||||
dofile(modpath .. "/tree_decoration.lua")
|
||||
dofile(modpath .. "/nether_wart.lua")
|
||||
|
||||
-- Nether Roof Light:
|
||||
mcl_mapgen.register_mapgen_block_lvm(function(vm_context)
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
local nether_wart_chance
|
||||
if mcl_mapgen.v6 then
|
||||
nether_wart_chance = 85
|
||||
else
|
||||
nether_wart_chance = 170
|
||||
end
|
||||
|
||||
local y_min = mcl_mapgen.nether.min
|
||||
local y_max = mcl_mapgen.nether.max
|
||||
local place_on = {"group:soil_nether_wart"}
|
||||
|
||||
local block_size = mcl_mapgen.BS
|
||||
local decrease_search_area = math.min(2, math.floor(block_size/2))
|
||||
local search_area_size = math.max(block_size - 2 * decrease_search_area, math.max(1, math.ceil(nether_wart_chance^(1/3))))
|
||||
nether_wart_chance = math.floor(nether_wart_chance * (search_area_size^3) / (block_size^3))
|
||||
local nether_wart_chance_threshold = nether_wart_chance
|
||||
local minetest_swap_node = minetest.swap_node
|
||||
|
||||
local wart_perlin
|
||||
local noise_params = {
|
||||
offset = 0.4,
|
||||
scale = 0.4,
|
||||
spread = {x = block_size, y = block_size, z = block_size},
|
||||
seed = 238742,
|
||||
octaves = 1,
|
||||
persist = 0.5,
|
||||
}
|
||||
|
||||
minetest.log("action", "Nether Wart block_size=" .. block_size .. ", search_area_size=" .. search_area_size .. ", per-area nether_wart_chance=" .. nether_wart_chance)
|
||||
|
||||
local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
|
||||
local minetest_get_perlin = minetest.get_perlin
|
||||
|
||||
mcl_mapgen.register_mapgen_block(function(minp, maxp, seed)
|
||||
local minp = minp
|
||||
local y1 = minp.y
|
||||
if y1 > y_max then return end
|
||||
|
||||
local maxp = maxp
|
||||
local y2 = maxp.y
|
||||
if y2 < y_min then return end
|
||||
|
||||
local p1 = {x = minp.x + decrease_search_area, y = y1 + decrease_search_area, z = minp.z + decrease_search_area}
|
||||
local p2 = {x = maxp.x - decrease_search_area, y = y2 - decrease_search_area, z = maxp.z - decrease_search_area}
|
||||
|
||||
pos_list = minetest_find_nodes_in_area_under_air(p1, p2, place_on)
|
||||
local pr = PseudoRandom(seed)
|
||||
wart_perlin = wart_perlin or minetest_get_perlin(noise_params)
|
||||
|
||||
for i = 1, #pos_list do
|
||||
local pos = pos_list[i]
|
||||
if pr:next(1, nether_wart_chance) + wart_perlin:get_3d(pos) >= nether_wart_chance_threshold then
|
||||
pos.y = pos.y + 1
|
||||
minetest.swap_node(pos, {name = "mcl_nether:nether_wart"})
|
||||
end
|
||||
end
|
||||
end, 999999999)
|
|
@ -0,0 +1,113 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
local pianowtune = "diminixed-pianowtune01"
|
||||
local end_tune = "diminixed-ambientwip"
|
||||
local nether_tune = "horizonchris96-traitor"
|
||||
|
||||
local dimension_to_base_track = {
|
||||
["overworld"] = pianowtune,
|
||||
["nether"] = nether_tune,
|
||||
["end"] = end_tune,
|
||||
}
|
||||
|
||||
local listeners = {}
|
||||
|
||||
local weather_state
|
||||
|
||||
local function stop_music_for_listener_name(listener_name)
|
||||
if not listener_name then return end
|
||||
local listener = listeners[listener_name]
|
||||
if not listener then return end
|
||||
local handle = listener.handle
|
||||
if not handle then return end
|
||||
minetest.sound_stop(handle)
|
||||
listeners[listener_name].handle = nil
|
||||
end
|
||||
|
||||
local function stop()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
stop_music_for_listener_name(player_name)
|
||||
end
|
||||
end
|
||||
|
||||
local function play()
|
||||
local new_weather_state = mcl_weather.get_weather()
|
||||
local was_good_weather = weather_state == "none" or weather_state == "clear"
|
||||
weather_state = new_weather_state
|
||||
local is_good_weather = weather_state == "none" or weather_state == "clear"
|
||||
local is_weather_changed = weather_state ~= new_weather_state
|
||||
local time = minetest.get_timeofday()
|
||||
if time < 0.25 or time >= 0.75 then
|
||||
stop()
|
||||
minetest.after(10, play)
|
||||
return
|
||||
end
|
||||
local day_count = minetest.get_day_count()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
local hp = player:get_hp()
|
||||
local pos = player:get_pos()
|
||||
local dimension = mcl_worlds.pos_to_dimension(pos)
|
||||
|
||||
local listener = listeners[player_name]
|
||||
local old_hp = listener and listener.hp
|
||||
local old_dimension = listener and listener.dimension
|
||||
|
||||
local is_dimension_changed = old_dimension and (old_dimension ~= dimension) or false
|
||||
local is_hp_changed = old_hp and (math.abs(old_hp - hp) > 0.00001) or false
|
||||
local handle = listener and listener.handle
|
||||
|
||||
local track = dimension_to_base_track[dimension]
|
||||
|
||||
if is_hp_changed
|
||||
or is_dimension_changed
|
||||
or (dimension == "overworld" and (is_weather_changed or not is_good_weather))
|
||||
or not track
|
||||
then
|
||||
stop_music_for_listener_name(player_name)
|
||||
if not listeners[player_name] then
|
||||
listeners[player_name] = {}
|
||||
end
|
||||
listeners[player_name].hp = hp
|
||||
listeners[player_name].dimension = dimension
|
||||
elseif not handle and (not listener or (listener.day_count ~= day_count)) then
|
||||
local spec = {
|
||||
name = track,
|
||||
gain = 0.3,
|
||||
pitch = 1.0,
|
||||
}
|
||||
local parameters = {
|
||||
to_player = player_name,
|
||||
gain = 1.0,
|
||||
fade = 0.0,
|
||||
pitch = 1.0,
|
||||
}
|
||||
handle = minetest.sound_play(spec, parameters, false)
|
||||
listeners[player_name] = {
|
||||
spec = spec,
|
||||
parameters = parameters,
|
||||
handle = handle,
|
||||
hp = hp,
|
||||
dimension = dimension,
|
||||
day_count = day_count,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(7, play)
|
||||
end
|
||||
|
||||
minetest.after(15, play)
|
||||
|
||||
minetest.register_on_joinplayer(function(player, last_login)
|
||||
local player_name = player:get_player_name()
|
||||
stop_music_for_listener_name(player_name)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
stop_music_for_listener_name(player_name)
|
||||
end)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
name = mcl_music
|
||||
author = diminixed, kay27
|
||||
description = Mod check some conditions and plays music
|
||||
depends = mcl_player, mcl_weather, mcl_worlds
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue