Search in sources :

Example 1 with ChunkLocation

use of org.dragonet.ChunkLocation in project Dragonet-Legacy by DragonetMC.

the class ClientChunkManager method prepareLoginChunks.

/**
 * Automatically prepare chunks
 */
public void prepareLoginChunks() {
    if (!(this.getSession().getPlayer() instanceof GlowPlayer)) {
        return;
    }
    int chunkX = this.getSession().getPlayer().getLocation().getChunk().getX();
    int chunkZ = this.getSession().getPlayer().getLocation().getChunk().getZ();
    for (int distance = 5; distance >= 0; distance--) {
        for (int x = chunkX - distance; x < chunkX + distance; x++) {
            for (int z = chunkZ - distance; z < chunkZ + distance; z++) {
                if (Math.sqrt((chunkX - x) * (chunkX - x) + (chunkZ - z) * (chunkZ - z)) < 5) {
                    this.prepareChunk(new ChunkLocation(x, z));
                }
            }
        }
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) ChunkLocation(org.dragonet.ChunkLocation)

Example 2 with ChunkLocation

use of org.dragonet.ChunkLocation in project Dragonet-Legacy by DragonetMC.

the class ClientChunkManager method autoPrepareChunks.

/**
 * Automatically prepare chunks
 */
public void autoPrepareChunks() {
    if (!(this.getSession().getPlayer() instanceof GlowPlayer)) {
        return;
    }
    int chunkX = this.getSession().getPlayer().getLocation().getChunk().getX();
    int chunkZ = this.getSession().getPlayer().getLocation().getChunk().getZ();
    for (int distance = 6; distance >= 0; distance--) {
        for (int x = chunkX - distance; x < chunkX + distance; x++) {
            for (int z = chunkZ - distance; z < chunkZ + distance; z++) {
                if (Math.sqrt((chunkX - x) * (chunkX - x) + (chunkZ - z) * (chunkZ - z)) < 8) {
                    this.prepareChunk(new ChunkLocation(x, z));
                }
            }
        }
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) ChunkLocation(org.dragonet.ChunkLocation)

Example 3 with ChunkLocation

use of org.dragonet.ChunkLocation in project Dragonet-Legacy by DragonetMC.

the class ClientChunkManager method sendChunks.

/**
 * Send all queued chunks to the client and mark them as sent
 */
public synchronized void sendChunks() {
    if (!(this.getSession().getPlayer() instanceof GlowPlayer)) {
        return;
    }
    ChunkLocation chunkLocation;
    while ((chunkLocation = this.chunksQueue.poll()) != null) {
        this.sendChunk(chunkLocation.getX(), chunkLocation.getZ());
        this.chunksLoaded.add(chunkLocation);
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) ChunkLocation(org.dragonet.ChunkLocation)

Aggregations

GlowPlayer (net.glowstone.entity.GlowPlayer)3 ChunkLocation (org.dragonet.ChunkLocation)3