aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/api/threads/GT_Runnable_Sound.java
blob: aaa8b84028edbefc72f3b657b5e7353cf131436f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package gregtech.api.threads;

import gregtech.api.util.GT_PlayedSound;
import gregtech.api.util.GT_Utility;
import net.minecraft.world.World;

public class GT_Runnable_Sound implements Runnable {
	private final int mX, mY, mZ, mTimeUntilNextSound;
	private final World mWorld;
	private final String mSoundName;
	private final float mSoundStrength, mSoundModulation;
	
	public GT_Runnable_Sound(World aWorld, int aX, int aY, int aZ, int aTimeUntilNextSound, String aSoundName, float aSoundStrength, float aSoundModulation) {
		mWorld = aWorld; mX = aX; mY = aY; mZ = aZ; mTimeUntilNextSound = aTimeUntilNextSound; mSoundName = aSoundName; mSoundStrength = aSoundStrength; mSoundModulation = aSoundModulation;
	}
	
	@Override
	public void run() {
		try {
			GT_PlayedSound tSound;
			if (GT_Utility.sPlayedSoundMap.keySet().contains(tSound = new GT_PlayedSound(mSoundName, mX, mY, mZ))) return;
			mWorld.playSound(mX, mY, mZ, mSoundName, mSoundStrength, mSoundModulation, false);
			GT_Utility.sPlayedSoundMap.put(tSound, mTimeUntilNextSound);
		} catch(Throwable e) {/**/}
	}
}