use of icbm.classic.content.explosive.thread.ThreadLargeExplosion.IThreadCallBack in project ICBM-Classic by BuiltBrokenModding.
the class BlastSonic method doPreExplode.
@Override
public void doPreExplode() {
if (!this.world().isRemote) {
if (this.hasShockWave) {
for (int x = (int) (-this.getRadius() * 2); x < this.getRadius() * 2; ++x) {
for (int y = (int) (-this.getRadius() * 2); y < this.getRadius() * 2; ++y) {
for (int z = (int) (-this.getRadius() * 2); z < this.getRadius() * 2; ++z) {
Location targetPosition = position.add(new Pos(x, y, z));
Block blockID = world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
if (blockID != Blocks.air) {
Material material = blockID.getMaterial();
if (blockID != Blocks.bedrock && !(material.isLiquid()) && (blockID.getExplosionResistance(this.exploder, world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), position.xi(), position.yi(), position.zi()) > this.nengLiang || material == Material.glass)) {
targetPosition.setBlock(world(), Blocks.air);
}
}
}
}
}
}
this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.nengLiang, this.exploder, new IThreadCallBack() {
@Override
public float getResistance(World world, IPos3D explosionPosition, IPos3D targetPosition, Entity source, Block block) {
float resistance = 0;
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
resistance = 1f;
} else {
resistance = block.getExplosionResistance(source, world, (int) targetPosition.x(), (int) targetPosition.y(), (int) targetPosition.z(), explosionPosition.x(), explosionPosition.y(), explosionPosition.z());
}
return resistance;
}
});
this.thread.start();
}
if (this.hasShockWave) {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "hypersonic", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
} else {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "sonicwave", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
}
Aggregations