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

Blocks being moved by pistons are incorrectly lit at the front

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.19.2, 22w42a, 1.21
    • None
    • Confirmed
    • Rendering
    • Normal
    • Platform

      When pistons push walls of blocks a shadow is shown while the blocks are moving, due to the blocks moving only for one tick the shadow appears to blink which is not pleasant to look at. This is odd specifically because the shadow is present only on the front face of the block while it is being pushed through air.

      The sides of the block being incorrectly lit until the pistons finish moving is not an issue (MC-255048), this is strictly about the front face of the block having a shadow when it should not have since there are no other blocks to cause the shadow.

      The attached video shows the current situation for the first 8 seconds, after that a code change is hotswapped that to show what it should look like instead.

       

      Code Analysis
      For each block being pushed by a piston we have the source and target block. The moving block entity uses the location of the source block to get rendering information like the block lighting, random texture variation (seed) and biome coloration. As per MC-255048 changing this to use the target block is not correct, understandibly since this changes the aforementioned factors. However, this creates a problem with lighting as the moving block is placed on the target block. The moving block inherits the collision shape from the moved block state, so if this is a full block it inherits `isCollisionShapeFullBlock` returning true which causes a shadow. So the shadow on the front face of the pushed wall is due to the new moving block casting a shadow on its own source block.

      A possible fix is to override `isCollisionShapeFullBlock` in `MovingPistonBlock` to always return false which seems to fix the issue but might not be the perfect solution since it could affect other rendering details. The fix to this issue involves some modification to how moving blocks render to remove this shadow cast by the moving block onto itself, either by overriding the specific front face or through changing whether the collision shape is seen as a full block.

      Specifically concering the provided video, the solution it uses simply changes the moving block entity to use the target block's position which is not the preferred fix as per MC-255048. So any minor visual differences with the video can be ignored, it's just for illustration of what it should look like.

            Unassigned Unassigned
            Aeltumn Daniël Goossens
            Votes:
            6 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: