use of net.minecraft.block.BlockTNT in project ArsMagica2 by Mithion.
the class AffinityHelper method applyFulmintion.
private void applyFulmintion(EntityPlayer ent, float lightningDepth) {
//chance to light nearby TNT
if (!ent.worldObj.isRemote) {
if (lightningDepth > 0.5f && lightningDepth <= 0.8f) {
int offsetX = (int) ent.posX - 5 + ent.getRNG().nextInt(11);
int offsetY = (int) ent.posY - 5 + ent.getRNG().nextInt(11);
int offsetZ = (int) ent.posZ - 5 + ent.getRNG().nextInt(11);
Block block = ent.worldObj.getBlock(offsetX, offsetY, offsetZ);
if (block == Blocks.tnt) {
ent.worldObj.setBlockToAir(offsetX, offsetY, offsetZ);
((BlockTNT) Blocks.tnt).func_150114_a(ent.worldObj, offsetX, offsetY, offsetZ, 1, ent);
}
}
//chance to supercharge nearby creepers
if (lightningDepth >= 0.7f && lightningDepth <= 0.95f && ent.getRNG().nextDouble() < 0.05f) {
List<EntityCreeper> creepers = ent.worldObj.getEntitiesWithinAABB(EntityCreeper.class, ent.boundingBox.expand(5, 5, 5));
for (EntityCreeper creeper : creepers) {
creeper.getDataWatcher().updateObject(17, (byte) 1);
AMCore.proxy.particleManager.BoltFromEntityToEntity(ent.worldObj, ent, ent, creeper, 0, 1, -1);
}
}
}
if (lightningDepth > 0.25f && ent.isWet()) {
ExtendedProperties.For(ent).deductMana(100);
if (ent.worldObj.isRemote) {
AMCore.proxy.particleManager.BoltFromEntityToPoint(ent.worldObj, ent, ent.posX - 2 + ent.getRNG().nextDouble() * 4, ent.posY + ent.getEyeHeight() - 2 + ent.getRNG().nextDouble() * 4, ent.posZ - 2 + ent.getRNG().nextDouble() * 4);
} else {
if (ent.getRNG().nextDouble() < 0.4f)
ent.worldObj.playSoundAtEntity(ent, "arsmagica2:misc.event.mana_shield_block", 1.0f, ent.worldObj.rand.nextFloat() + 0.5f);
}
}
}
Aggregations