Hello guys, So I have been trying to stop player sprinting if he sprints too long, but even cancelling the PlayerToggleSprintEvent, stopping the player sprinting IN the playerToggleSprintEvent or stopping player sprinting in the PlayerMoveEvent, nothing seems to work. After doing a quick google search, I found no solution, just that it is apparently handled client side and was server side only in 1.6. Is this really true? Isn't there any solution you guys maybe know of I could try? I was trying to look for some solutions in the javadocs, but those seem not to work anymore. Thanks for any ideas or suggestions!
One idea would be to wait for the player to enable sprinting and stop them from moving until they disable it. This is handled client side so there isn't much you can do.
@Skionz Well, this is how I have it now, but don't like it this way though because well, if you run away from a mob or something you could die because of this. @Zombie_Striker That's not even a bad idea! Thanks, I'll try to do it like that. @all Another thing I had in mind, how about checking if the player is sprinting and if yes, change the to a number that combined with the sprinting is exactly the same as when NOT sprinting and having default speed?
@Lionhard Check if the player is sprinting then do this: Code: if (player.isSprinting()) { player.setSprinting(false); } ~ Cheers
Why not just do this? Code: player.setSprinting(false); Why even check to see if the player is sprinting in the first place? You don't need to.
@teej107 @ninjaboy323 Because this no longer works. It worked in version 1.6, when sprinting was handled server-side, now it is client-side and it doesn't work anymore. (What I already told in my thread.) That's why I need another solution.
@teej107 Thanks. @Zombie_Striker @teej107 Oh man, I was hoping this would work. When I set the hunger to 3 and then instantly set it to to whatever it was, it doesn't do anything. If I set it to 3, wait for another event to be fire and THEN set it to what it was before, it gets some kind of "laggy" movement, like the user is sprinting, then stops, then sprints again, then stops, then sprints again, ... Makes them faster too, so yeah... :/ EDIT: When I tested it a bit more, it seems to work when double-hitting W (As the ToggleEvent is fired only 1 time, but when using Control, the toggleEvent is continuously thrown (seems like) and it makes that weird kind of movement.) EDIT by Moderator: merged posts, please use the edit button instead of double posting.
There's your problem. By setting it back to what it was instantly, it is not sending the packet that it ever was three. Try adding a small runnable with a delay of maybe 4 or 5.
@Zombie_Striker Yeah, tried that, which didn't work. (That's probably my fault. ), Then I put everything into the runnable. I'll try to rework it, if it is not going to work, I'll send you the code. Thanks for helping me so far guys!