better cannon crater particles
This commit is contained in:
parent
3b18b93286
commit
2445e73623
@ -38,6 +38,7 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
@ -64,6 +65,9 @@ public class Cannon implements Listener
|
||||
public static final List<Integer> SULPHUR_SLOTS = Arrays.asList(1, 3, 5, 7);
|
||||
public static final List<Integer> EMPTY_SLOTS = Arrays.asList(0, 2, 6, 8);
|
||||
|
||||
private static final double[] VERT_POWER = { 0.5, 0.75631, 0.9382 };
|
||||
private static final double[] HORIZ_POWER = { 0.8, 1.1241, 1.34231 };
|
||||
|
||||
private Location _location;
|
||||
private CannonState _state;
|
||||
|
||||
@ -170,14 +174,17 @@ public class Cannon implements Listener
|
||||
|
||||
_projectile = tnt;
|
||||
|
||||
double vVel = VERT_POWER[getPower() - 1];
|
||||
double hMulti = HORIZ_POWER[getPower() - 1];
|
||||
|
||||
Vector velocity = UtilAlg.getTrajectory(
|
||||
getArmorStand().getLocation(),
|
||||
UtilAlg.moveForward(
|
||||
getArmorStand().getLocation(),
|
||||
2.,
|
||||
(float) Math.toDegrees(getArmorStand().getHeadPose().getY()), false))
|
||||
.setY(1 + ((((double) getPower() - 1.d)) / 2.d))
|
||||
.multiply(((double) getPower()) / 2.d);
|
||||
.multiply(hMulti)
|
||||
.setY(vVel);
|
||||
|
||||
tnt.setVelocity(velocity);
|
||||
|
||||
@ -222,7 +229,7 @@ public class Cannon implements Listener
|
||||
|
||||
_projectile.setFuseTicks(40);
|
||||
|
||||
if ((Math.abs(_projectile.getVelocity().getX()) < 0.1 || Math.abs(_projectile.getVelocity().getZ()) < 0.1) && _projectile.getTicksLived() >= 10)
|
||||
if ((Math.abs(_projectile.getVelocity().getX()) < 0.01 || Math.abs(_projectile.getVelocity().getZ()) < 0.01) && UtilBlock.getInRadius(_projectile.getLocation(), 2).keySet().stream().filter(block -> !UtilItem.isBoundless(block.getType())).iterator().hasNext() && _projectile.getTicksLived() >= 10)
|
||||
{
|
||||
//Do Explosion;
|
||||
|
||||
@ -243,7 +250,7 @@ public class Cannon implements Listener
|
||||
{
|
||||
if (System.currentTimeMillis() - _lastFired < COOLDOWN)
|
||||
{
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is cooling down."));
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is cooling down. (" + F.time(UtilTime.MakeStr(COOLDOWN - (System.currentTimeMillis() - _lastFired)) + C.mBody + ")")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -251,7 +258,7 @@ public class Cannon implements Listener
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is not correctly loaded. (" + F.time(UtilTime.MakeStr(COOLDOWN - (System.currentTimeMillis() - _lastFired)) + ")")));
|
||||
UtilPlayer.message(_rider, F.main("Clans", "Cannon is not correctly loaded."));
|
||||
_rider.playSound(_rider.getLocation(), Sound.CLICK, 1.f, 1.f);
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,13 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -32,7 +35,6 @@ public class CannonCrater implements Listener
|
||||
private long _birthTime;
|
||||
|
||||
private List<CraterBlock> _blocks;
|
||||
private List<CraterEffect> _effects;
|
||||
|
||||
public CannonCrater(Cannon cannon, Location origin)
|
||||
{
|
||||
@ -41,13 +43,10 @@ public class CannonCrater implements Listener
|
||||
|
||||
_birthTime = System.currentTimeMillis();
|
||||
_blocks = new ArrayList<>();
|
||||
_effects = new ArrayList<>();
|
||||
|
||||
UtilServer.getServer().getPluginManager().registerEvents(this, ClansManager.getInstance().getPlugin());
|
||||
|
||||
createExplosion();
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -58,24 +57,17 @@ public class CannonCrater implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<CraterEffect> iterator = _effects.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
CraterEffect effect = iterator.next();
|
||||
_blocks.stream().filter(block -> block.Type == Material.COAL_BLOCK).forEach(block -> {
|
||||
long lifetime = System.currentTimeMillis() - _birthTime;
|
||||
|
||||
effect.update();
|
||||
long max = 25000 - (long) ((block.DistanceToOrigin * 1000) * 3.5);
|
||||
|
||||
if (effect.getLifetime() >= effect.getMaxLifetime())
|
||||
if (lifetime < max)
|
||||
{
|
||||
iterator.remove();
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, block.Location.clone().add(.5, 1.1, .5), new Vector(0, 0, 0), .4f, 1, ViewDist.MAX);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.SMOKE, block.Location.clone().add(.5, 1.1, .5), new Vector(0, 0, 0), .4f, 1, ViewDist.MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void start()
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void createExplosion()
|
||||
@ -122,11 +114,6 @@ public class CannonCrater implements Listener
|
||||
{
|
||||
_blocks.add(new CraterBlock(above.getLocation(), distance, Material.AIR));
|
||||
}
|
||||
|
||||
if (!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()) && distance >= 1.5 && UtilMath.random.nextBoolean())
|
||||
{
|
||||
_effects.add(new CraterEffect(ParticleType.FLAME, block.getLocation().add(0, .5, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,10 +126,15 @@ public class CannonCrater implements Listener
|
||||
|
||||
if (block.getType() == Material.AIR) continue;
|
||||
|
||||
if (distance > 2 && Math.random() > .75 && UtilItem.isBoundless(block.getRelative(BlockFace.UP).getType()) && !UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()))
|
||||
if (
|
||||
distance > 2 &&
|
||||
Math.random() > .75 &&
|
||||
UtilItem.isBoundless(block.getRelative(BlockFace.UP).getType()) &&
|
||||
!UtilItem.isBoundless(block.getRelative(BlockFace.DOWN).getType()) &&
|
||||
!block.getRelative(BlockFace.UP).getType().equals(Material.COAL_BLOCK) &&
|
||||
!block.getRelative(BlockFace.DOWN).getType().equals(Material.COAL_BLOCK))
|
||||
{
|
||||
_blocks.add(new CraterBlock(block.getLocation(), distance, Material.COAL_BLOCK));
|
||||
_effects.add(new CraterEffect(ParticleType.FLAME, block.getLocation().add(0, .5, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
package mineplex.game.clans.clans.siege.cannon;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
|
||||
public class CraterEffect
|
||||
{
|
||||
private ParticleType _particle;
|
||||
private Location _location;
|
||||
|
||||
private final long _birthTime = System.currentTimeMillis();
|
||||
private final long _maxLifetime = 15000 + (UtilMath.random.nextInt(30000));
|
||||
|
||||
public CraterEffect(ParticleType particle, Location location)
|
||||
{
|
||||
_particle = particle;
|
||||
_location = location;
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
UtilParticle.PlayParticle(_particle, _location, new Vector(0, 0, 0), .1f, 1, ViewDist.MAX);
|
||||
}
|
||||
|
||||
public long getLifetime()
|
||||
{
|
||||
return System.currentTimeMillis() - _birthTime;
|
||||
}
|
||||
|
||||
public long getMaxLifetime()
|
||||
{
|
||||
return _maxLifetime;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user