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

BlockState's obtained in BlockFormEvent are not persistent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-e5e5c7c-c24abab (MC: 1.13.2) (Implementing API version 1.13.2-R0.1-SNAPSHOT)
    • Yes

      When a BlockState is obtained in the BlockFormEvent, and then passed to a separate thread, the location data in the BlockState is changing.

      For example:

      BlockPlaceEvent (works properly):
      8:57:07 INFO]: Queued block: WHITE_CONCRETE_POWDER, 200, 68, -132
      [18:57:08 INFO]: Processing block: WHITE_CONCRETE_POWDER, 200, 68, -132

      BlockFormEvent (location data changed):
      [18:57:08 INFO]: Queued block: WHITE_CONCRETE, 200, 68, -132
      [18:57:09 INFO]: Processing block: WHITE_CONCRETE, 199, 0, -132

      This is running identical code, just triggered from different events.

      @EventHandler(priority = EventPriority.MONITOR)
      protected void onBlockForm(BlockFormEvent event) {
        BlockState blockState1 = event.getNewState();
        BlockState blockState2 = event.getBlock().getState();
        System.out.println("Location: " + blockState1.getX() + ", " + blockState1.getY() + ", " + blockState1.getZ());
        System.out.println("Location: " + blockState2.getX() + ", " + blockState2.getY() + ", " + blockState2.getZ());
        // passing either of these states into a secondary thread results in the location output from the BlockState changing
      }
      

      Update:
      If I do the following to obtain the BlockState, it persists properly:

      @EventHandler(priority = EventPriority.MONITOR)
      protected void onBlockForm(BlockFormEvent event) {
        BlockState blockState1 = event.getBlock().getLocation().getBlock().getState()
        System.out.println("Location: " + blockState1.getX() + ", " + blockState1.getY() + ", " + blockState1.getZ());
        // This persists properly when passed into a secondary thread
      }
      

            Unassigned Unassigned
            Intelli Intelli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: