From 74464417fd78c389b9d84173a7f9aeb4443ae0b6 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Sat, 23 Jul 2022 13:21:54 +0200 Subject: add(api/enums): particle and sound effect enumerations (#1154) * add(api/enums): particle and sound effect enumerations - Adds new GregTech API enumerations: - `ParticleFX`: Enumerates known EntityFX particles. - `SoundResource`: Enumerates known sounds with, id and ResourceLocation. - Refactors code to use the new enumerations instead of string literals. - Uses `ParticleFX` and `onRandomDisplayTick` to improve or implement new particle effects for these machines: - BBF: Adds random flames in front of the firebox. - Steam machines: Changes pressure-exhaust particles to white vapour, rather than dark smoke. - Magic Energy Absorber: Adds random effect, of absorbed magical purple particles, by the EnderDragon Egg siphon. - Forge Hammer: Adds sparse random sparks, ejected from the main face. --- .../java/gregtech/api/threads/GT_Runnable_Sound.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/threads') diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java b/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java index dad93ff98c..441d46ad58 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_Sound.java @@ -2,32 +2,41 @@ package gregtech.api.threads; import gregtech.api.util.GT_PlayedSound; import gregtech.api.util.GT_Utility; +import net.minecraft.util.ResourceLocation; 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 ResourceLocation mSoundResourceLocation; 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) { + public GT_Runnable_Sound(World aWorld, int aX, int aY, int aZ, int aTimeUntilNextSound, ResourceLocation aSoundResourceLocation, float aSoundStrength, float aSoundModulation) { mWorld = aWorld; mX = aX; mY = aY; mZ = aZ; mTimeUntilNextSound = aTimeUntilNextSound; - mSoundName = aSoundName; + mSoundResourceLocation = aSoundResourceLocation; mSoundStrength = aSoundStrength; mSoundModulation = aSoundModulation; } + /** + * @deprecated Use {@link #GT_Runnable_Sound(World, int, int, int, int, ResourceLocation, float, float)} + */ + @Deprecated + public GT_Runnable_Sound(World aWorld, int aX, int aY, int aZ, int aTimeUntilNextSound, String aSoundName, float aSoundStrength, float aSoundModulation) { + this(aWorld, aX, aY, aZ, aTimeUntilNextSound, new ResourceLocation(aSoundName), aSoundStrength, aSoundModulation); + } + @Override public void run() { try { GT_PlayedSound tSound; - if (GT_Utility.sPlayedSoundMap.keySet().contains(tSound = new GT_PlayedSound(mSoundName, mX, mY, mZ))) + if (GT_Utility.sPlayedSoundMap.containsKey(tSound = new GT_PlayedSound(mSoundResourceLocation, mX, mY, mZ))) return; - mWorld.playSound(mX, mY, mZ, mSoundName, mSoundStrength, mSoundModulation, false); + mWorld.playSound(mX, mY, mZ, mSoundResourceLocation.toString(), mSoundStrength, mSoundModulation, false); GT_Utility.sPlayedSoundMap.put(tSound, mTimeUntilNextSound); } catch (Throwable e) {/**/} } -- cgit