Fix SetCameraFree bugging up in OnWorldInitialized

This commit is contained in:
David Vogel 2022-07-29 00:25:19 +02:00
parent b81fcd8417
commit 83be64dd74

View File

@ -81,6 +81,9 @@ end
---Ensures chunks around the player have been loaded & created. ---Ensures chunks around the player have been loaded & created.
---@param playerEntityID integer ---@param playerEntityID integer
function OnPlayerSpawned(playerEntityID) function OnPlayerSpawned(playerEntityID)
-- Set camera free based on mod settings.
-- We need to do this here, otherwise it will bug up or delete the player entity.
Modification.SetCameraFree()
end end
---Called when the player dies. ---Called when the player dies.
@ -91,14 +94,12 @@ end
---Called once the game world is initialized. ---Called once the game world is initialized.
---Doesn't ensure any chunks around the player. ---Doesn't ensure any chunks around the player.
function OnWorldInitialized() function OnWorldInitialized()
-- Set camera free based on mod settings.
Modification.SetCameraFree() -- BUG: Calling this here has the side effect of the player entity not being loaded. Also the player UI will be gone
end end
---Called *every* time the game is about to start updating the world. ---Called *every* time the game is about to start updating the world.
function OnWorldPreUpdate() function OnWorldPreUpdate()
Message:CatchException("OnWorldPreUpdate", function () Message:CatchException("OnWorldPreUpdate", function ()
-- Coroutines aren't run every frame in this lua sandbox, do it manually here. -- Coroutines aren't run every frame in this lua sandbox, do it manually here.
wake_up_waiting_threads(1) wake_up_waiting_threads(1)