CustomExplosion: Add method to change block explosion size separately
This commit is contained in:
parent
db5e6ad745
commit
2d4dcdbd8e
@ -44,30 +44,43 @@ public class CustomExplosion extends Explosion
|
||||
private boolean _damageBlocksEqually;
|
||||
private boolean _createFire;
|
||||
private boolean _ignoreRate = true;
|
||||
private float _blockExplosionSize;
|
||||
|
||||
public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause)
|
||||
{
|
||||
super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize);
|
||||
|
||||
_world = ((CraftWorld) loc.getWorld()).getHandle();
|
||||
_manager = manager;
|
||||
_damageReason = deathCause;
|
||||
_blockExplosionSize = explosionSize;
|
||||
}
|
||||
|
||||
public CustomExplosion setBlockExplosionSize(float explosionSize)
|
||||
{
|
||||
_blockExplosionSize = explosionSize;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomExplosion setIgnoreRate(boolean ignoreRate)
|
||||
{
|
||||
_ignoreRate = ignoreRate;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomExplosion setDamageBlocks(boolean damageBlocks)
|
||||
{
|
||||
b = damageBlocks;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomExplosion setBlocksDamagedEqually(boolean damageEqually)
|
||||
{
|
||||
_damageBlocksEqually = damageEqually;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -98,7 +111,7 @@ public class CustomExplosion extends Explosion
|
||||
@Override
|
||||
public void a()
|
||||
{
|
||||
if (this.size < 0.1F)
|
||||
if (Math.max(_blockExplosionSize, this.size) < 0.1F)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -122,7 +135,7 @@ public class CustomExplosion extends Explosion
|
||||
d3 /= d6;
|
||||
d4 /= d6;
|
||||
d5 /= d6;
|
||||
float f1 = this.size * (0.7F + this._world.random.nextFloat() * 0.6F);
|
||||
float f1 = this._blockExplosionSize * (0.7F + this._world.random.nextFloat() * 0.6F);
|
||||
|
||||
double d0 = this.posX;
|
||||
double d1 = this.posY;
|
||||
@ -229,7 +242,7 @@ public class CustomExplosion extends Explosion
|
||||
{
|
||||
this._world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F,
|
||||
(1.0F + (this._world.random.nextFloat() - this._world.random.nextFloat()) * 0.2F) * 0.7F);
|
||||
if ((this.size >= 2.0F) && (this.b))
|
||||
if ((this._blockExplosionSize >= 2.0F) && (this.b))
|
||||
this._world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
|
||||
else
|
||||
{
|
||||
@ -292,7 +305,7 @@ public class CustomExplosion extends Explosion
|
||||
d3 /= d6;
|
||||
d4 /= d6;
|
||||
d5 /= d6;
|
||||
double d7 = 0.5D / (d6 / this.size + 0.1D);
|
||||
double d7 = 0.5D / (d6 / this._blockExplosionSize + 0.1D);
|
||||
|
||||
d7 *= (this._world.random.nextFloat() * this._world.random.nextFloat() + 0.3F);
|
||||
d3 *= d7;
|
||||
@ -307,7 +320,7 @@ public class CustomExplosion extends Explosion
|
||||
{
|
||||
if (block.a(this) && _dropItems)
|
||||
{
|
||||
block.dropNaturally(this._world, i, j, k, this._world.getData(i, j, k), size, 0);
|
||||
block.dropNaturally(this._world, i, j, k, this._world.getData(i, j, k), _blockExplosionSize, 0);
|
||||
}
|
||||
|
||||
this._world.setTypeAndData(i, j, k, Blocks.AIR, 0, 3);
|
||||
@ -337,7 +350,7 @@ public class CustomExplosion extends Explosion
|
||||
}
|
||||
}
|
||||
|
||||
PacketPlayOutExplosion explosion = new PacketPlayOutExplosion(this.posX, this.posY, this.posZ, this.size,
|
||||
PacketPlayOutExplosion explosion = new PacketPlayOutExplosion(this.posX, this.posY, this.posZ, this._blockExplosionSize,
|
||||
new ArrayList(), null);
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
((CraftPlayer) p).getHandle().playerConnection.sendPacket(explosion);
|
||||
|
Loading…
Reference in New Issue
Block a user