CustomExplosion: Added option to limit falling blocks that spawn, removed 'Reason' to prevent CustomDamageEvent from using a mod instead of initialDamage (wtf?)
This commit is contained in:
parent
fc7c6e5831
commit
2d59bb4010
@ -1,6 +1,8 @@
|
||||
package mineplex.minecraft.game.core.explosion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -49,6 +51,7 @@ public class CustomExplosion extends Explosion
|
||||
private mineplex.core.explosion.Explosion _explosion;
|
||||
private float _damage;
|
||||
private boolean _useCustomDamage;
|
||||
private int _maxFallingBlocks = -1;
|
||||
|
||||
public CustomExplosion(DamageManager manager, mineplex.core.explosion.Explosion explosion, Location loc, float explosionSize,
|
||||
String deathCause)
|
||||
@ -94,6 +97,13 @@ public class CustomExplosion extends Explosion
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomExplosion setFallingBlockExplosionAmount(int maxFallingBlocks)
|
||||
{
|
||||
_maxFallingBlocks = maxFallingBlocks;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CustomExplosion setDamageBlocks(boolean damageBlocks)
|
||||
{
|
||||
b = damageBlocks;
|
||||
@ -246,7 +256,7 @@ public class CustomExplosion extends Explosion
|
||||
if (entity.getBukkitEntity() instanceof LivingEntity)
|
||||
{
|
||||
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null,
|
||||
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason);
|
||||
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -319,7 +329,21 @@ public class CustomExplosion extends Explosion
|
||||
|
||||
if (_fallingBlockExplosion)
|
||||
{
|
||||
_explosion.BlockExplosion(event.GetBlocks(), new Location(_world.getWorld(), posX, posY, posZ), false, false);
|
||||
Collection<org.bukkit.block.Block> blocks = event.GetBlocks();
|
||||
|
||||
if (_maxFallingBlocks != -1)
|
||||
{
|
||||
blocks = new ArrayList<org.bukkit.block.Block>(blocks);
|
||||
|
||||
Collections.shuffle((ArrayList) blocks);
|
||||
|
||||
while (blocks.size() > Math.max(0, _maxFallingBlocks))
|
||||
{
|
||||
blocks.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
_explosion.BlockExplosion(blocks, new Location(_world.getWorld(), posX, posY, posZ), false, false);
|
||||
}
|
||||
|
||||
Iterator iterator = this.blocks.iterator();
|
||||
|
Loading…
Reference in New Issue
Block a user