Mekanism-tilera-Edition/common/mekanism/client/sound/GasMaskSound.java

60 lines
1.1 KiB
Java
Raw Normal View History

2013-12-06 21:26:44 +01:00
package mekanism.client.sound;
import mekanism.client.ClientPlayerTickHandler;
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);
}
@Override
public boolean update(World world)
{
if(player.isDead)
{
return false;
}
2013-12-07 23:06:11 +01:00
else if(player.worldObj != world)
{
return false;
}
2013-12-06 21:26:44 +01:00
else if(!world.loadedEntityList.contains(player))
{
return false;
}
else if(!hasGasMask(player))
{
return false;
}
else {
if(ClientPlayerTickHandler.isGasMaskOn(player) != isPlaying)
{
if(ClientPlayerTickHandler.isGasMaskOn(player))
{
play();
}
else {
stopLoop();
}
}
}
if(isPlaying)
{
ticksSincePlay++;
}
return true;
}
private boolean hasGasMask(EntityPlayer player)
{
return player.inventory.armorInventory[3] != null && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask;
}
}