2013-12-06 21:26:44 +01:00
|
|
|
package mekanism.client.sound;
|
|
|
|
|
2013-12-09 02:35:45 +01:00
|
|
|
import mekanism.client.ClientTickHandler;
|
2013-12-06 21:26:44 +01:00
|
|
|
import mekanism.common.item.ItemGasMask;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class GasMaskSound extends PlayerSound
|
|
|
|
{
|
|
|
|
public GasMaskSound(String id, EntityPlayer entity)
|
|
|
|
{
|
|
|
|
super(id, "GasMask.ogg", entity);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
@Override
|
|
|
|
public boolean update(World world)
|
|
|
|
{
|
2013-12-08 05:51:07 +01:00
|
|
|
if(!super.update(world))
|
2013-12-06 21:26:44 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(!hasGasMask(player))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
2013-12-09 02:35:45 +01:00
|
|
|
if(ClientTickHandler.isGasMaskOn(player) != isPlaying)
|
2013-12-06 21:26:44 +01:00
|
|
|
{
|
2013-12-09 02:35:45 +01:00
|
|
|
if(ClientTickHandler.isGasMaskOn(player))
|
2013-12-06 21:26:44 +01:00
|
|
|
{
|
|
|
|
play();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stopLoop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
if(isPlaying)
|
|
|
|
{
|
|
|
|
ticksSincePlay++;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
private boolean hasGasMask(EntityPlayer player)
|
|
|
|
{
|
|
|
|
return player.inventory.armorInventory[3] != null && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask;
|
|
|
|
}
|
|
|
|
}
|