CustomExplosion: Added method to change to customdamage, added method to change the block damage differently from the entity damage
This commit is contained in:
parent
d5137d9ec6
commit
290767c58d
@ -47,8 +47,11 @@ public class CustomExplosion extends Explosion
|
||||
private float _blockExplosionSize;
|
||||
private boolean _fallingBlockExplosion;
|
||||
private mineplex.core.explosion.Explosion _explosion;
|
||||
private float _damage;
|
||||
private boolean _useCustomDamage;
|
||||
|
||||
public CustomExplosion(DamageManager manager, mineplex.core.explosion.Explosion explosion, Location loc, float explosionSize, String deathCause)
|
||||
public CustomExplosion(DamageManager manager, mineplex.core.explosion.Explosion explosion, Location loc, float explosionSize,
|
||||
String deathCause)
|
||||
{
|
||||
super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize);
|
||||
|
||||
@ -59,6 +62,17 @@ public class CustomExplosion extends Explosion
|
||||
_explosion = explosion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Center of explosion does this much damage
|
||||
*/
|
||||
public CustomExplosion setExplosionDamage(float damage)
|
||||
{
|
||||
_damage = damage;
|
||||
_useCustomDamage = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomExplosion setBlockExplosionSize(float explosionSize)
|
||||
{
|
||||
_blockExplosionSize = explosionSize;
|
||||
@ -214,9 +228,20 @@ public class CustomExplosion extends Explosion
|
||||
d0 /= d8;
|
||||
d1 /= d8;
|
||||
d2 /= d8;
|
||||
|
||||
// Performs a raytrace that determines the percentage of solid blocks between the two
|
||||
double d9 = this._world.a(vec3d, entity.boundingBox);
|
||||
double d10 = (1.0D - d7) * d9;
|
||||
int damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D);
|
||||
int damage;
|
||||
|
||||
if (_useCustomDamage)
|
||||
{
|
||||
damage = Math.max(0, (int) ((_damage * d9) * (d8 / size)));
|
||||
}
|
||||
else
|
||||
{
|
||||
damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D);
|
||||
}
|
||||
|
||||
if (entity.getBukkitEntity() instanceof LivingEntity)
|
||||
{
|
||||
@ -296,7 +321,7 @@ public class CustomExplosion extends Explosion
|
||||
{
|
||||
_explosion.BlockExplosion(event.GetBlocks(), new Location(_world.getWorld(), posX, posY, posZ), false, false);
|
||||
}
|
||||
|
||||
|
||||
Iterator iterator = this.blocks.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
|
Loading…
Reference in New Issue
Block a user