diff --git a/mods/PLAYER/mcl_sprint/README.md b/mods/PLAYER/mcl_sprint/README.md index c8a8e99cae..bf02b909ee 100644 --- a/mods/PLAYER/mcl_sprint/README.md +++ b/mods/PLAYER/mcl_sprint/README.md @@ -19,6 +19,7 @@ What a player has to do to start sprinting. 0 = double tap w, 1 = press e. Note that if you have the fast privlige, and have the fast speed turned on, you will run very, very fast. You can toggle this by pressing j. +NOTE: Method 0 is UNTESTED! mcl_sprint.SPEED (default 1.5) diff --git a/mods/PLAYER/mcl_sprint/depends.txt b/mods/PLAYER/mcl_sprint/depends.txt index db2aacba35..73b341633d 100644 --- a/mods/PLAYER/mcl_sprint/depends.txt +++ b/mods/PLAYER/mcl_sprint/depends.txt @@ -1 +1,2 @@ playerplus +mcl_hunger diff --git a/mods/PLAYER/mcl_sprint/esprint.lua b/mods/PLAYER/mcl_sprint/esprint.lua index 886d5146d8..e7599b458a 100644 --- a/mods/PLAYER/mcl_sprint/esprint.lua +++ b/mods/PLAYER/mcl_sprint/esprint.lua @@ -61,8 +61,8 @@ minetest.register_globalstep(function(dtime) --Adjust player states if players[playerName]["shouldSprint"] == true then --Stopped local sprinting - -- Prevent sprinting if standing on soul sand - if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" then + -- Prevent sprinting if standing on soul sand or hungry + if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" or mcl_hunger.get_hunger(player) <= 6 then sprinting = false else sprinting = true diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 0437c0cc52..49a7705ac3 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -15,6 +15,7 @@ mcl_sprint.SPEED = 1.3 mcl_sprint.TIMEOUT = 0.5 --Only used if mcl_sprint.METHOD = 0 if mcl_sprint.METHOD == 0 then + -- UNTESTED dofile(minetest.get_modpath("mcl_sprint") .. "/wsprint.lua") elseif mcl_sprint.METHOD == 1 then dofile(minetest.get_modpath("mcl_sprint") .. "/esprint.lua") diff --git a/mods/PLAYER/mcl_sprint/wsprint.lua b/mods/PLAYER/mcl_sprint/wsprint.lua index 70b40ef526..05c7cdb3bf 100644 --- a/mods/PLAYER/mcl_sprint/wsprint.lua +++ b/mods/PLAYER/mcl_sprint/wsprint.lua @@ -60,6 +60,8 @@ minetest.register_globalstep(function(dtime) end end + -- Prevent sprinting if standing on soul sand or hungry + local can_sprint = (playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand") and (mcl_hunger.get_hunger(player) <= 6) --Adjust player states if players[playerName]["moving"] == false and playerInfo["state"] == 3 then --Stopped setState(playerName, 0) @@ -67,18 +69,16 @@ minetest.register_globalstep(function(dtime) setState(playerName, 1) elseif players[playerName]["moving"] == false and playerInfo["state"] == 1 then --Primed local sprinting - -- Prevent sprinting if standing on soul sand - if not playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand" then - setState(playerName, 2) - else + if can_sprint then setState(playerName, 0) + else + setState(playerName, 2) end elseif players[playerName]["moving"] == true and playerInfo["state"] == 2 then --Sprinting - -- Prevent sprinting if standing on soul sand - if not playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand" then - setState(playerName, 3) - else + if can_sprint then setState(playerName, 1) + else + setState(playerName, 3) end end