Posted June 18, 20214 yr Hi there! I'm currently trying to stop the player from sprinting using: event.player.setSprinting(false); 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 { @SubscribeEvent 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()) { s.increase(4); } }); if (FeathersHelper.getFeatherLevel((ServerPlayerEntity) event.player) <= 0) { event.player.setSprinting(false); } event.player.getCapability(SprintProvider.SPRINT_CAP).ifPresent(s -> { if (s.getSprint() >= 20) { s.set(0); 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!
June 13, 20241 yr 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!
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.