How should I make huge block change without locking main thread

Discussion in 'Plugin Development' started by jamesst20, Dec 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    Wow, thanks, you're awesome :)

    It looks like it makes a huge difference at large volumes. Sounds worth looking into... it's not like I haven't been tying into NMS all over the place lately anyway.

    You're right about combining the approaches, that's doable. I will probably just stick this in my mass update code for now - since the current "visual effect" is just a side-effect of doing incremental updates anyway, if I really want such an effect I should probably intentionally code it that way :D

    I suppose it'd be easy enough to just call updateClients periodically while processing, though- assuming that's safe to call more than once on the same MBU?
  2. Offline


    The way it's coded right now, you'd really want to create a new MBU object after calling notifyClients(), but a MBU object is very cheap to create (no special calculation, just intialising a few fields). The MBU tracks the bounding region for all the changes to know which chunks need refreshing, and notifyClients() doesn't reset that.
    NathanWolf likes this.
  3. Offline


    desht: Sorry to keep bugging you! Is your nms.api lib no longer public, or did you move it to another project? I'm looking at your CraftMBU code and trying to follow the breadcrumbs. :)

    EDIT: Nevermind, I found it! Unfortunately untagging you probably doesn't un-bug you, but... well thanks again!
    desht likes this.
  4. Offline


    desht Is there a way to not make my plugins weight 3 MB when I link dhutils ? :)

    Also, I was wondering,

    For a radius of 1000, it means : (1000 * 2 + 1) ^2 * 1000 = 4 004 001 000 Blocks to replace, is there a very very efficient way to check if the block to replace isn't already air ? Would it be faster to check if the block has to be replaced or the condition would be slower than replacing Material.air by Material.air?

  5. Offline


    Dhutils does add some weight to your plugin (I need to look at streamlining that a bit), but if you're ending up with 3MB, you're doing something wrong :) you can tell Maven to exclude most classes when you shade it (unfortunately the dynamic class loading for NMS abstraction defeats Maven's auto-minimisation)

    I'm not following your block calculations at all. For a cube of "radius" 1000, that would be for billion blocks. For a sphere of radius 1000, it's 4/3 * pi * one billion blocks. Either way, with that many blocks you have no choice but to stage it over many ticks, NMS or no NMS.
    jamesst20 likes this.
Thread Status:
Not open for further replies.

Share This Page