Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5617

setBlockData does not work when NotPlayEvent is called by redstone current

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • git-Spigot-6de3d4b-fc24934 (1.15.2)
    • Yes

      https://www.youtube.com/watch?v=2YZR8s9i2Ik

       

      Test source: https://github.com/toriato/TestNoteBlockEvent

      Thread: https://www.spigotmc.org/threads/cant-change-the-instrument-of-the-noteblock.421743/

       

      Title: Can't change the instrument of the NoteBlock

      Below code will works only for the manual change but not on redstone update
      I tested update the noteblock after the NoteBlock#setInstrument but it didn't works either

      @EventHandler(priority = EventPriority.HIGHEST)
      public void onNotePlay (NotePlayEvent event) {
        Block block = event.getBlock();
        NoteBlock blockData = (NoteBlock) block.getBlockData();
        blockData.setInstrument(Instrument.BANJO);
      
        // Block will not be updated when the event called by redstone
        block.setBlockData(blockData);
      
        // Some of method I tried to update the block self and relative blocks
        block.getState().update(); // not works
        block.getState().update(true); // nah
        block.getRelative(BlockFace.DOWN).setType(Material.AIR); // no chance
      }

       

            Unassigned Unassigned
            toriato Sangha Lee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: