Manually refresh a chunk

Discussion in 'Plugin Development' started by Skyost, Aug 15, 2015.

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

    Skyost

    Hello there !
    I want to manually refresh a chunk. I was using world.refreshChunk(...) before 1.8.x but now it just does not work.
    I tried block.getState().update(...) (with each block inside the chunk) and world.load(...) but it does not work too :(
    Any idea or suggestion ?

    Thanks !

    EDIT : Okay, found a solution, I made this small class :
    Show Spoiler

    Code:
    public class PacketMapChunk {
    
        private final net.minecraft.server.v1_8_R3.Chunk chunk;
    
        public PacketMapChunk(final org.bukkit.Chunk chunk) {
            this.chunk = ((CraftChunk)chunk).getHandle();
        }
    
        public final void send(final Player player) {
            ((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, true, 20));
        }
    
    }

    You can use it like that :
    Show Spoiler

    Code:
    for(final Chunk chunk : chunks) {
        for(final Player player : Bukkit.getOnlinePlayers()) {
            new PacketMapChunk(chunk).send(player);
        }
        world.refreshChunk(chunk.getX(), chunk.getZ());
    }
     
    Last edited: Aug 15, 2015
Thread Status:
Not open for further replies.

Share This Page