1
0
Fork 0

Fix XP and Nether ashes

This commit is contained in:
kay27 2020-10-26 01:06:35 +04:00
parent 1965696829
commit 9f98117328
2 changed files with 5 additions and 4 deletions

View File

@ -31,7 +31,7 @@ minetest.register_globalstep(function(dtime)
end end
for _, player in ipairs(minetest.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_dust(player:get_pos())) then if not mcl_worlds.has_dust(player:get_pos()) then
return false return false
end end
mcl_weather.nether_dust.add_dust_particles(player) mcl_weather.nether_dust.add_dust_particles(player)

View File

@ -3,6 +3,7 @@ mcl_experience = {}
local pool = {} local pool = {}
local registered_nodes local registered_nodes
local max_xp = 2^31-1 local max_xp = 2^31-1
local max_orb_age = 300 -- seconds
local gravity = {x = 0, y = -((tonumber(minetest.settings:get("movement_gravity"))) or 9.81), z = 0} local gravity = {x = 0, y = -((tonumber(minetest.settings:get("movement_gravity"))) or 9.81), z = 0}
local size_min, size_max = 20, 59 -- percents local size_min, size_max = 20, 59 -- percents
@ -147,7 +148,7 @@ function mcl_experience.set_player_xp_level(player,level)
return return
end end
pool[name].level = level pool[name].level = level
pool[name].xp, pool[name].next_level = mcl_experience.bar_to_xp(pool[name].bar, level) pool[name].xp, pool[name].bar_step, pool[name].next_level = mcl_experience.bar_to_xp(pool[name].bar, level)
hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)}) hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(level)})
-- we may don't update the bar -- we may don't update the bar
end end
@ -237,7 +238,7 @@ function mcl_experience.add_experience(player, experience)
local old_bar, old_xp, old_level = temp_pool.bar, temp_pool.xp, temp_pool.level local old_bar, old_xp, old_level = temp_pool.bar, temp_pool.xp, temp_pool.level
temp_pool.xp = math.min(math.max(temp_pool.xp + experience, 0), max_xp) temp_pool.xp = math.min(math.max(temp_pool.xp + experience, 0), max_xp)
if (temp_pool.xp >= temp_pool.xp_next_level) or (experience < 1) then if (temp_pool.xp >= temp_pool.xp_next_level) or (temp_pool.xp < old_xp) then
temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp) temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp)
temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level)
if old_level ~= temp_pool.level then if old_level ~= temp_pool.level then
@ -342,7 +343,7 @@ local function xp_step(self, dtime)
self.age = self.age + dtime self.age = self.age + dtime
if self.age > 300 then if self.age > max_orb_age then
self.object:remove() self.object:remove()
return return
end end