use of net.glowstone.entity.GlowPlayer 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 net.glowstone.entity.GlowPlayer 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 net.glowstone.entity.GlowPlayer 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);
}
}
use of net.glowstone.entity.GlowPlayer in project Dragonet-Legacy by DragonetMC.
the class RemoveBlockPacketTranslator method handleSpecific.
@Override
public Message[] handleSpecific(RemoveBlockPacket packet) {
if (!(this.getSession().getPlayer() instanceof Player)) {
return null;
}
if (getSession().getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
final GlowPlayer player = getSession().getPlayer();
GlowWorld world = player.getWorld();
GlowBlock block = world.getBlockAt(packet.x, packet.y, packet.z);
PlayerInteractEvent interactEvent = EventFactory.onPlayerInteract(player, Action.LEFT_CLICK_BLOCK, block, BlockFace.UP);
if (interactEvent.isCancelled()) {
player.sendBlockChange(block.getLocation(), block.getType(), block.getData());
return null;
}
block.setType(Material.AIR);
} else {
// Not Creative
DiggingMessage msgFinishBreak = new DiggingMessage(DiggingMessage.FINISH_DIGGING, packet.x, packet.y, packet.z, 1);
return new Message[] { msgFinishBreak };
}
return null;
}
Aggregations