public void broadcastServerPacket(PacketContainer packet, Location origin, int maxObserverDistance) {
try {
// Square the maximum too
int maxDistance = maxObserverDistance * maxObserverDistance;
World world = origin.getWorld();
Location recycle = origin.clone();
// Only broadcast the packet to nearby players
for (Player player : server.getOnlinePlayers()) {
if (world.equals(player.getWorld()) &&
getDistanceSquared(origin, recycle, player) <= maxDistance) {
sendServerPacket(player, packet);
}
}