Added additional sound events to allow manipulation of a sound source at its creation.
This commit is contained in:
parent
e762b58bbf
commit
ddd406bad3
5 changed files with 124 additions and 8 deletions
|
@ -0,0 +1,14 @@
|
|||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.src.SoundManager;
|
||||
|
||||
public class PlaySoundEffectSourceEvent extends SoundEvent
|
||||
{
|
||||
public final SoundManager manager;
|
||||
public final String name;
|
||||
public PlaySoundEffectSourceEvent(SoundManager manager, String name)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.src.SoundManager;
|
||||
|
||||
public class PlaySoundSourceEvent extends SoundEvent
|
||||
{
|
||||
public final SoundManager manager;
|
||||
public final String name;
|
||||
public final float x;
|
||||
public final float y;
|
||||
public final float z;
|
||||
public PlaySoundSourceEvent(SoundManager manager, String name, float x, float y, float z)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.src.SoundManager;
|
||||
|
||||
public class PlayStreamingSourceEvent extends SoundEvent
|
||||
{
|
||||
public final SoundManager manager;
|
||||
public final String name;
|
||||
public final float x;
|
||||
public final float y;
|
||||
public final float z;
|
||||
public PlayStreamingSourceEvent(SoundManager manager, String name, float x, float y, float z)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.src.SoundManager;
|
||||
|
||||
public class SoundSetListenerEvent extends SoundEvent
|
||||
{
|
||||
public final SoundManager manager;
|
||||
public final float elapsed;
|
||||
public final float posX;
|
||||
public final float posY;
|
||||
public final float posZ;
|
||||
public final float lookX;
|
||||
public final float lookY;
|
||||
public final float lookZ;
|
||||
public SoundSetListenerEvent(SoundManager manager, float elapsed, float posX, float posY, float posZ, float lookX, float lookY, float lookZ)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.elapsed = elapsed;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posZ = posZ;
|
||||
this.lookX = lookX;
|
||||
this.lookY = lookY;
|
||||
this.lookZ = lookZ;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
--- ../src_base/minecraft/net/minecraft/src/SoundManager.java
|
||||
+++ ../src_work/minecraft/net/minecraft/src/SoundManager.java
|
||||
@@ -2,6 +2,18 @@
|
||||
@@ -2,6 +2,22 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Random;
|
||||
|
@ -8,18 +8,22 @@
|
|||
+import net.minecraftforge.client.ForgeHooksClient;
|
||||
+import net.minecraftforge.client.ModCompatibilityClient;
|
||||
+import net.minecraftforge.client.event.sound.PlaySoundEffectEvent;
|
||||
+import net.minecraftforge.client.event.sound.PlaySoundEffectSourceEvent;
|
||||
+import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||
+import net.minecraftforge.client.event.sound.PlaySoundSourceEvent;
|
||||
+import net.minecraftforge.client.event.sound.PlayStreamingEvent;
|
||||
+import net.minecraftforge.client.event.sound.PlayStreamingSourceEvent;
|
||||
+import net.minecraftforge.client.event.sound.SoundEvent;
|
||||
+import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
|
||||
+import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
+import net.minecraftforge.client.event.sound.SoundSetListenerEvent;
|
||||
+import net.minecraftforge.client.event.sound.SoundSetupEvent;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import static net.minecraftforge.client.event.sound.SoundEvent.*;
|
||||
import paulscode.sound.SoundSystem;
|
||||
import paulscode.sound.SoundSystemConfig;
|
||||
import paulscode.sound.codecs.CodecJOrbis;
|
||||
@@ -37,9 +49,11 @@
|
||||
@@ -37,9 +53,11 @@
|
||||
private Random rand = new Random();
|
||||
private int ticksBeforeMusic;
|
||||
|
||||
|
@ -32,7 +36,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -54,6 +68,8 @@
|
||||
@@ -54,6 +72,8 @@
|
||||
{
|
||||
this.tryToSetLibraryAndCodecs();
|
||||
}
|
||||
|
@ -41,7 +45,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +89,8 @@
|
||||
@@ -73,6 +93,8 @@
|
||||
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
|
||||
SoundSystemConfig.setCodec("mus", CodecMus.class);
|
||||
SoundSystemConfig.setCodec("wav", CodecWav.class);
|
||||
|
@ -50,7 +54,7 @@
|
|||
sndSystem = new SoundSystem();
|
||||
this.options.soundVolume = var1;
|
||||
this.options.musicVolume = var2;
|
||||
@@ -161,10 +179,12 @@
|
||||
@@ -161,10 +183,12 @@
|
||||
}
|
||||
|
||||
SoundPoolEntry var1 = this.soundPoolMusic.getRandomSound();
|
||||
|
@ -64,7 +68,15 @@
|
|||
sndSystem.backgroundMusic("BgMusic", var1.soundUrl, var1.soundName, false);
|
||||
sndSystem.setVolume("BgMusic", this.options.musicVolume);
|
||||
sndSystem.play("BgMusic");
|
||||
@@ -214,6 +234,7 @@
|
||||
@@ -196,6 +220,7 @@
|
||||
float var17 = 0.0F;
|
||||
sndSystem.setListenerPosition((float)var4, (float)var6, (float)var8);
|
||||
sndSystem.setListenerOrientation(var12, var13, var14, var15, var16, var17);
|
||||
+ MinecraftForge.EVENT_BUS.post(new SoundSetListenerEvent(this, par2, (float)var4, (float)var6, (float)var8, var12, var13, var14));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,6 +239,7 @@
|
||||
if (par1Str != null)
|
||||
{
|
||||
SoundPoolEntry var8 = this.soundPoolStreaming.getRandomSoundFromSoundPool(par1Str);
|
||||
|
@ -72,7 +84,15 @@
|
|||
|
||||
if (var8 != null && par5 > 0.0F)
|
||||
{
|
||||
@@ -239,6 +260,7 @@
|
||||
@@ -225,6 +251,7 @@
|
||||
float var9 = 16.0F;
|
||||
sndSystem.newStreamingSource(true, var7, var8.soundUrl, var8.soundName, false, par2, par3, par4, 2, var9 * 4.0F);
|
||||
sndSystem.setVolume(var7, 0.5F * this.options.soundVolume);
|
||||
+ MinecraftForge.EVENT_BUS.post(new PlayStreamingSourceEvent(this, var7, par2, par3, par4));
|
||||
sndSystem.play(var7);
|
||||
}
|
||||
}
|
||||
@@ -239,6 +266,7 @@
|
||||
if (loaded && this.options.soundVolume != 0.0F)
|
||||
{
|
||||
SoundPoolEntry var7 = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
|
||||
|
@ -80,7 +100,15 @@
|
|||
|
||||
if (var7 != null && par5 > 0.0F)
|
||||
{
|
||||
@@ -274,6 +296,7 @@
|
||||
@@ -260,6 +288,7 @@
|
||||
}
|
||||
|
||||
sndSystem.setVolume(var8, par5 * this.options.soundVolume);
|
||||
+ MinecraftForge.EVENT_BUS.post(new PlaySoundSourceEvent(this, var8, par2, par3, par4));
|
||||
sndSystem.play(var8);
|
||||
}
|
||||
}
|
||||
@@ -274,6 +303,7 @@
|
||||
if (loaded && this.options.soundVolume != 0.0F)
|
||||
{
|
||||
SoundPoolEntry var4 = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
|
||||
|
@ -88,3 +116,11 @@
|
|||
|
||||
if (var4 != null)
|
||||
{
|
||||
@@ -289,6 +319,7 @@
|
||||
par2 *= 0.25F;
|
||||
sndSystem.setPitch(var5, par3);
|
||||
sndSystem.setVolume(var5, par2 * this.options.soundVolume);
|
||||
+ MinecraftForge.EVENT_BUS.post(new PlaySoundEffectSourceEvent(this, var5));
|
||||
sndSystem.play(var5);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue