mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Finally do SoundSystem workup for 1.7, Closes #982
This commit is contained in:
1 parent
5fbc70173c
commit
621fb050ce
16 files changed
+150
-22
No files matched your search
@@ -5,6 +5,9 @@ import java.util.Random;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundEventAccessorComposite;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
@@ -48,6 +51,7 @@ import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundEvent17;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.common.ForgeVersion.Status;
|
||||
@@ -441,4 +445,12 @@ public class ForgeHooksClient
|
||||
gui.drawString(font, line, width - font.getStringWidth(line) - 2, height - (2 * (font.FONT_HEIGHT + 1)), -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static ISound playSound(SoundManager manager, ISound sound)
|
||||
{
|
||||
SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation());
|
||||
PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
|
||||
MinecraftForge.EVENT_BUS.post(e);
|
||||
return e.result;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.client.audio.SoundPoolEntry;
|
||||
* If you return null from this function it will prevent the sound from being played,
|
||||
* you can return a different entry if you want to change the sound being played.
|
||||
*/
|
||||
@Deprecated // Remove in 1.8
|
||||
public class PlayBackgroundMusicEvent extends SoundResultEvent
|
||||
{
|
||||
public PlayBackgroundMusicEvent(SoundManager manager, SoundPoolEntry entry)
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.minecraftforge.client.event.sound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundPoolEntry;
|
||||
|
||||
@Deprecated //Remove in 1.8
|
||||
public class PlaySoundEffectEvent extends SoundResultEvent
|
||||
{
|
||||
public PlaySoundEffectEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch)
|
||||
|
||||
@@ -2,12 +2,14 @@ package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
|
||||
@Deprecated //Remove in 1.8
|
||||
public class PlaySoundEffectSourceEvent extends SoundEvent
|
||||
{
|
||||
public final SoundManager manager;
|
||||
public final String name;
|
||||
public PlaySoundEffectSourceEvent(SoundManager manager, String name)
|
||||
{
|
||||
super(manager);
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundPoolEntry;
|
||||
|
||||
/***
|
||||
* Raised when the SoundManager tries to play a normal sound,
|
||||
* dogs barking, footsteps, etc. THe majority of all sounds during normal game play.
|
||||
* Raised when the SoundManager tries to play a normal sound.
|
||||
*
|
||||
* If you return null from this function it will prevent the sound from being played,
|
||||
* you can return a different entry if you want to change the sound being played.
|
||||
*/
|
||||
@Deprecated // Switch with PlaySoundEvent17 in 1.8
|
||||
public class PlaySoundEvent extends SoundResultEvent
|
||||
{
|
||||
public final float x;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundCategory;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundPoolEntry;
|
||||
|
||||
/***
|
||||
* Raised when the SoundManager tries to play a normal sound.
|
||||
*
|
||||
* If you return null from this function it will prevent the sound from being played,
|
||||
* you can return a different entry if you want to change the sound being played.
|
||||
*/
|
||||
//TODO: Replace PlaySoundEvent in 1.8
|
||||
public class PlaySoundEvent17 extends SoundEvent
|
||||
{
|
||||
public final String name;
|
||||
public final ISound sound;
|
||||
public ISound result;
|
||||
|
||||
public PlaySoundEvent17(SoundManager manager, ISound sound, SoundCategory category)
|
||||
{
|
||||
super(manager);
|
||||
this.sound = sound;
|
||||
this.name = sound.getPositionedSoundLocation().getResourcePath();
|
||||
this.result = sound;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,38 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
|
||||
public class PlaySoundSourceEvent extends SoundEvent
|
||||
public class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
@Deprecated
|
||||
public final SoundManager manager;
|
||||
@Deprecated
|
||||
public final String name;
|
||||
@Deprecated
|
||||
public final float x;
|
||||
@Deprecated
|
||||
public final float y;
|
||||
@Deprecated
|
||||
public final float z;
|
||||
|
||||
@Deprecated
|
||||
public PlaySoundSourceEvent(SoundManager manager, String name, float x, float y, float z)
|
||||
{
|
||||
super(manager, null, null);
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public PlaySoundSourceEvent(SoundManager manager, ISound sound, String uuid)
|
||||
{
|
||||
super(manager, sound, uuid);
|
||||
this.name = sound.getPositionedSoundLocation().getResourcePath();
|
||||
this.manager = manager;
|
||||
this.x = this.y = this.z = 0;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.client.audio.SoundPoolEntry;
|
||||
* you can return a different entry if you want to change the sound being played.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayStreamingEvent extends SoundResultEvent
|
||||
{
|
||||
public final float x;
|
||||
|
||||
@@ -1,20 +1,38 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
|
||||
public class PlayStreamingSourceEvent extends SoundEvent
|
||||
public class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
@Deprecated
|
||||
public final SoundManager manager;
|
||||
@Deprecated
|
||||
public final String name;
|
||||
@Deprecated
|
||||
public final float x;
|
||||
@Deprecated
|
||||
public final float y;
|
||||
@Deprecated
|
||||
public final float z;
|
||||
|
||||
@Deprecated
|
||||
public PlayStreamingSourceEvent(SoundManager manager, String name, float x, float y, float z)
|
||||
{
|
||||
super(manager, null, null);
|
||||
this.manager = manager;
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public PlayStreamingSourceEvent(SoundManager manager, ISound sound, String uuid)
|
||||
{
|
||||
super(manager, sound, uuid);
|
||||
this.x = this.y = this.z = 0;
|
||||
this.manager = null;
|
||||
this.name = sound.getPositionedSoundLocation().getResourcePath();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,38 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundPoolEntry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class SoundEvent extends Event
|
||||
{
|
||||
public SoundEvent(){}
|
||||
public final SoundManager manager;
|
||||
public SoundEvent(SoundManager manager)
|
||||
{
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static SoundPoolEntry getResult(SoundResultEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.result;
|
||||
}
|
||||
|
||||
public static class SoundSourceEvent extends SoundEvent
|
||||
{
|
||||
public final ISound sound;
|
||||
public final String uuid;
|
||||
public final String name;
|
||||
|
||||
public SoundSourceEvent(SoundManager manager, ISound sound, String uuid)
|
||||
{
|
||||
super(manager);
|
||||
this.name = sound.getPositionedSoundLocation().getResourcePath();
|
||||
this.sound = sound;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ import net.minecraft.client.audio.SoundManager;
|
||||
*/
|
||||
public class SoundLoadEvent extends SoundEvent
|
||||
{
|
||||
@Deprecated
|
||||
public final SoundManager manager;
|
||||
public SoundLoadEvent(SoundManager manager)
|
||||
{
|
||||
super(manager);
|
||||
this.manager = manager;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.minecraftforge.client.event.sound;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.audio.SoundPoolEntry;
|
||||
|
||||
@Deprecated //Remove in 1.8
|
||||
public abstract class SoundResultEvent extends SoundEvent
|
||||
{
|
||||
public final SoundManager manager;
|
||||
@@ -14,6 +15,7 @@ public abstract class SoundResultEvent extends SoundEvent
|
||||
|
||||
public SoundResultEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch)
|
||||
{
|
||||
super(manager);
|
||||
this.manager = manager;
|
||||
this.source = source;
|
||||
this.name = name;
|
||||
|
||||
@@ -8,9 +8,11 @@ import net.minecraft.client.audio.SoundManager;
|
||||
*/
|
||||
public class SoundSetupEvent extends SoundEvent
|
||||
{
|
||||
@Deprecated
|
||||
public final SoundManager manager;
|
||||
public SoundSetupEvent(SoundManager manager)
|
||||
{
|
||||
super(manager);
|
||||
this.manager = manager;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user