use of pneumaticCraft.common.network.PacketPlaySound in project PneumaticCraft by MineMaarten.
the class TileEntityPneumaticBase method airLeak.
/**
* Method to release air in the air. It takes air from a specific side, plays a sound effect, and spawns smoke particles.
* @param side
*/
@Override
public void airLeak(ForgeDirection side) {
if (worldObj.isRemote || Math.abs(getPressure(side)) < 0.01F)
return;
double motionX = side.offsetX;
double motionY = side.offsetY;
double motionZ = side.offsetZ;
if (soundCounter <= 0) {
soundCounter = 20;
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.LEAKING_GAS_SOUND, xCoord, yCoord, zCoord, 0.1F, 1.0F, true), worldObj);
}
if (getPressure(side) < 0) {
double speed = getPressure(side) * 0.1F - 0.1F;
NetworkHandler.sendToAllAround(new PacketSpawnParticle("smoke", xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), worldObj);
int dispersedAmount = -(int) (getPressure(side) * PneumaticValues.AIR_LEAK_FACTOR) + 20;
if (getCurrentAir(side) > dispersedAmount)
dispersedAmount = -getCurrentAir(side);
onAirDispersion(dispersedAmount, side);
addAir(dispersedAmount, side);
} else {
double speed = getPressure(side) * 0.1F + 0.1F;
// if(DateEventHandler.isEvent()) {
//DateEventHandler.spawnFirework(worldObj, xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D);
// } else {
NetworkHandler.sendToAllAround(new PacketSpawnParticle("smoke", xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), worldObj);
// }
int dispersedAmount = (int) (getPressure(side) * PneumaticValues.AIR_LEAK_FACTOR) + 20;
if (dispersedAmount > getCurrentAir(side))
dispersedAmount = getCurrentAir(side);
onAirDispersion(-dispersedAmount, side);
addAir(-dispersedAmount, side);
}
}
Aggregations