mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
More work - SoundHandler now uses a channel-based system for sounds.
This commit is contained in:
1 parent
be7ea115b6
commit
4309a7d7b1
3 files changed
+38
-16
No files matched your search
@@ -391,7 +391,7 @@ public class ClientTickHandler
|
||||
|
||||
if(player != null)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getMap(player) == null)
|
||||
if(MekanismClient.audioHandler.getSound(player, SoundHandler.CHANNEL_JETPACK) == null)
|
||||
{
|
||||
new JetpackSound(MekanismClient.audioHandler.getIdentifier(player), player);
|
||||
}
|
||||
@@ -404,7 +404,7 @@ public class ClientTickHandler
|
||||
|
||||
if(player != null)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getMap(player) == null)
|
||||
if(MekanismClient.audioHandler.getSound(player, SoundHandler.CHANNEL_GASMASK) == null)
|
||||
{
|
||||
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(player), player);
|
||||
}
|
||||
@@ -415,7 +415,7 @@ public class ClientTickHandler
|
||||
{
|
||||
if(hasFlamethrower(player))
|
||||
{
|
||||
if(MekanismClient.audioHandler.getMap(player) == null)
|
||||
if(MekanismClient.audioHandler.getSound(player, SoundHandler.CHANNEL_FLAMETHROWER) == null)
|
||||
{
|
||||
new FlamethrowerSound(MekanismClient.audioHandler.getIdentifier(player), player);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ public class SoundHandler
|
||||
public Map<Object, SoundMap> soundMaps = Collections.synchronizedMap(new HashMap<Object, SoundMap>());
|
||||
|
||||
public static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static final String CHANNEL_TILE_DEFAULT = "tile";
|
||||
public static final String CHANNEL_JETPACK = "jetpack";
|
||||
public static final String CHANNEL_GASMASK = "gasMask";
|
||||
public static final String CHANNEL_FLAMETHROWER = "flamethrower";
|
||||
|
||||
/**
|
||||
* SoundHandler -- a class that handles all Sounds used by Mekanism.
|
||||
@@ -254,14 +259,14 @@ public class SoundHandler
|
||||
}
|
||||
}
|
||||
|
||||
public Sound getSound(Object obj, String path)
|
||||
public Sound getSound(Object obj, String channel)
|
||||
{
|
||||
if(soundMaps.get(obj) == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return soundMaps.get(obj).getSound(path);
|
||||
return soundMaps.get(obj).getSound(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,11 +300,23 @@ public class SoundHandler
|
||||
{
|
||||
synchronized(soundMaps)
|
||||
{
|
||||
String toReturn = "Mekanism_" + soundMaps.size() + "_" + new Random().nextInt(10000);
|
||||
String toReturn = "Mekanism_" + getActiveSize() + "_" + new Random().nextInt(10000);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
public int getActiveSize()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for(SoundMap map : soundMaps.values())
|
||||
{
|
||||
count += map.size();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a sound in a specific location.
|
||||
|
||||
@@ -17,11 +17,11 @@ public class SoundMap implements Iterable<Sound>
|
||||
objRef = obj;
|
||||
}
|
||||
|
||||
public SoundMap(Object obj, String path, Sound sound)
|
||||
public SoundMap(Object obj, String channel, Sound sound)
|
||||
{
|
||||
this(obj);
|
||||
|
||||
soundMap.put(path, sound);
|
||||
soundMap.put(channel, sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,24 +30,24 @@ public class SoundMap implements Iterable<Sound>
|
||||
return soundMap.values().iterator();
|
||||
}
|
||||
|
||||
public Sound getSound(String path)
|
||||
public Sound getSound(String channel)
|
||||
{
|
||||
return soundMap.get(path);
|
||||
return soundMap.get(channel);
|
||||
}
|
||||
|
||||
public boolean hasSound(String path)
|
||||
public boolean hasSound(String channel)
|
||||
{
|
||||
return soundMap.containsKey(path);
|
||||
return soundMap.containsKey(channel);
|
||||
}
|
||||
|
||||
public void remove(String path)
|
||||
public void remove(String channel)
|
||||
{
|
||||
soundMap.remove(path);
|
||||
soundMap.remove(channel);
|
||||
}
|
||||
|
||||
public void add(String path, Sound sound)
|
||||
public void add(String channel, Sound sound)
|
||||
{
|
||||
soundMap.put(path, sound);
|
||||
soundMap.put(channel, sound);
|
||||
}
|
||||
|
||||
public void stopLoops()
|
||||
@@ -70,4 +70,9 @@ public class SoundMap implements Iterable<Sound>
|
||||
|
||||
MekanismClient.audioHandler.soundMaps.remove(objRef);
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return soundMap.size();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user