Files
MinecraftForge/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch
T
2024-12-05 10:22:55 -08:00

54 lines
3.1 KiB
Diff

--- a/net/minecraft/client/sounds/SoundEngine.java
+++ b/net/minecraft/client/sounds/SoundEngine.java
@@ -79,6 +_,7 @@
this.soundManager = p_120236_;
this.options = p_120237_;
this.soundBuffers = new SoundBufferLibrary(p_249332_);
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this));
}
public void reload() {
@@ -96,6 +_,7 @@
this.destroy();
this.loadLibrary();
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.sound.SoundEngineLoadEvent(this));
}
private synchronized void loadLibrary() {
@@ -334,7 +_,8 @@
public void play(SoundInstance p_120313_) {
if (this.loaded) {
- if (p_120313_.canPlaySound()) {
+ p_120313_ = net.minecraftforge.client.ForgeHooksClient.playSound(this, p_120313_);
+ if (p_120313_ != null && p_120313_.canPlaySound()) {
WeighedSoundEvents weighedsoundevents = p_120313_.resolve(this.soundManager);
ResourceLocation resourcelocation = p_120313_.getLocation();
if (weighedsoundevents == null) {
@@ -398,19 +_,22 @@
p_194488_.setSelfPosition(vec3);
p_194488_.setRelative(flag);
});
+ SoundInstance soundinstance = p_120313_;
if (!flag2) {
this.soundBuffers
.getCompleteBuffer(sound.getPath())
.thenAccept(p_377326_ -> channelaccess$channelhandle.execute(p_194495_ -> {
p_194495_.attachStaticBuffer(p_377326_);
p_194495_.play();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onPlaySoundSource(this, soundinstance, p_194495_);
}));
} else {
- this.soundBuffers
- .getStream(sound.getPath(), flag1)
+ soundinstance
+ .getStream(this.soundBuffers, sound, flag1)
.thenAccept(p_376862_ -> channelaccess$channelhandle.execute(p_194498_ -> {
p_194498_.attachBufferStream(p_376862_);
p_194498_.play();
+ net.minecraftforge.client.event.ForgeEventFactoryClient.onPlayStreamingSource(this, soundinstance, p_194498_);
}));
}