Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-217724

Traveling vertically through powder snow does not produce any particles

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w15a, 21w16a, 21w17a, 21w18a, 21w19a, 21w20a, 1.17 Pre-release 1, 1.17 Pre-release 3, 1.17 Pre-release 4, 1.17 Pre-release 5, 1.17 Release Candidate 1, 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 2, 1.17.1 Release Candidate 1, 1.17.1, 21w37a, 21w40a, 21w43a, 1.18, 1.18.1, 22w05a, 1.18.2 Pre-release 1, 1.18.2, 1.19, 1.19.2, 22w43a, 1.19.3, 1.19.4, 1.20.1
    • Confirmed
    • Particles
    • Normal
    • Platform

      The Bug:

      Traveling vertically through powder snow does not produce any particles.

      Steps to Reproduce:

      1. Horizontally move through some powder snow by walking through it, without changing your y level, and take note of how particles are produced.
      2. Vertically move through some powder snow by falling/jumping through it, without changing your x or z coordinate.
      3. Take note as to whether or not traveling vertically through powder snow produces any particles.

      Observed Behavior:

      Particles aren't produced.

      Expected Behavior:

      Particles would be produced.

      Code Analysis:

      Code analysis by Avoma can be found below.

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

      net.minecraft.world.level.block.PowderSnowBlock.java
      public class PowderSnowBlock extends Block implements BucketPickup {
         ...
         public void entityInside(BlockState $bs, Level $l, BlockPos $bp, Entity $e) {
            if (!($e instanceof LivingEntity) || $e.getFeetBlockState().is(this)) {
               $e.makeStuckInBlock($bs, new Vec3((double)0.9F, 1.5D, (double)0.9F));
               if ($l.isClientSide) {
                  Random random = $l.getRandom();
                  boolean flag = $e.xOld != $e.getX() || $e.zOld != $e.getZ();
                  if (flag && random.nextBoolean()) {
                     $l.addParticle(ParticleTypes.SNOWFLAKE, $e.getX(), (double)($bp.getY() + 1), $e.getZ(), (double)(Mth.randomBetween(random, -1.0F, 1.0F) * 0.083333336F), (double)0.05F, (double)(Mth.randomBetween(random, -1.0F, 1.0F) * 0.083333336F));
                  }
               }
            }
            ...

      If we look at the above class, we can see that particles from powder snow are only produced based on the entity's change in "x" and "z" positions. This is evident through the following line of code:

      boolean flag = $e.xOld != $e.getX() || $e.zOld != $e.getZ();

      Potential Fix:

      Simply adding a line of code that checks whether the entity's "y" position was changed should resolve this problem. The following line of code could be used in order to fix this:

      $e.yOld != $e.getY()

      The correct piece of code within its class should look something like the following:

      net.minecraft.world.level.block.PowderSnowBlock.java
      public class PowderSnowBlock extends Block implements BucketPickup {
         ...
         public void entityInside(BlockState $bs, Level $l, BlockPos $bp, Entity $e) {
            if (!($e instanceof LivingEntity) || $e.getFeetBlockState().is(this)) {
               $e.makeStuckInBlock($bs, new Vec3((double)0.9F, 1.5D, (double)0.9F));
               if ($l.isClientSide) {
                  Random random = $l.getRandom();
                  boolean flag = $e.xOld != $e.getX() || $e.yOld != $e.getY() || $e.zOld != $e.getZ();
                  if (flag && random.nextBoolean()) {
                     $l.addParticle(ParticleTypes.SNOWFLAKE, $e.getX(), (double)($bp.getY() + 1), $e.getZ(), (double)(Mth.randomBetween(random, -1.0F, 1.0F) * 0.083333336F), (double)0.05F, (double)(Mth.randomBetween(random, -1.0F, 1.0F) * 0.083333336F));
                  }
               }
            }
            ...

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            14 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              CHK: