2013-12-04 22:53:58 +01:00
|
|
|
package mekanism.client.sound;
|
|
|
|
|
2013-12-22 07:04:35 +01:00
|
|
|
import mekanism.api.Pos3D;
|
2013-12-24 19:25:31 +01:00
|
|
|
import mekanism.client.HolidayManager;
|
2013-12-04 22:53:58 +01:00
|
|
|
import mekanism.common.IActiveState;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sound -- an object that is created in SoundHandler. A 'Sound' object runs off of
|
|
|
|
* PaulsCode's SoundSystem. It has several methods; play(), for looping the clip,
|
|
|
|
* stop(), for stopping the loop, remove(), for removing the sound from PaulsCode,
|
|
|
|
* and updateVolume() for updating the volume based on where the player is.
|
|
|
|
* @author AidanBrady
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class TileSound extends Sound
|
|
|
|
{
|
|
|
|
/** The TileEntity this sound is associated with. */
|
|
|
|
public TileEntity tileEntity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A sound that runs off of the PaulsCode sound system.
|
|
|
|
* @param id - unique identifier
|
|
|
|
* @param sound - bundled path to the sound
|
|
|
|
* @param tileentity - the tile this sound is playing from.
|
|
|
|
*/
|
|
|
|
public TileSound(String id, String sound, TileEntity tileentity)
|
|
|
|
{
|
2013-12-22 07:04:35 +01:00
|
|
|
super(id, sound, tileentity, new Pos3D(tileentity));
|
2013-12-04 22:53:58 +01:00
|
|
|
|
|
|
|
tileEntity = tileentity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getMultiplier()
|
|
|
|
{
|
|
|
|
return ((IHasSound)tileEntity).getVolumeMultiplier();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-22 07:04:35 +01:00
|
|
|
public Pos3D getLocation()
|
2013-12-04 22:53:58 +01:00
|
|
|
{
|
2013-12-22 07:04:35 +01:00
|
|
|
return new Pos3D(tileEntity);
|
2013-12-04 22:53:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean update(World world)
|
|
|
|
{
|
|
|
|
if(!(tileEntity instanceof IHasSound))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(world.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-24 19:25:31 +01:00
|
|
|
else if(!HolidayManager.filterSound(((IHasSound)tileEntity).getSoundPath()).equals(soundPath))
|
2013-12-04 22:53:58 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(tileEntity instanceof IActiveState)
|
|
|
|
{
|
|
|
|
if(((IActiveState)tileEntity).getActive() != isPlaying)
|
|
|
|
{
|
|
|
|
if(((IActiveState)tileEntity).getActive())
|
|
|
|
{
|
|
|
|
play();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stopLoop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|