2013-12-06 21:26:44 +01:00
|
|
|
package mekanism.client.sound;
|
|
|
|
|
2013-12-22 07:04:35 +01:00
|
|
|
import mekanism.api.Pos3D;
|
2013-12-06 21:26:44 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-08 05:51:07 +01:00
|
|
|
import net.minecraft.world.World;
|
2013-12-06 21:26:44 +01:00
|
|
|
|
|
|
|
public abstract class PlayerSound extends Sound
|
|
|
|
{
|
|
|
|
/** The TileEntity this sound is associated with. */
|
|
|
|
public EntityPlayer player;
|
|
|
|
|
|
|
|
public int ticksSincePlay = 0;
|
|
|
|
|
|
|
|
public PlayerSound(String id, String sound, EntityPlayer entity)
|
|
|
|
{
|
2013-12-22 07:04:35 +01:00
|
|
|
super(id, sound, entity, new Pos3D(entity));
|
2013-12-06 21:26:44 +01:00
|
|
|
|
|
|
|
player = entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getMultiplier()
|
|
|
|
{
|
|
|
|
return Math.min(1, ((float)ticksSincePlay/20F))*0.3F;
|
|
|
|
}
|
|
|
|
|
2013-12-08 05:51:07 +01:00
|
|
|
@Override
|
|
|
|
public boolean update(World world)
|
|
|
|
{
|
|
|
|
if(player.isDead)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(player.worldObj != world)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(!world.loadedEntityList.contains(player))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
@Override
|
2013-12-22 07:04:35 +01:00
|
|
|
public Pos3D getLocation()
|
2013-12-06 21:26:44 +01:00
|
|
|
{
|
2013-12-22 07:04:35 +01:00
|
|
|
return new Pos3D(player);
|
2013-12-06 21:26:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void play()
|
|
|
|
{
|
|
|
|
super.play();
|
|
|
|
|
|
|
|
ticksSincePlay = 0;
|
|
|
|
}
|
|
|
|
}
|