From c24c11cb33fd70367bad9d759054ba6f4bde6554 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Wed, 20 Aug 2014 01:30:31 +0100 Subject: [PATCH] Make things like the ExtraUtils muffler actually have an effect on our machines. VERY HACKY. --- .../java/mekanism/client/sound/Sound.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/main/java/mekanism/client/sound/Sound.java b/src/main/java/mekanism/client/sound/Sound.java index 9cc7cb1d5..8be57b8ac 100644 --- a/src/main/java/mekanism/client/sound/Sound.java +++ b/src/main/java/mekanism/client/sound/Sound.java @@ -7,7 +7,11 @@ import mekanism.api.Pos3D; import mekanism.client.MekanismClient; import mekanism.common.Mekanism; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.ISound.AttenuationType; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraftforge.client.ForgeHooksClient; public abstract class Sound { @@ -78,6 +82,9 @@ public abstract class Sound return; } + ISound sound = ForgeHooksClient.playSound(SoundHandler.getSoundManager(), new DummySound()); + if (!(sound instanceof DummySound)) return; + ticksSincePlay = 0; if(SoundHandler.getSoundSystem() != null) @@ -184,4 +191,61 @@ public abstract class Sound } catch(Exception e) {} } } + + public class DummySound implements ISound + { + @Override + public ResourceLocation getPositionedSoundLocation() + { + return new ResourceLocation("mekanism", "sound.ogg"); + } + + @Override + public boolean canRepeat() + { + return false; + } + + @Override + public int getRepeatDelay() + { + return 0; + } + + @Override + public float getVolume() + { + return 1; + } + + @Override + public float getPitch() + { + return 0; + } + + @Override + public float getXPosF() + { + return (float)getLocation().xPos; + } + + @Override + public float getYPosF() + { + return (float)getLocation().yPos; + } + + @Override + public float getZPosF() + { + return (float)getLocation().zPos; + } + + @Override + public AttenuationType getAttenuationType() + { + return AttenuationType.LINEAR; + } + } }