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));
}
}
}
}
}
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));
}
}
}
}
}
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);
}
}
Aggregations