aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/threads/RunnableSound.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/threads/RunnableSound.java')
-rw-r--r--src/main/java/gregtech/api/threads/RunnableSound.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/threads/RunnableSound.java b/src/main/java/gregtech/api/threads/RunnableSound.java
new file mode 100644
index 0000000000..30704f2a97
--- /dev/null
+++ b/src/main/java/gregtech/api/threads/RunnableSound.java
@@ -0,0 +1,41 @@
+package gregtech.api.threads;
+
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+
+import gregtech.api.util.GTPlayedSound;
+import gregtech.api.util.GTUtility;
+
+public class RunnableSound implements Runnable {
+
+ private final double mX, mY, mZ;
+ private final int mTimeUntilNextSound;
+ private final World mWorld;
+ private final ResourceLocation mSoundResourceLocation;
+ private final float mSoundStrength, mSoundModulation;
+
+ public RunnableSound(World aWorld, double aX, double aY, double aZ, int aTimeUntilNextSound,
+ ResourceLocation aSoundResourceLocation, float aSoundStrength, float aSoundModulation) {
+ mWorld = aWorld;
+ mX = aX;
+ mY = aY;
+ mZ = aZ;
+ mTimeUntilNextSound = aTimeUntilNextSound;
+ mSoundResourceLocation = aSoundResourceLocation;
+ mSoundStrength = aSoundStrength;
+ mSoundModulation = aSoundModulation;
+ }
+
+ @Override
+ public void run() {
+ try {
+ GTPlayedSound tSound;
+ if (GTUtility.sPlayedSoundMap.containsKey(tSound = new GTPlayedSound(mSoundResourceLocation, mX, mY, mZ)))
+ return;
+ mWorld.playSound(mX, mY, mZ, mSoundResourceLocation.toString(), mSoundStrength, mSoundModulation, false);
+ GTUtility.sPlayedSoundMap.put(tSound, mTimeUntilNextSound);
+ } catch (Throwable e) {
+ /**/
+ }
+ }
+}