mojira.dev
MC-309659

Cushions cannot be placed on the highest edge of a lectern

Cushions are meant to be able to be placed on any top surface on any part of a block. This is possible in most cases, however the highest part of a lectern that reaches outside of the lectern’s block does nothing when you right-click, even though it should be considered a part of the lectern. (see image / video)

Steps to Reproduce:

  1. Place a lectern

  2. Try to place a cushion on each of the lectern’s top faces (crouching is required)

Observed Behaviour:

You can place a cushion on all top-faces except for the highest section of the lectern.

Expected Behaviour:

You can place a cushion on all top-faces of the lectern,

Linked issues

Attachments

Comments 5

Thank you for helping us improve Minecraft! We saved your files:

[media][media]

This issue has been reviewed by our team.

Please add new, relevant information if it helps us understand or reproduce the issue. To show that you’re affected, use the vote feature rather than commenting.

If a fix is implemented, it will be listed in our official changelogs.

For major outages or urgent assistance, visit the Minecraft Help Center.

Code analysis: this is because Cusion.wouldSuriveAt() [sic] only checks for collisions with blocks that are at most 1/64 blocks below itself:

   public static boolean wouldSuriveAt(final Level level, final AABB boundingBox) {
      AABB anchorBox = new AABB(
         boundingBox.minX, boundingBox.minY - 0.015625, boundingBox.minZ, Math.nextDown(boundingBox.maxX), boundingBox.minY, Math.nextDown(boundingBox.maxZ)
      );

      for (BlockPos blockPos : BlockPos.betweenClosed(anchorBox)) {
         BlockState blockState = level.getBlockState(blockPos);
         VoxelShape shape = blockState.getShape(level, blockPos);
         if (!shape.isEmpty() && shape.bounds().move(blockPos).intersects(anchorBox)) {
            return true;
         }
      }

      return false;
   }

This means that it never checks collisions with the lectern block when placed on the highest edge, since the block position is too far away. If it did, it would see that the shape intersects. The game should scan at least 2 pixels further down for blocks, since the interaction shape of lecterns is 18 pixels tall.

*Cushion.wouldSuriveAt()

A fix would look something like:

   public static boolean wouldSuriveAt(final Level level, final AABB boundingBox) {
      AABB anchorBox = new AABB(
         boundingBox.minX, boundingBox.minY - 0.015625, boundingBox.minZ, Math.nextDown(boundingBox.maxX), boundingBox.minY, Math.nextDown(boundingBox.maxZ)
      );
      AABB blockCheckBox = anchorBox.setMinY(anchorBox.minY - MAX_BLOCK_SHAPE_HEIGHT_ABOVE_FULL_BLOCK);
      
      for (BlockPos blockPos : BlockPos.betweenClosed(blockCheckBox)) {
         BlockState blockState = level.getBlockState(blockPos);
         VoxelShape shape = blockState.getShape(level, blockPos);
         if (!shape.isEmpty() && shape.bounds().move(blockPos).intersects(anchorBox)) {
            return true;
         }
      }

      return false;
   }

(I release all rights to this code modification)

DorkOrc

(Unassigned)

1648494

Confirmed

Expansion A

Collision, Items

26.3 Snapshot 3

26.3 Snapshot 4

Retrieved