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

Lava is double-ticked in random ticking

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.16.5, 1.17.1, 21w43a, 1.18 Release Candidate 3, 1.18, 1.18.1, 22w11a
    • None
    • Plausible

      The Bug

      During world random block ticking, if a lava block is selected to tick then it will tick twice, when it should only tick once. In general this is simply a minor behavioral regression from older versions as a result of technical changes, so minor in fact I'm reporting this over a year after I found it. But it should be fixed, as it will result in a small performance gain for random ticks (lava is the most expensive random ticking block in this game) and fix a behavioral regression.

      Analysis

      Note: All mappings are Mojang mappings.

      The cause is from the fact that a lava block has a FluidState and a BlockState, and both are marked as randomly ticking. The code for random tick will run random tick logic for the FluidState if it is marked as randomly ticking, and it will run the code for BlockState random ticking if the BlockState is marked as randomly ticking. You can verify this behavior yourself by looking at ServerLevel#tickChunk(LevelChunk, int). Since the Lava FluidState and BlockState are both marked as randomly ticking, it will be double ticked - unlike other blocks, like dirt, which are not a fluid and as such will not randomly tick twice.

      I verified with older versions (1.12.2) that this kind of logic was not intentional. I found that the random tick implementation is basically the same for Lava. Also, Lava in 1.12.2 was only ticked once per random tick selection. So it's definitely a regression from the technical changes to split Fluids from Blocks, as it looks like the fluid ticking was added without considering how the Lava BlockState random ticking worked. A simple mistake.

      This can be solved by making the LiquidBlock class not run the fluid's random tick method. This seems to be a good fit for the direction the technical changes are headed in, as fluids and blocks should be separate and as such the BlockState should not be responsible for randomly ticking the fluid, especially when there is already dedicated logic for that.

       

            Unassigned Unassigned
            Spottedleaf Spottedleaf
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              CHK: