block.setType() causes mini lag EVERY block?

Discussion in 'Plugin Development' started by Regenwurm97, Dec 30, 2016.

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

    Regenwurm97

    Hey guys :)

    In one of my plugins I replace some blocks with another block type. Unfortunately, whenever I change a single block, if it's in the sight of a player, this player will have a small lag.
    Basically, I'm replacing a number of blocks with a replace material one after another (with a delay). All the code is placed in a sync timer which is executed with a delay (some ticks) between each execution - (shouldn't be an overload for the server to replace a block at a time I think :D)

    The only code snippet in the run() method is:
    Code:
    Block block = this.location.getBlock();
    block.setTypeIdAndData(this.material.getId(), data, false);
    And when I run this in a timer for some locations, a player standing close and looking on the blocks will have lag spikes (so in the moment a block is changed, FPS drop)

    Is there a more recommended way of updating blocks so the frame doesn't stutter? Or is it just bc. of my limited resources (localhost running)?
     
  2. Offline

    Kaelinator

    Hmmm. Just how many blocks are being updated?

    Sent from my SAMSUNG-SM-G935A using Tapatalk
     
  3. Offline

    Zombie_Striker

    @Regenwurm97
    Unless you have a good rig, you are almost always going to have lagspikes/FPS loss when you are hosting the server and playing at the same time.

    There is no way to to update blocks around the player without creating some lagspikes.
     
  4. Offline

    Regenwurm97

    Doesn't matter, even only 1 block change causes a mini lag spike...

    Alright thanks for that, I bought a 1$ game server for 3 days and will test on that now :)
     
Thread Status:
Not open for further replies.

Share This Page