aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/tectech/thing/metaTileEntity/multi/base
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2024-09-28 20:16:09 +0900
committerGitHub <noreply@github.com>2024-09-28 11:16:09 +0000
commit6b1f145f5028f1bc92cf478e5963224e7d94b5cd (patch)
tree2227de40c6c806bd59c430e973a07dda8d9f1c1f /src/main/java/tectech/thing/metaTileEntity/multi/base
parent254a3bc734648c97e136f67d714dcf5a4f8a3df9 (diff)
downloadGT5-Unofficial-6b1f145f5028f1bc92cf478e5963224e7d94b5cd.tar.gz
GT5-Unofficial-6b1f145f5028f1bc92cf478e5963224e7d94b5cd.tar.bz2
GT5-Unofficial-6b1f145f5028f1bc92cf478e5963224e7d94b5cd.zip
Unify machine sound loop to use SoundResource (#3289)
Diffstat (limited to 'src/main/java/tectech/thing/metaTileEntity/multi/base')
-rw-r--r--src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java59
-rw-r--r--src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java39
2 files changed, 5 insertions, 93 deletions
diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java
deleted file mode 100644
index c337f5093e..0000000000
--- a/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package tectech.thing.metaTileEntity.multi.base;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.audio.MovingSound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.world.World;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-
-@SideOnly(Side.CLIENT)
-public class SoundLoop extends MovingSound {
-
- private final boolean whileActive;
- private final boolean whileInactive;
- private final int worldID;
- private boolean fadeMe = false;
-
- public SoundLoop(ResourceLocation p_i45104_1_, IGregTechTileEntity base, boolean stopWhenActive,
- boolean stopWhenInactive) {
- super(p_i45104_1_);
- this.whileActive = stopWhenActive;
- this.whileInactive = stopWhenInactive;
- xPosF = base.getXCoord();
- yPosF = base.getYCoord();
- zPosF = base.getZCoord();
- worldID = base.getWorld().provider.dimensionId;
- repeat = true;
- volume = 0.0625f;
- }
-
- @Override
- public void update() {
- if (donePlaying) {
- return;
- }
- if (fadeMe) {
- volume -= 0.0625f;
- if (volume <= 0) {
- volume = 0;
- donePlaying = true;
- }
- } else if (volume < 1) {
- volume += 0.0625f;
- }
- World world = Minecraft.getMinecraft().thePlayer.worldObj;
- donePlaying = world.provider.dimensionId != worldID
- || !world.checkChunksExist((int) xPosF, (int) yPosF, (int) zPosF, (int) xPosF, (int) yPosF, (int) zPosF);
- if (donePlaying) return;
- TileEntity tile = world.getTileEntity((int) xPosF, (int) yPosF, (int) zPosF);
- if (!(tile instanceof IGregTechTileEntity)) {
- donePlaying = true;
- return;
- }
- fadeMe |= ((IGregTechTileEntity) tile).isActive() ? whileActive : whileInactive;
- }
-}
diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java
index fdc3f9f826..8ee6eb3863 100644
--- a/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java
+++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java
@@ -21,12 +21,10 @@ import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
@@ -60,6 +58,7 @@ import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.enums.SoundResource;
import gregtech.api.enums.Textures;
import gregtech.api.gui.modularui.GTUITextures;
import gregtech.api.interfaces.IHatchElement;
@@ -88,7 +87,6 @@ import gregtech.api.util.shutdown.ShutDownReason;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
import gregtech.api.util.shutdown.SimpleShutDownReason;
import gregtech.common.tileentities.machines.IDualInputHatch;
-import tectech.Reference;
import tectech.TecTech;
import tectech.loader.ConfigHandler;
import tectech.thing.gui.TecTechUITextures;
@@ -117,11 +115,6 @@ public abstract class TTMultiblockBase extends MTEExtendedPowerMultiBlockBase<TT
/** Base ID for the LED window popup. LED 1 I0 will have ID 100, LED 1 I1 101... */
protected static int LED_WINDOW_BASE_ID = 100;
- // Sound resource - same as with screen but override getActivitySound
- public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_lo_freq");
-
- @SideOnly(Side.CLIENT)
- private SoundLoop activitySoundLoop;
// endregion
// region HATCHES ARRAYS - they hold info about found hatches, add hatches to them... (auto structure magic does it
@@ -505,31 +498,9 @@ public abstract class TTMultiblockBase extends MTEExtendedPowerMultiBlockBase<TT
return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4] };
}
- /**
- * should return your activity sound
- */
- @SideOnly(Side.CLIENT)
- protected ResourceLocation getActivitySound() {
- return activitySound;
- }
-
- /**
- * plays the sounds auto magically
- */
- @SideOnly(Side.CLIENT)
- protected void soundMagic(ResourceLocation activitySound) {
- if (getBaseMetaTileEntity().isActive()) {
- if (activitySoundLoop == null) {
- activitySoundLoop = new SoundLoop(activitySound, getBaseMetaTileEntity(), false, true);
- Minecraft.getMinecraft()
- .getSoundHandler()
- .playSound(activitySoundLoop);
- }
- } else {
- if (activitySoundLoop != null) {
- activitySoundLoop = null;
- }
- }
+ @Override
+ protected SoundResource getActivitySoundLoop() {
+ return SoundResource.TECTECH_MACHINES_FX_LOW_FREQ;
}
// endregion
@@ -1200,7 +1171,7 @@ public abstract class TTMultiblockBase extends MTEExtendedPowerMultiBlockBase<TT
boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0;
setMufflers(active);
} else {
- soundMagic(getActivitySound());
+ doActivitySound(getActivitySoundLoop());
}
}