mojira.dev
MC-201374

Wrong position passed to getCollisionShape from CampfireBlock#isSmokingBlockAt

I ran into an odd bug randomly which I am pretty sure is just due to accidentally passing the wrong parameter to a method. Using forge names, the method isSmokingBlockAt in CampfireBlock seems to be passing the wrong position to getCollisionShape. With forge mappings the method looks like this:

public static boolean isSmokingBlockAt(World world, BlockPos pos) {
  for(int i = 1; i <= 5; ++i) {
     BlockPos blockpos = pos.down(i);
     BlockState blockstate = world.getBlockState(blockpos);
     if (isLit(blockstate)) {
        return true;
     }

     boolean flag = VoxelShapes.compare(SMOKING_SHAPE, blockstate.getCollisionShape(world, pos, ISelectionContext.dummy()), IBooleanFunction.AND);
     if (flag) {
        BlockState blockstate1 = world.getBlockState(blockpos.down());
        return isLit(blockstate1);
     }
  }

  return false;
}

and passes pos to blockstate#getCollisionShape. The issue is that BlockState is gotten from the world at blockpos and not pos, and likely doesn't even exist in the world at pos.

Environment

Windows 10, AdoptOpenJDK 7.0.232 Hotspot, Minecraft Forge 1.16.3 34.1.0

Attachments

Comments 2

Confirmed, although this seems to have no actual in-game consequence, since the only relevant block I could find that uses the passed-in blockPos to determine its collision box is bamboo, which intentionally ignores the Y value, the only value with a discrepancy.

From viewing decompiled source code, I can confirm this method still exists in 24w21b as it did when the report was originally created:

[media]

(Mappings are Mojang mappings instead of forge)

pupnewfster

(Unassigned)

Confirmed

1.16.3, 24w21b

Retrieved