diff options
author | Maxim <maxim235@gmx.de> | 2023-02-26 18:40:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-26 18:40:37 +0100 |
commit | f04ae276af1346fb8ca5a022b21f5f372960ae13 (patch) | |
tree | ebb03d039ebc5fc7aa5d369789a1ba6592334597 /src/main/java/gregtech/api/metatileentity/implementations | |
parent | 2651ea95e7af46b2d599f9e6eab25345595c9459 (diff) | |
download | GT5-Unofficial-f04ae276af1346fb8ca5a022b21f5f372960ae13.tar.gz GT5-Unofficial-f04ae276af1346fb8ca5a022b21f5f372960ae13.tar.bz2 GT5-Unofficial-f04ae276af1346fb8ca5a022b21f5f372960ae13.zip |
Multiblock Sounds (#1768)
* Added methods to allow multiblocks to play sounds
* Implemented first few sounds
* Added sound to PA
* Introduced static variables for sound indexes
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
-rw-r--r-- | src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index bcdb456ecc..57ec61e19d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -37,6 +37,7 @@ import com.gtnewhorizons.modularui.common.widget.*; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.SoundResource; import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -90,6 +91,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<>(); protected final List<GT_MetaTileEntity_Hatch> mExoticEnergyHatches = new ArrayList<>(); + protected static final byte INTERRUPT_SOUND_INDEX = 8; + protected static final byte PROCESS_START_SOUND_INDEX = 1; + public GT_MetaTileEntity_MultiBlockBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 2); GT_MetaTileEntity_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile @@ -383,6 +387,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity protected boolean checkRecipe() { startRecipeProcessing(); boolean result = checkRecipe(mInventory[1]); + if (result && getProcessStartSound() != null) { + sendLoopStart(PROCESS_START_SOUND_INDEX); + } endRecipeProcessing(); return result; } @@ -461,6 +468,43 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity return mPollution < 10000; } + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + super.doSound(aIndex, aX, aY, aZ); + switch (aIndex) { + case PROCESS_START_SOUND_INDEX: + if (getProcessStartSound() != null) + GT_Utility.doSoundAtClient(getProcessStartSound(), getTimeBetweenProcessSounds(), 1.0F, aX, aY, aZ); + break; + case INTERRUPT_SOUND_INDEX: + GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); + break; + } + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == PROCESS_START_SOUND_INDEX) { + if (getProcessStartSound() != null) + GT_Utility.doSoundAtClient(getProcessStartSound(), getTimeBetweenProcessSounds(), 1.0F, aX, aY, aZ); + } + } + + /** + * @return Time before the start process sound is played again + */ + protected int getTimeBetweenProcessSounds() { + return 100; + } + + /** + * @return Sound that will be played once, when the recipe check was valid + */ + protected SoundResource getProcessStartSound() { + return null; + } + /** * Called every tick the Machine runs */ @@ -539,6 +583,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity public void criticalStopMachine() { stopMachine(); + sendSound(INTERRUPT_SOUND_INDEX); getBaseMetaTileEntity().setShutdownStatus(true); } |