mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +00:00
After much client code isolation, there should be no more issues on the server side with sounds
This commit is contained in:
1 parent
12b6b4610b
commit
339e048a4e
9 files changed
+103
-41
No files matched your search
@@ -2,23 +2,25 @@ package mekanism.common.tile;
|
||||
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.Pos3D;
|
||||
import mekanism.client.sound.IHasSound;
|
||||
import mekanism.client.sound.IResettableSound;
|
||||
import mekanism.client.sound.ISoundSource;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.client.sound.TileSound;
|
||||
import mekanism.common.base.IActiveState;
|
||||
|
||||
import mekanism.common.base.IHasSound;
|
||||
import mekanism.common.base.SoundWrapper;
|
||||
import net.minecraft.client.audio.ISound.AttenuationType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlock implements IHasSound, ISoundSource, IActiveState
|
||||
{
|
||||
/** The ResourceLocation of the machine's sound */
|
||||
public ResourceLocation soundURL;
|
||||
|
||||
/** The bundled URL of this machine's sound effect */
|
||||
public IResettableSound sound;
|
||||
/** The SoundWrapper containing this machine's sound object */
|
||||
@SideOnly(Side.CLIENT)
|
||||
public SoundWrapper sound;
|
||||
|
||||
/**
|
||||
* The base of all blocks that deal with electricity and make noise.
|
||||
@@ -34,7 +36,8 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResettableSound getSound()
|
||||
@SideOnly(Side.CLIENT)
|
||||
public SoundWrapper getSound()
|
||||
{
|
||||
return sound;
|
||||
}
|
||||
@@ -82,6 +85,7 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AttenuationType getAttenuation()
|
||||
{
|
||||
return AttenuationType.LINEAR;
|
||||
@@ -92,12 +96,18 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo
|
||||
{
|
||||
super.validate();
|
||||
|
||||
initSounds();
|
||||
try {
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
initSounds();
|
||||
}
|
||||
} catch(Throwable t) {}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void initSounds()
|
||||
{
|
||||
sound = new TileSound(this, this);
|
||||
sound = new SoundWrapper(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,10 +115,12 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(worldObj.isRemote && shouldPlaySound() && SoundHandler.canRestartSound(getSound()) && client.enableMachineSounds)
|
||||
{
|
||||
getSound().reset();
|
||||
SoundHandler.playSound(getSound());
|
||||
}
|
||||
try {
|
||||
if(worldObj.isRemote && shouldPlaySound() && getSound().canRestart() && client.enableMachineSounds)
|
||||
{
|
||||
getSound().reset();
|
||||
getSound().play();
|
||||
}
|
||||
} catch(Throwable t) {}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user