1
0
Fork 0

mcl_util.is_in_void

This commit is contained in:
Wuzzy 2017-02-21 16:38:28 +01:00
parent c866227d54
commit 2e7ce77985
3 changed files with 14 additions and 1 deletions

View File

@ -194,3 +194,14 @@ end
function mcl_util.is_fuel(item)
return minetest.get_craft_result({method="fuel", width=1, items={item}}).time ~= 0
end
-- For a given position, returns a 2-tuple:
-- 1st return value: true if pos is in void
-- 2nd return value: true if it is in the deadly part of the void
function mcl_util.is_in_void(pos)
local void, void_deadly
void = pos.y < mcl_vars.bedrock_overworld_min
void_deadly = pos.y < mcl_vars.bedrock_overworld_min - 65
return void, void_deadly
end

View File

@ -1,3 +1,4 @@
mcl_init
mcl_util
mcl_core
3d_armor?

View File

@ -129,7 +129,8 @@ minetest.register_globalstep(function(dtime)
-- This only works beause weather_pack currently does not touch the sky for players below the height used for this check.
-- There should be a real skybox API.
end
if pos.y < mcl_vars.bedrock_overworld_min - 65 then
local void, void_deadly = mcl_util.is_in_void(pos)
if void_deadly then
-- Player is deep into the void, deal void damage
if player:get_hp() > 0 then
player:set_hp(player:get_hp() - 4)