mojira.dev
MC-120488

Sprint particles may be visible while the player is riding an entity and pressing the sprint keys

Steps to reproduce

  1. Find or spawn a horse and tame that horse or place a minecart.

  2. Mount the horse or enter the minecart.

  3. Now press Ctrl (Sprint key) and W (Moving forwards key) simultaneously.

  4. Notice that there are a few sprinting particles visible.

Linked issues

Attachments

Comments 18

Affects 1.16 Release Candidate 1
The horse has to have a block in its legs. For example tall grass or a rail. Does not happen on flat ground. The minecart shows particles whether its on a rail or flat ground.

Can confirm in 20w51a.

Can confirm in 21w03a.

Can confirm in 21w05a.

8 more comments

Can confirm this in 21w41a. The expected behavior would be that no sprinting particles would be produced when sprinting whilst riding an entity.

I can confirm this behavior in 1.18.1 and 22w06a.

It's important to note that this can be seen when riding any entity, as long as the player's hitbox is in close contact with the ground/the block beneath its mount. In other words, this problem is not exclusive to riding unsaddled horses and minecarts as currently mentioned in this ticket.

Here's a code analysis along with a potential fix regarding this issue.

Code Analysis:

The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

net.minecraft.world.entity.Entity.java

public abstract class Entity implements Nameable, EntityAccess, CommandSource {
   ...
   public boolean canSpawnSprintParticle() {
      return this.isSprinting() && !this.isInWater() && !this.isSpectator() && !this.isCrouching() && !this.isInLava() && this.isAlive();
   }

   protected void spawnSprintParticle() {
      int i = Mth.floor(this.getX());
      int j = Mth.floor(this.getY() - (double)0.2F);
      int k = Mth.floor(this.getZ());
      BlockPos blockpos = new BlockPos(i, j, k);
      BlockState blockstate = this.level.getBlockState(blockpos);
      if (blockstate.getRenderShape() != RenderShape.INVISIBLE) {
         Vec3 vec3 = this.getDeltaMovement();
         this.level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, blockstate), this.getX() + (this.random.nextDouble() - 0.5D) * (double)this.dimensions.width, this.getY() + 0.1D, this.getZ() + (this.random.nextDouble() - 0.5D) * (double)this.dimensions.width, vec3.x * -4.0D, 1.5D, vec3.z * -4.0D);
      }

   }
   ...

In order for an entity to produce sprinting particles, certain criteria must be met. The criteria are as follows:

  • The entity must be sprinting.

  • The entity must not be in water.

  • The entity must not be in spectator mode.

  • The entity must not be crouching.

  • The entity must not be in lava.

  • The entity must be alive.

If these criteria are met, sprinting particles can be produced. Looking at the above class, we can see that no checks are carried out to see whether or not the entity is a passenger before allowing them to produce sprinting particles, meaning that they are able to, as long as their hitbox is in close contact with the block beneath their mount.

Potential Fix:

Simply altering the canSpawnSprintParticle() method to include that passengers should not be able to produce sprinting particles, should resolve this problem. The following line of code could be used in order to fix this:

!this.isPassenger()

Additionally, here's what the fixed method within its class should look something like:

net.minecraft.world.entity.Entity.java

public boolean canSpawnSprintParticle() {
   return this.isSprinting() && !this.isInWater() && !this.isSpectator() && !this.isCrouching() && !this.isInLava() && this.isAlive();
}

Can confirm in 1.18.2.

Can confirm in 1.19.2.

This issue was present in 1.19.3 but no longer occurs in 23w03a. This issue has been fixed in 23w03a. Due to the fixing of MC-257082, sprinting is no longer possible while riding entities thus fixing this issue (MC-120488).

violine1101

(Unassigned)

Confirmed

Hitboxes, Particles

horse, minecart, particles, sprinting

Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w50a, Minecraft 1.13.1, Minecraft 1.13.2, ..., 1.18.1, 22w06a, 1.18.2, 1.19.2, 1.19.3

23w03a

Retrieved