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

SculkSensorBlockEntity and SculkShriekerBlockEntity leak VibrationListeners on update

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • 1.19, 1.19.1 Pre-release 1
    • None
    • None
    • Confirmed
    • Game Events
    • Low

    Description

      Root cause of MC-249450

      SculkShriekerBlockEntity and SculkSensorBlockEntity both serialize their listener, and when calling the load method it causes their listener to be overridden.

      if (nbt.contains("listener", 10)) {
                  VibrationListener.codec(this).parse(new Dynamic<>(NbtOps.INSTANCE, nbt.getCompound("listener"))).resultOrPartial(LOGGER::error).ifPresent((listener) -> {
                      this.listener = listener;
                  });
      } 

      This causes the previous listener to be thrown away and the new one to not be properly registered when calling the load method. This means that whenever this blockentity is removed it will fail to remove the old listener that it actually registered.

      This can be reproduced using: /data merge block location {dummy:1} on a sculk sensor, where it updates the listener but doesn't properly remove the previous listener or register the new one (making it nonfunctional). 

       

      A possible fix is to store the listener that is registered and ensure it is properly removed when updating the listener, and then register the new listener.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Owen1212055 Owen
              Votes:
              8 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                CHK: