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

SculkSensorBlockEntity and SculkShriekerBlockEntity leak VibrationListeners on update

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 23w16a
    • 1.19, 1.19.1 Pre-release 1, 1.19.2, 22w42a, 1.19.3 Pre-release 1
    • None
    • Confirmed
    • Game Events
    • Low

      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.

            kingbdogz [Mojang] Brandon Pearce
            Owen1212055 Owen
            Votes:
            10 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: