Jump to content

How to stop the player from sprinting


Recommended Posts

Hi there!

I'm currently trying to stop the player from sprinting using:


in the PlayerTickEvent event. This works for double tapping w, however the player can still sprint by holding Left-Control.


Here is my full Class for reference:

package com.elenai.elenaihardcore.event;

import com.elenai.elenaidodge2.api.FeathersHelper;
import com.elenai.elenaihardcore.capability.sprint.SprintProvider;

import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class PlayerEventListener {

	public void playerEventListener(PlayerTickEvent event) {
		if (event.side.isServer() && event.phase == TickEvent.Phase.START) {
			event.player.getCapability(SprintProvider.SPRINT_CAP).ifPresent(s -> {
				if (event.player.isSprinting()) {

			if (FeathersHelper.getFeatherLevel((ServerPlayerEntity) event.player) <= 0) {
			event.player.getCapability(SprintProvider.SPRINT_CAP).ifPresent(s -> {
				if (s.getSprint() >= 20) {
					FeathersHelper.decreaseFeathers((ServerPlayerEntity) event.player, 1);



^ I have also tested this without the if conditions or capabilities and it still doesn't work. How would I be able to completely prevent the player from sprinting?


Thanks for your help!


Link to comment
Share on other sites

  • 2 years later...

I know this post is a few years old now, and i don't see any responses, but where you ever able to figure out the issue? Im having the same exact problem right now for 1.20.1. I have FOV effect disabled for both methods of sprinting and speed boost disabled for double tapping W, but i can't for the life of me figure out why left CTRL is acting different. Any help would be appreciated, thanks! 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.