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 }