Accessing Block data every few ticks within an Async Thread

Discussion in 'Spigot Plugin Development' started by xBallisticBlazex, Sep 12, 2018.

  1. Hey,

    Currently I'm using ProtocolLib API in order to listen to the Steer Packet. I make the car handle differently depending on blocks surrounding the entity.

    The issue is, I cannot seem to access block data within this Async thread without some lockup or issue taking place. Scheduling bukkit tasks would not work here as I may want to cancel the packet depending on this data while also wanting it to run in real time with little delay.

    How can I assess this sync issue?
  2. Choco


    Bukkit was not designed for async code execution. Hell, Minecraft wasn't designed for async code execution. The majority of the game is not thread safe, world components being one of those things. If you're querying the state of a block, doing so asynchronously is most likely not the best way to do that. You're going to run into inconsistencies and unpredictable functionality.
    • Useful Useful x 1
  3. Seems like that's that then. I'll instead store all input data from the packet listener and use a sync task to read it and act accordingly.
    Thanks for that, I'll remember this next time I do something similar.