PC-34 - Effects/Particles when you blow up enemy
This commit is contained in:
parent
f2d450d26b
commit
2fcd809447
@ -6,6 +6,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Stream;
|
||||
@ -612,4 +613,13 @@ public class UtilAlg
|
||||
|
||||
return new Location(location.getWorld(), x, location.getY(), z, location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
public static Location getRandomLocation(Location center, int radius)
|
||||
{
|
||||
Random r = new Random();
|
||||
int x = r.nextInt(radius * 2) - radius;
|
||||
int y = r.nextInt(radius * 2) - radius;
|
||||
int z = r.nextInt(radius * 2) - radius;
|
||||
return center.clone().add(x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package mineplex.game.clans.clans.siege.weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
@ -20,6 +23,7 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
@ -32,6 +36,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
|
||||
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
|
||||
import mineplex.game.clans.clans.siege.weapon.projectile.ProjectileAttributes;
|
||||
import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
|
||||
@ -406,4 +411,35 @@ public class Cannon extends SiegeWeapon
|
||||
return new double[] { yAdd, hMult };
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void explosionEffects(SiegeWeaponExplodeEvent event)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
// Explosion particle effects.
|
||||
Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
|
||||
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
|
||||
}
|
||||
|
||||
// Block explosion.
|
||||
ArrayList<Block> blocks = new ArrayList<>();
|
||||
int attempts = 0;
|
||||
while (blocks.size() < 10 && (attempts < 30))
|
||||
{
|
||||
Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock();
|
||||
if ((block.getType() != Material.AIR) && (!blocks.contains(block)))
|
||||
{
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
attempts++;
|
||||
}
|
||||
|
||||
_siegeManager.getClansManager().getExplosion().BlockExplosion(
|
||||
blocks,
|
||||
event.getProjectile().getLocation(),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user