Steps to reproduce
Find or spawn a horse and tame that horse or place a minecart.
Mount the horse or enter the minecart.
Now press
Ctrl
(Sprint key) andW
(Moving forwards key) simultaneously.Notice that there are a few sprinting particles visible.
Linked issues
is duplicated by 1
relates to 1
Attachments
Comments 18
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();
}
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.