Rearrange optimized checks
This commit is contained in:
parent
35401336d2
commit
658f197051
20
script.lua
20
script.lua
@ -681,21 +681,25 @@ function hostTick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function tick()
|
function tick()
|
||||||
STATE.current.color_check=player:isInLava() ~= (player:getDimensionName()=="minecraft:the_nether")
|
STATE.current.color_check=player:isInLava() ~=
|
||||||
|
(player:getDimensionName()=="minecraft:the_nether")
|
||||||
if STATE.old.color_check~=STATE.current.color_check then
|
if STATE.old.color_check~=STATE.current.color_check then
|
||||||
setColor()
|
setColor()
|
||||||
end
|
end
|
||||||
-- optimization, only execute these once a second --
|
-- optimization, only execute these with certain frequency --
|
||||||
if world.getTimeOfDay() % 20 == 0 then
|
if world.getTimeOfDay() % 5 == 0 then -- 1/4 second
|
||||||
|
|
||||||
if player:getPose() == "SLEEPING" then
|
if player:getPose() == "SLEEPING" then
|
||||||
snore()
|
snore()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sync state every 10 seconds
|
|
||||||
if world.getTimeOfDay() % (20*10) == 0 then
|
-- unneeded for now but can uncomment if needed
|
||||||
sharedstate.sync()
|
--if world.getTimeOfDay() % 20 == 0 then -- 1 second
|
||||||
end
|
-- Sync state every 10 seconds
|
||||||
|
if world.getTimeOfDay() % (20*10) == 0 then
|
||||||
|
sharedstate.sync()
|
||||||
|
end
|
||||||
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
hostTick()
|
hostTick()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user