Block restoration

Discussion in 'Plugin Development' started by WolfMage1, Nov 4, 2016.

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

    WolfMage1

    I made a thread before this asking if there were any alternate methods to using NMS for block restoration and it turns out that NMS really is the only way to go about it (I know there's bukkits setBlock but that's too laggy for thousands of blocks)

    So, I found a method in NMS's Chunk class and it appears to do what I want it to, but the blocks don't actually become visible with the method, do I have to send a packet to players saying the blocks are there? or do I have to unload the chunk then reload it? etc

    Code:
    public void setBlockFast(World world, BlockPosition blockPosition) {
            net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle();
            Chunk chunk = w.getChunkAtWorldCoords(blockPosition);
            chunk.a(blockPosition, chunk.getBlockData(blockPosition));
        }
     
  2. Offline

    Zombie_Striker

    @WolfMage1
    The reason why setBlock is "laggy" (its not laggy for the server. Its only laggy for the player) is because the block-change packet gets sent. The lag is caused by the client having to change all render information for the specified block.
     
  3. Offline

    WolfMage1

    I know that, but with that method the blocks dont actually become visible, so I was asking if I had to send the packet, or if the world doesn't know the blocks are there and I have to unload the chunk then reload it.

    Alright, it works now, turns out the block changes were actually happening, they just weren't visible until you re logged or unloaded then reloaded the chunk. So I guess now I need to send the block change packet?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 4, 2016
Thread Status:
Not open for further replies.

Share This Page