Added reset for player respawning to remove FOV modifiers.

Fixed missing on_end call in remove_all_modifiers.
Added mcl_fovapi to Bows, Sprint, and Spyglass.
This commit is contained in:
Michieal 2023-12-03 08:24:21 -05:00 committed by the-real-herowl
parent bf41e116a1
commit 6cfb55e853
4 changed files with 12 additions and 4 deletions

View file

@ -1,6 +1,6 @@
name = mcl_bows name = mcl_bows
author = Arcelmi author = Arcelmi
description = This mod adds bows and arrows for MineClone 2. description = This mod adds bows and arrows for MineClone 2.
depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util, mcl_shields depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util, mcl_shields, mcl_fovapi
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button

View file

@ -1,4 +1,4 @@
name = mcl_spyglass name = mcl_spyglass
author = NO11 author = NO11
description = This mod adds a spyglass, which is an item that can be used for zooming in on specific locations. description = This mod adds a spyglass, which is an item that can be used for zooming in on specific locations.
depends = mcl_core, controls depends = mcl_core, controls, mcl_fovapi

View file

@ -60,6 +60,10 @@ function mcl_fovapi.register_modifier(name, fov_factor, time, is_multiplier, exc
end end
minetest.register_on_respawnplayer(function(player)
mcl_fovapi.remove_all_modifiers(player:get_player_name())
end)
function mcl_fovapi.apply_modifier(player, modifier_name) function mcl_fovapi.apply_modifier(player, modifier_name)
if player == nil then if player == nil then
return return
@ -162,6 +166,9 @@ function mcl_fovapi.remove_all_modifiers(player)
end end
player:set_fov(0, false, 0) player:set_fov(0, false, 0)
if mcl_fovapi.registered_modifiers[modifier_name].on_end ~= nil then
mcl_fovapi.registered_modifiers[modifier_name].on_end(player)
end
end end

View file

@ -1,4 +1,5 @@
name = mcl_sprint name = mcl_sprint
author = GunshipPenguin author = GunshipPenguin
description = Allows the player to sprint by pressing the “Use” key (default: E). description = Allows the player to sprint by pressing the “AUX” key (default: E).
depends = mcl_playerinfo, playerphysics, mcl_hunger depends = mcl_playerinfo, playerphysics, mcl_hunger, mcl_fovapi
optional = mcl_bows