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

Shulker boxes are far more expensive to render than most other blocks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 24w38a
    • None
    • Community Consensus
    • Performance

      The bug

      Shulker boxes are perhaps one of the most horribly unoptimized blocks in vanilla Minecraft when it comes to rendering:

      • Despite being outwardly a simple cube, all of the many, many interior faces are also rendered, at all times, despite them never being visible without clipping inside of the block.
      • Being an opaque full cube, they also do not cull the faces of any other blocks that are occluded by them.
      • They themselves are also not culled by any blocks next to them.
      • To top it off, instead of the standard block model system, shulker boxes render as entities, which is provably far more expensive.

      This is a major issue in cases where large numbers of shulker boxes are present, such as advanced storage and loading systems.

      How to reproduce

      Two resource packs are attached to this ticket: one which introduces models for shulker boxes based on the json model format, and one which remodels reinforced deepslate to use the closed shulker box model.

      1. Download and apply the "shulker-box-optimization-resources" pack, and the "shulker-box-optimized-demo" pack on top of it
      2. Create a The Void superflat world with doDaylightCycle and doWeatherCycle disabled
      3. Set your render distance to 3, FOV to default, and disable VSync
      4. Use F3+2 to open performance graphs
      5. /tp @s 16.5 -60 16.5 135 -22.5
      6. /fill -8 -60 -8 7 -45 7 reinforced_deepslate

        , observe

      7. /fill -8 -60 -8 7 -45 7 shulker_box

        , observe

      8. /fill -8 -60 -8 7 -45 7 barrel

        , observe

      Expected results

      Shulker boxes wouldn't hurt performance by a lot.

      Actual results

      They do. We can confirm that the block-entity rendering is the main issue rather than simply the presence of a block entity, as barrels did not cause the same levels of lag.

      How to fix

      It is evident that the current block entity system for rendering shulker boxes needs to be scrapped. This should preferably be done in favour of the existing block model system.

      Since shulker boxes are almost always in a closed state, a simple cube model will suffice, without requiring any extra internal geometry.

      For opened shulker boxes, the optimization-resources resource pack contains model files for the stationary base under "open", and the animated, rotating lid under "lid". Only the lid, when the shulker box is opening, needs to use the block-entity renderer.

      Split versions of the shulker texture are also included for easier use with shulker boxes as block models.

      Retiring block-entity rendering would also fix several other issues for shulker boxes, such as MC-69683 and MC-231102, as well as the problem where they de-render too early at a distance.

        1. 2024-09-20_21.45.43.png
          203 kB
          Connor Steppie
        2. 2024-09-20_21.46.04.png
          194 kB
          Connor Steppie
        3. 2024-09-20_21.46.34.png
          219 kB
          Connor Steppie
        4. image-2024-09-21-00-15-06-634.png
          2.01 MB
          BugTracker

            Unassigned Unassigned
            Awesoman3000 Connor Steppie
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: