Search in sources :

Example 6 with PacketPlaySound

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);
    }
}
Also used : PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound)

Aggregations

PacketPlaySound (pneumaticCraft.common.network.PacketPlaySound)6 PacketSpawnParticle (pneumaticCraft.common.network.PacketSpawnParticle)4 EntityItem (net.minecraft.entity.item.EntityItem)2 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 Random (java.util.Random)1 Block (net.minecraft.block.Block)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 EntityFireball (net.minecraft.entity.projectile.EntityFireball)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IPneumaticWrenchable (pneumaticCraft.api.block.IPneumaticWrenchable)1 PacketSetEntityMotion (pneumaticCraft.common.network.PacketSetEntityMotion)1