Start to re-implement sound system in vanilla sounds.
This will make us compatible with XU mufflers (when they're) fixed and reduce unneccesary reinvention of wheels.
This commit is contained in:
parent
96072e0f5e
commit
41be14fad4
4 changed files with 73 additions and 20 deletions
38
src/main/java/mekanism/client/sound/TestSound.java
Normal file
38
src/main/java/mekanism/client/sound/TestSound.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package mekanism.client.sound;
|
||||
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
import net.minecraft.client.audio.PositionedSound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TestSound extends PositionedSound implements ITickableSound
|
||||
{
|
||||
public boolean finished = true;
|
||||
|
||||
public TestSound(ResourceLocation location, TileEntity tile)
|
||||
{
|
||||
super(location);
|
||||
this.volume = 1.0f;
|
||||
this.field_147663_c = 1.0f;
|
||||
this.xPosF = tile.xCoord;
|
||||
this.yPosF = tile.yCoord;
|
||||
this.zPosF = tile.zCoord;
|
||||
this.repeat = true;
|
||||
this.field_147665_h = 0;
|
||||
this.field_147666_i = AttenuationType.LINEAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDonePlaying()
|
||||
{
|
||||
return finished;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ public class TileSound extends Sound
|
|||
|
||||
@Override
|
||||
public boolean update(World world)
|
||||
{
|
||||
{/*
|
||||
if(!super.update(world))
|
||||
{
|
||||
return false;
|
||||
|
@ -84,7 +84,7 @@ public class TileSound extends Sound
|
|||
{
|
||||
ticksSincePlay++;
|
||||
}
|
||||
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,20 @@ package mekanism.common.tile;
|
|||
import java.util.Map;
|
||||
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.client.sound.TestSound;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
|
||||
import net.minecraft.client.audio.ISound.AttenuationType;
|
||||
import net.minecraft.client.audio.PositionedSound;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
public class TileEntityCrusher extends TileEntityElectricMachine
|
||||
{
|
||||
public float crushMatrix = 0;
|
||||
public TestSound sfx;
|
||||
|
||||
public TileEntityCrusher()
|
||||
{
|
||||
|
@ -22,28 +30,20 @@ public class TileEntityCrusher extends TileEntityElectricMachine
|
|||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
if(crushMatrix < 6)
|
||||
if(isActive && sfx.isDonePlaying())
|
||||
{
|
||||
crushMatrix+=0.2F;
|
||||
Mekanism.logger.info("Playing Crusher noise");
|
||||
sfx.finished = false;
|
||||
FMLClientHandler.instance().getClient().getSoundHandler().playSound(sfx);
|
||||
}
|
||||
else {
|
||||
crushMatrix = 0;
|
||||
else if(!(isActive || sfx.isDonePlaying()))
|
||||
{
|
||||
Mekanism.logger.info("Stopping Crusher noise");
|
||||
sfx.finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getMatrix()
|
||||
{
|
||||
float matrix = 0;
|
||||
|
||||
if(crushMatrix <= 3)
|
||||
{
|
||||
return crushMatrix;
|
||||
}
|
||||
else {
|
||||
return 3 - (crushMatrix-3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getRecipes()
|
||||
|
@ -56,4 +56,18 @@ public class TileEntityCrusher extends TileEntityElectricMachine
|
|||
{
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
super.validate();
|
||||
sfx = new TestSound(new ResourceLocation("mekanism", "tile.machine.crusher"), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
sfx.finished = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
"etc.GasMask": {"category": "master","sounds": [{"name": "etc/GasMask","stream": false}]},
|
||||
"etc.Hydraulic": {"category": "master","sounds": [{"name": "etc/Hydraulic","stream": false}]},
|
||||
"etc.Pop": {"category": "master","sounds": [{"name": "etc/Pop","stream": false}]},
|
||||
"etc.Success": {"category": "master","sounds": [{"name": "etc/Success","stream": false}]}
|
||||
"etc.Success": {"category": "master","sounds": [{"name": "etc/Success","stream": false}]},
|
||||
"tile.machine.crusher": {"category": "block", "sounds": [{"name": "Crusher","stream": false}]}
|
||||
}
|
Loading…
Add table
Reference in a new issue