}
}
public void strikePlayers(List<Player> toStrike) {
for (Player player : toStrike) {
Point playerPos = player.getPhysics().getPosition();
final int posX = GenericMath.floor(playerPos.getX());
final int posY = GenericMath.floor(playerPos.getY());
final int posZ = GenericMath.floor(playerPos.getZ());
for (int tries = 0; tries < 10; tries++) {
//pick a random chunk between -4, -4, to 4, 4 relative to the player's position to strike at
int cx = (ra.nextBoolean() ? -1 : 1) * ra.nextInt(5);
int cz = (ra.nextBoolean() ? -1 : 1) * ra.nextInt(5);
//pick random coords to try to strike at inside the chunk (0, 0) to (15, 15)
int rx = ra.nextInt(16);
int rz = ra.nextInt(16);
//pick a offset from the player's y position to strike at (-15 - +15) of their position
int offsetY = (ra.nextBoolean() ? -1 : 1) * ra.nextInt(15);
int x = posX + cx * 16 + rx;
int y = posY + offsetY;
int z = posZ + cz * 16 + rz;
if (weather.isRainingAt(x, y, z, false)) {
int lightning = 1;
//30% chance of extra lightning at the spot
if (ra.nextInt(10) < 3) {
lightning += ra.nextInt(MAX_LIGHTNING_BRANCHES);
}
for (int strikes = 0; strikes < lightning; strikes++) {
float adjustX = 0.5F;
float adjustY = 0.0F;
float adjustZ = 0.5F;
//if there are extra strikes, tweak their placement slightly
if (strikes > 0) {
adjustX += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(2);
adjustY += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(8);
adjustZ += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(2);
}
World world = getWorld();
Point point = new Point(world, x + adjustX, y + adjustY, z + adjustZ);
world.createAndSpawnEntity(point, LoadOption.NO_LOAD, Lightning.class);
for (Player p : GeneralEffects.LIGHTNING_THUNDER.getNearbyPlayers(point, null, 600)) {
double dist = p.getPhysics().getPosition().distanceSquared(point);
float volume = (float) (10000F - Math.pow(dist, 0.73));
if (volume > 0) {