Skip to content

Commit

Permalink
Unify machine sound loop to use SoundResource (#3289)
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune authored Sep 28, 2024
1 parent 254a3bc commit 6b1f145
Show file tree
Hide file tree
Showing 48 changed files with 121 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -435,7 +434,7 @@ public boolean supportsVoidProtection() {

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MEGA_BLAST_FURNACE_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MEGA_BLAST_FURNACE_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -537,7 +536,7 @@ public boolean supportsVoidProtection() {

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_MEGA_VACUUM_FREEZER_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_MEGA_VACUUM_FREEZER_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -534,8 +533,8 @@ public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDat

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_PRECISE_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_PRECISE_LOOP;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -358,7 +357,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mMachine ? 0 : 64));
aBaseMetaTileEntity.setActive(mMaxProgresstime > 0);
} else {
soundMagic(getActivitySoundLoop());
doActivitySound(getActivitySoundLoop());
}
}

Expand Down Expand Up @@ -570,8 +569,8 @@ public boolean explodesOnComponentBreak(ItemStack aStack) {

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_FUSION_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_FUSION_LOOP;
}

@Override
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/gregtech/api/enums/SoundResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static gregtech.api.enums.Mods.GregTech;
import static gregtech.api.enums.Mods.IndustrialCraft2;
import static gregtech.api.enums.Mods.TecTech;

import java.util.EnumSet;
import java.util.Locale;
Expand Down Expand Up @@ -100,6 +101,10 @@ public enum SoundResource {
GT_MACHINES_QUANTUM_FORCE_TRANSFORMER_LOOP(264, GregTech.ID, "machines.MTEQuantumForceTransformer"),
GT_MACHINES_ADV_EBF_LOOP(265, GregTech.ID, "machines.MTEAdvEBF"),
GT_MACHINES_LARGE_TURBINES_LOOP(266, GregTech.ID, "machines.MTELargeTurbine"),
TECTECH_MACHINES_FX_LOW_FREQ(267, TecTech.ID, "fx_lo_freq"),
TECTECH_MACHINES_FX_HIGH_FREQ(268, TecTech.ID, "fx_hi_freq"),
TECTECH_MACHINES_NOISE(269, TecTech.ID, "fx_noise"),
TECTECH_MACHINES_FX_WHOOUM(270, TecTech.ID, "fx_whooum"),

GUI_BUTTON_DOWN(-1, GregTech.ID, "gui.buttonDown"),
GUI_BUTTON_UP(-1, GregTech.ID, "gui.buttonUp"),
Expand Down Expand Up @@ -346,7 +351,16 @@ public enum SoundResource {

static {
EnumSet.allOf(SoundResource.class)
.forEach(sound -> { if (sound.id >= 0) ID_SOUND_MAP.put(sound.id, sound); });
.forEach(sound -> {
if (sound.id < 0) {
return;
}

if (ID_SOUND_MAP.containsKey(sound.id)) {
throw new IllegalStateException(String.format("Sound ID %s is already occupied!", sound.id));
}
ID_SOUND_MAP.put(sound.id, sound);
});
EnumSet.allOf(SoundResource.class)
.forEach(sound -> RESOURCE_STR_SOUND_MAP.put(sound.resourceLocation.toString(), sound));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
Expand Down Expand Up @@ -677,10 +676,14 @@ public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
}

@SideOnly(Side.CLIENT)
protected void doActivitySound(ResourceLocation activitySound) {
protected void doActivitySound(SoundResource activitySound) {
if (getBaseMetaTileEntity().isActive() && activitySound != null) {
if (activitySoundLoop == null) {
activitySoundLoop = new GTSoundLoop(activitySound, getBaseMetaTileEntity(), false, true);
activitySoundLoop = new GTSoundLoop(
activitySound.resourceLocation,
getBaseMetaTileEntity(),
false,
true);
Minecraft.getMinecraft()
.getSoundHandler()
.playSound(activitySoundLoop);
Expand Down Expand Up @@ -710,7 +713,7 @@ protected SoundResource getProcessStartSound() {
* @return Sound that will be looped for as long as the machine is doing a recipe
*/
@SideOnly(Side.CLIENT)
protected ResourceLocation getActivitySoundLoop() {
protected SoundResource getActivitySoundLoop() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -402,7 +401,7 @@ public boolean supportsBatchMode() {

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_EBF_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_EBF_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
Expand Down Expand Up @@ -546,8 +545,8 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_FUSION_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_FUSION_LOOP;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -479,7 +478,7 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_LARGE_TURBINES_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_LARGE_TURBINES_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -301,8 +300,8 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_AUTOCLAVE_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_AUTOCLAVE_LOOP;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -287,8 +286,8 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_LATHE_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_LATHE_LOOP;
}

private int mCasingAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.chunk.Chunk;
Expand Down Expand Up @@ -492,7 +491,7 @@ public boolean supportsVoidProtection() {

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_OIL_DRILL_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_OIL_DRILL_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.util.ForgeDirection;
Expand Down Expand Up @@ -1113,8 +1112,8 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PLASMAFORGE_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PLASMAFORGE_LOOP;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.List;

import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;

import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -166,7 +165,7 @@ public boolean supportsBatchMode() {

@SideOnly(Side.CLIENT)
@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_VACUUM_FREEZER_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_MULTI_VACUUM_FREEZER_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

Expand Down Expand Up @@ -326,7 +325,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
}

@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATIONPLANT_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATIONPLANT_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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;

Expand Down Expand Up @@ -482,7 +481,7 @@ public void loadNBTData(NBTTagCompound aNBT) {
}

@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_COAGULATION_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_COAGULATION_LOOP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

Expand Down Expand Up @@ -269,8 +268,8 @@ public CheckRecipeResult checkProcessing() {
}

@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_OZONATION_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_OZONATION_LOOP;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
Expand Down Expand Up @@ -572,8 +571,8 @@ public void loadNBTData(NBTTagCompound aNBT) {
}

@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATION_PH_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATION_PH_LOOP;
}

private enum SpecialHatchElement implements IHatchElement<MTEPurificationUnitPhAdjustment> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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;

Expand Down Expand Up @@ -559,7 +558,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
}

@Override
protected ResourceLocation getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATION_PLASMA_LOOP.resourceLocation;
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATION_PLASMA_LOOP;
}
}
Loading

0 comments on commit 6b1f145

Please sign in to comment.