distSq = dist * dist;
}
@Override
public void onPacketSending(final PacketEvent event) {
final PacketContainer packetContainer = event.getPacket();
// Compare sound effect name.
if (!contains(packetContainer.getStrings().read(0))) {
return;
}
final Player player = event.getPlayer();
final Location loc = player.getLocation(); // TODO: Use getLocation(useLoc) [synced if async].
// Compare distance of player to the weather location.
final StructureModifier<Integer> ints = packetContainer.getIntegers();
if (TrigUtil.distanceSquared(ints.read(0) / 8, ints.read(2) / 8, loc.getX(), loc.getZ()) > distSq) {
// TODO: Get from a NetConfig (optimized).
if (ConfigManager.getConfigFile(player.getWorld().getName()).getBoolean(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
event.setCancelled(true);
}