diff --git a/src/main/java/mekanism/client/sound/IHasSound.java b/src/main/java/mekanism/client/sound/IHasSound.java index 58956b48a..b1b6deada 100644 --- a/src/main/java/mekanism/client/sound/IHasSound.java +++ b/src/main/java/mekanism/client/sound/IHasSound.java @@ -1,5 +1,7 @@ package mekanism.client.sound; +import net.minecraft.client.audio.ISound; + /** * Implement this if your TileEntity has a specific sound. * @author AidanBrady @@ -7,15 +9,7 @@ package mekanism.client.sound; */ public interface IHasSound { - /** - * Gets the sound path of this block's sound. - * @return sound path - */ - public String getSoundPath(); + public ISound getSound(); - /** - * Gets the multiplier to play this sound by. - * @return sound multiplier - */ - public float getVolumeMultiplier(); + public boolean shouldPlaySound(); } diff --git a/src/main/java/mekanism/client/sound/ISoundSource.java b/src/main/java/mekanism/client/sound/ISoundSource.java new file mode 100644 index 000000000..84b751f5d --- /dev/null +++ b/src/main/java/mekanism/client/sound/ISoundSource.java @@ -0,0 +1,23 @@ +package mekanism.client.sound; + +import mekanism.api.Pos3D; + +import net.minecraft.client.audio.ISound.AttenuationType; +import net.minecraft.util.ResourceLocation; + +public interface ISoundSource +{ + public ResourceLocation getSoundLocation(); + + public float getVolume(); + + public float getPitch(); + + public Pos3D getSoundPosition(); + + public boolean shouldRepeat(); + + public int getRepeatDelay(); + + public AttenuationType getAttenuation(); +} diff --git a/src/main/java/mekanism/client/sound/SoundBase.java b/src/main/java/mekanism/client/sound/SoundBase.java new file mode 100644 index 000000000..62a8cfdc4 --- /dev/null +++ b/src/main/java/mekanism/client/sound/SoundBase.java @@ -0,0 +1,175 @@ +package mekanism.client.sound; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.audio.ISound; +import net.minecraft.util.ResourceLocation; + +/** + * Generic ISound class with lots of constructor functionality. Required because - of course - Mojang has no generic that lets you specify *any* arguments for + * this. Taken from CoFHLib + * + * @author skyboy + * + */ +@SideOnly(Side.CLIENT) +public class SoundBase implements ISound { + + protected AttenuationType attenuation; + protected final ResourceLocation sound; + protected float volume; + protected float pitch; + protected float x; + protected float y; + protected float z; + protected boolean repeat; + protected int repeatDelay; + + public SoundBase(String sound) { + + this(sound, 0); + } + + public SoundBase(String sound, float volume) { + + this(sound, volume, 0); + } + + public SoundBase(String sound, float volume, float pitch) { + + this(sound, volume, pitch, false, 0); + } + + public SoundBase(String sound, float volume, float pitch, boolean repeat, int repeatDelay) { + + this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); + } + + public SoundBase(String sound, float volume, float pitch, double x, double y, double z) { + + this(sound, volume, pitch, false, 0, x, y, z); + } + + public SoundBase(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) { + + this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); + } + + public SoundBase(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, AttenuationType attenuation) { + + this(new ResourceLocation(sound), volume, pitch, repeat, repeatDelay, x, y, z, attenuation); + } + + public SoundBase(ResourceLocation sound) { + + this(sound, 0); + } + + public SoundBase(ResourceLocation sound, float volume) { + + this(sound, volume, 0); + } + + public SoundBase(ResourceLocation sound, float volume, float pitch) { + + this(sound, volume, pitch, false, 0); + } + + public SoundBase(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay) { + + this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); + } + + public SoundBase(ResourceLocation sound, float volume, float pitch, double x, double y, double z) { + + this(sound, volume, pitch, false, 0, x, y, z); + } + + public SoundBase(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) { + + this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); + } + + public SoundBase(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, + AttenuationType attenuation) { + + this.attenuation = attenuation; + this.sound = sound; + this.volume = volume; + this.pitch = pitch; + this.x = (float) x; + this.y = (float) y; + this.z = (float) z; + this.repeat = repeat; + this.repeatDelay = repeatDelay; + } + + public SoundBase(SoundBase other) { + + this.attenuation = other.attenuation; + this.sound = other.sound; + this.volume = other.volume; + this.pitch = other.pitch; + this.x = other.x; + this.y = other.y; + this.z = other.z; + this.repeat = other.repeat; + this.repeatDelay = other.repeatDelay; + } + + @Override + public AttenuationType getAttenuationType() { + + return attenuation; + } + + @Override + public ResourceLocation getPositionedSoundLocation() { + + return sound; + } + + @Override + public float getVolume() { + + return volume; + } + + @Override + public float getPitch() { + + return pitch; + } + + @Override + public float getXPosF() { + + return x; + } + + @Override + public float getYPosF() { + + return y; + } + + @Override + public float getZPosF() { + + return z; + } + + @Override + public boolean canRepeat() { + + return repeat; + } + + @Override + public int getRepeatDelay() { + + return repeatDelay; + } + +} diff --git a/src/main/java/mekanism/client/sound/SoundHandler.java b/src/main/java/mekanism/client/sound/SoundHandler.java index ed6096c23..4aa21cf40 100644 --- a/src/main/java/mekanism/client/sound/SoundHandler.java +++ b/src/main/java/mekanism/client/sound/SoundHandler.java @@ -285,14 +285,6 @@ public class SoundHandler { return; } - - synchronized(soundMaps) - { - if(getMap(tile) == null) - { - new TileSound(getIdentifier(tile), HolidayManager.filterSound(((IHasSound)tile).getSoundPath()), CHANNEL_TILE_DEFAULT, tile); - } - } } /** diff --git a/src/main/java/mekanism/client/sound/SoundTile.java b/src/main/java/mekanism/client/sound/SoundTile.java new file mode 100644 index 000000000..c325f606f --- /dev/null +++ b/src/main/java/mekanism/client/sound/SoundTile.java @@ -0,0 +1,102 @@ +package mekanism.client.sound; + +import net.minecraft.client.audio.ITickableSound; +import net.minecraft.util.ResourceLocation; + +public class SoundTile extends SoundBase implements ITickableSound { + + IHasSound source; + boolean beginFadeOut; + boolean donePlaying = true; + int ticks = 0; + int fadeIn = 50; + int fadeOut = 50; + float baseVolume = 1.0F; + + public SoundTile(IHasSound source, ISoundSource values) + { + this(source, values.getSoundLocation(), values.getVolume(), values.getPitch(), values.shouldRepeat(), values.getRepeatDelay(), values.getSoundPosition().xPos, values.getSoundPosition().yPos, values.getSoundPosition().zPos); + } + + public SoundTile(IHasSound source, String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) { + + this(source, sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); + } + + public SoundTile(IHasSound source, String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, + AttenuationType attenuation) { + + this(source, new ResourceLocation(sound), volume, pitch, repeat, repeatDelay, x, y, z, attenuation); + } + + public SoundTile(IHasSound source, ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) { + + this(source, sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); + } + + public SoundTile(IHasSound source, ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, + AttenuationType attenuation) { + + super(sound, volume, pitch, repeat, repeatDelay, x, y, z, attenuation); + this.source = source; + this.baseVolume = volume; + } + + public SoundTile setFadeIn(int fadeIn) { + + this.fadeIn = Math.min(0, fadeIn); + return this; + } + + public SoundTile setFadeOut(int fadeOut) { + + this.fadeOut = Math.min(0, fadeOut); + return this; + } + + public float getFadeInMultiplier() { + + return ticks >= fadeIn ? 1 : (float) (ticks / (float) fadeIn); + } + + public float getFadeOutMultiplier() { + + return ticks >= fadeOut ? 0 : (float) ((fadeOut - ticks) / (float) fadeOut); + } + + /* ITickableSound */ + @Override + public void update() { + + if (!beginFadeOut) { + if (ticks < fadeIn) { + ticks++; + } + if (!source.shouldPlaySound()) { + beginFadeOut = true; + ticks = 0; + } + } else { + ticks++; + } + float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier(); + volume = baseVolume * multiplier; + + if (multiplier <= 0) { + donePlaying = true; + } + } + + @Override + public boolean isDonePlaying() + { + return donePlaying; + } + + public void reset() + { + donePlaying = false; + beginFadeOut = false; + ticks = 0; + } +} diff --git a/src/main/java/mekanism/client/sound/TestSound.java b/src/main/java/mekanism/client/sound/TestSound.java index 19de5f25e..1cf4e4343 100644 --- a/src/main/java/mekanism/client/sound/TestSound.java +++ b/src/main/java/mekanism/client/sound/TestSound.java @@ -2,8 +2,6 @@ package mekanism.client.sound; import net.minecraft.client.audio.ITickableSound; import net.minecraft.client.audio.PositionedSound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,17 +10,17 @@ public class TestSound extends PositionedSound implements ITickableSound { public boolean finished = true; - public TestSound(ResourceLocation location, TileEntity tile) + public TestSound(ISoundSource source) { - super(location); - this.volume = 1.0f; - this.field_147663_c = 1.0f; - this.xPosF = tile.xCoord; - this.yPosF = tile.yCoord; - this.zPosF = tile.zCoord; - this.repeat = true; - this.field_147665_h = 0; - this.field_147666_i = AttenuationType.LINEAR; + super(source.getSoundLocation()); + this.volume = getVolume(); + this.field_147663_c = getPitch(); + this.xPosF = (float)source.getSoundPosition().xPos; + this.yPosF = (float)source.getSoundPosition().yPos; + this.zPosF = (float)source.getSoundPosition().zPos; + this.repeat = source.shouldRepeat(); + this.field_147665_h = source.getRepeatDelay(); + this.field_147666_i = source.getAttenuation(); } @Override diff --git a/src/main/java/mekanism/client/sound/TileSound.java b/src/main/java/mekanism/client/sound/TileSound.java index 0b9996af0..bb65ab2f4 100644 --- a/src/main/java/mekanism/client/sound/TileSound.java +++ b/src/main/java/mekanism/client/sound/TileSound.java @@ -35,12 +35,6 @@ public class TileSound extends Sound tileEntity = tileentity; } - @Override - public float getMultiplier() - { - return super.getMultiplier()*((IHasSound)tileEntity).getVolumeMultiplier(); - } - @Override public Pos3D getLocation() { diff --git a/src/main/java/mekanism/common/base/IFactory.java b/src/main/java/mekanism/common/base/IFactory.java index 37782af86..4ae40f778 100644 --- a/src/main/java/mekanism/common/base/IFactory.java +++ b/src/main/java/mekanism/common/base/IFactory.java @@ -14,6 +14,7 @@ import mekanism.api.util.StackUtils; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; /** @@ -39,16 +40,16 @@ public interface IFactory public static enum RecipeType { - SMELTING("smelting", "Smelter.ogg", MachineType.ENERGIZED_SMELTER.getStack(), false, null), - ENRICHING("enriching", "Chamber.ogg", MachineType.ENRICHMENT_CHAMBER.getStack(), false, Recipe.ENRICHMENT_CHAMBER), - CRUSHING("crushing", "Crusher.ogg", MachineType.CRUSHER.getStack(), false, Recipe.CRUSHER), - COMPRESSING("compressing", "Compressor.ogg", MachineType.OSMIUM_COMPRESSOR.getStack(), true, Recipe.OSMIUM_COMPRESSOR), - COMBINING("combining", "Combiner.ogg", MachineType.COMBINER.getStack(), true, Recipe.COMBINER), - PURIFYING("purifying", "PurificationChamber.ogg", MachineType.PURIFICATION_CHAMBER.getStack(), true, Recipe.PURIFICATION_CHAMBER), - INJECTING("injecting", "ChemicalInjectionChamber.ogg", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, Recipe.CHEMICAL_INJECTION_CHAMBER); + SMELTING("smelting", "smelter", MachineType.ENERGIZED_SMELTER.getStack(), false, null), + ENRICHING("enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER.getStack(), false, Recipe.ENRICHMENT_CHAMBER), + CRUSHING("crushing", "crusher", MachineType.CRUSHER.getStack(), false, Recipe.CRUSHER), + COMPRESSING("compressing", "compressor", MachineType.OSMIUM_COMPRESSOR.getStack(), true, Recipe.OSMIUM_COMPRESSOR), + COMBINING("combining", "combiner", MachineType.COMBINER.getStack(), true, Recipe.COMBINER), + PURIFYING("purifying", "purifier", MachineType.PURIFICATION_CHAMBER.getStack(), true, Recipe.PURIFICATION_CHAMBER), + INJECTING("injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, Recipe.CHEMICAL_INJECTION_CHAMBER); private String name; - private String sound; + private ResourceLocation sound; private ItemStack stack; private boolean usesFuel; private Recipe recipe; @@ -188,7 +189,7 @@ public interface IFactory return MekanismUtils.localize("gui.factory." + name); } - public String getSound() + public ResourceLocation getSound() { return sound; } @@ -201,7 +202,7 @@ public interface IFactory private RecipeType(String s, String s1, ItemStack is, boolean b, Recipe r) { name = s; - sound = s1; + sound = new ResourceLocation("mekanism", s1); stack = is; usesFuel = b; recipe = r; diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java index 5dcb3efbf..fcb901c71 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java @@ -5,9 +5,13 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.Coord4D; +import mekanism.api.Pos3D; import mekanism.api.Range4D; import mekanism.api.MekanismConfig.general; import mekanism.client.sound.IHasSound; +import mekanism.client.sound.ISoundSource; +import mekanism.client.sound.SoundTile; +import mekanism.client.sound.TestSound; import mekanism.common.Mekanism; import mekanism.common.SideData; import mekanism.common.base.IActiveState; @@ -20,15 +24,19 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.util.MekanismUtils; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.ISound.AttenuationType; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl +public abstract class TileEntityBasicMachine extends TileEntityNoisyElectricBlock implements IElectricMachine, IPeripheral, IInvConfiguration, IUpgradeTile, IRedstoneControl { /** This machine's side configuration. */ public byte[] sideConfig; @@ -36,9 +44,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp /** An arraylist of SideData for this machine. */ public ArrayList sideOutputs = new ArrayList(); - /** The bundled URL of this machine's sound effect */ - public String soundURL; - /** How much energy this machine uses per tick. */ public double ENERGY_PER_TICK; @@ -80,10 +85,9 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp */ public TileEntityBasicMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy) { - super(name, maxEnergy); + super("machine." + soundPath, name, maxEnergy); ENERGY_PER_TICK = perTick; TICKS_REQUIRED = ticksRequired; - soundURL = soundPath; guiLocation = location; isActive = false; } @@ -291,18 +295,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp return facing; } - @Override - public String getSoundPath() - { - return soundURL; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public boolean renderUpdate() { diff --git a/src/main/java/mekanism/common/tile/TileEntityChargepad.java b/src/main/java/mekanism/common/tile/TileEntityChargepad.java index 9c887f7d2..266d5aa4c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChargepad.java +++ b/src/main/java/mekanism/common/tile/TileEntityChargepad.java @@ -29,7 +29,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; import cofh.api.energy.IEnergyContainerItem; -public class TileEntityChargepad extends TileEntityElectricBlock implements IActiveState, IHasSound +public class TileEntityChargepad extends TileEntityNoisyElectricBlock { public boolean isActive; @@ -39,7 +39,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct public TileEntityChargepad() { - super("Chargepad", MachineType.CHARGEPAD.baseEnergy); + super("chargepad", "Chargepad", MachineType.CHARGEPAD.baseEnergy); inventory = new ItemStack[0]; } @@ -217,13 +217,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct } @Override - public String getSoundPath() - { - return "Chargepad.ogg"; - } - - @Override - public float getVolumeMultiplier() + public float getVolume() { return 0.4F; } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index 2c680ff16..e3ec66df1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -41,7 +41,7 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IInvConfiguration, IUpgradeTile, ISustainedData +public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IInvConfiguration, IUpgradeTile, ISustainedData { public static final int MAX_GAS = 10000; public static final int MAX_FLUID = 10000; @@ -82,7 +82,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl public TileEntityChemicalCrystallizer() { - super("ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy); + super("crystallizer", "ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy); sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {0})); @@ -469,18 +469,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl return InventoryUtils.EMPTY; } - @Override - public String getSoundPath() - { - return "ChemicalCrystallizer.ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public ArrayList getSideData() { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index 74a6e9815..956ee9335 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -34,7 +34,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IGasHandler, IUpgradeTile, ISustainedData +public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IGasHandler, IUpgradeTile, ISustainedData { public GasTank injectTank = new GasTank(MAX_GAS); public GasTank outputTank = new GasTank(MAX_GAS); @@ -65,7 +65,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc public TileEntityChemicalDissolutionChamber() { - super("ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy); + super("machine.dissolution", "ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy); inventory = new ItemStack[5]; } @@ -396,18 +396,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc MekanismUtils.saveChunk(this); } - @Override - public String getSoundPath() - { - return "ChemicalDissolutionChamber.ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index 5b25aa89c..8ddd6c8d2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -33,7 +33,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, ISustainedData +public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData { public GasTank leftTank = new GasTank(MAX_GAS); public GasTank rightTank = new GasTank(MAX_GAS); @@ -58,7 +58,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement public TileEntityChemicalInfuser() { - super("ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy); + super("machine.cheminfuser", "ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy); inventory = new ItemStack[4]; } @@ -315,21 +315,6 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement return null; } - public int getScaledLeftGasLevel(int i) - { - return leftTank != null ? leftTank.getStored()*i / MAX_GAS : 0; - } - - public int getScaledRightGasLevel(int i) - { - return rightTank != null ? rightTank.getStored()*i / MAX_GAS : 0; - } - - public int getScaledCenterGasLevel(int i) - { - return centerTank != null ? centerTank.getStored()*i / MAX_GAS : 0; - } - @Override public void setActive(boolean active) { @@ -468,18 +453,6 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement return InventoryUtils.EMPTY; } - @Override - public String getSoundPath() - { - return "ChemicalInfuser.ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public void writeSustainedData(ItemStack itemStack) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java index f99b7840e..d7a25a0f0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java @@ -22,7 +22,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr { public TileEntityChemicalInjectionChamber() { - super("ChemicalInjectionChamber.ogg", "ChemicalInjectionChamber", usage.chemicalInjectionChamberUsage, 1, 200, MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy); + super("injection", "ChemicalInjectionChamber", usage.chemicalInjectionChamberUsage, 1, 200, MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index 55290d9e7..ce9178f7d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -33,7 +33,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IUpgradeTile, ISustainedData +public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IUpgradeTile, ISustainedData { public GasTank gasTank = new GasTank(MAX_GAS); @@ -61,7 +61,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen public TileEntityChemicalOxidizer() { - super("ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy); + super("machine.oxidiser", "ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy); inventory = new ItemStack[4]; } @@ -295,11 +295,6 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen return MekanismUtils.getMaxEnergy(this, MAX_ELECTRICITY); } - public int getScaledGasLevel(int i) - { - return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_GAS : 0; - } - @Override public void setActive(boolean active) { @@ -351,18 +346,6 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen MekanismUtils.saveChunk(this); } - @Override - public String getSoundPath() - { - return "ChemicalInfuser.ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public TileComponentUpgrade getComponent() { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index bb3d6a9ef..3e665af9b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -43,7 +43,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityChemicalWasher extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IFluidHandler, ISustainedData +public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandler, ISustainedData { public FluidTank fluidTank = new FluidTank(MAX_FLUID); public GasTank inputTank = new GasTank(MAX_GAS); @@ -71,7 +71,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements public TileEntityChemicalWasher() { - super("ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); + super("washer", "ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); inventory = new ItemStack[4]; } @@ -533,18 +533,6 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements return InventoryUtils.EMPTY; } - @Override - public String getSoundPath() - { - return "ChemicalWasher.ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/mekanism/common/tile/TileEntityCombiner.java b/src/main/java/mekanism/common/tile/TileEntityCombiner.java index afdb2ba1a..c521a4921 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCombiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityCombiner.java @@ -17,7 +17,7 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine { public TileEntityCombiner() { - super("Combiner.ogg", "Combiner", usage.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy); + super("combiner", "Combiner", usage.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityCrusher.java b/src/main/java/mekanism/common/tile/TileEntityCrusher.java index 9adbd8cb3..df2250209 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCrusher.java +++ b/src/main/java/mekanism/common/tile/TileEntityCrusher.java @@ -16,35 +16,11 @@ import cpw.mods.fml.client.FMLClientHandler; public class TileEntityCrusher extends TileEntityElectricMachine { - public TestSound sfx; - public TileEntityCrusher() { - super("Crusher.ogg", "Crusher", usage.crusherUsage, 200, MachineType.CRUSHER.baseEnergy); + super("crusher", "Crusher", usage.crusherUsage, 200, MachineType.CRUSHER.baseEnergy); } - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote) - { - if(isActive && sfx.isDonePlaying()) - { - Mekanism.logger.info("Playing Crusher noise"); - sfx.finished = false; - FMLClientHandler.instance().getClient().getSoundHandler().playSound(sfx); - } - else if(!(isActive || sfx.isDonePlaying())) - { - Mekanism.logger.info("Stopping Crusher noise"); - sfx.finished = true; - } - } - } - - @Override public Map getRecipes() { @@ -52,22 +28,8 @@ public class TileEntityCrusher extends TileEntityElectricMachine } @Override - public float getVolumeMultiplier() + public float getVolume() { return 0.5F; } - - @Override - public void validate() - { - super.validate(); - sfx = new TestSound(new ResourceLocation("mekanism", "tile.machine.crusher"), this); - } - - @Override - public void invalidate() - { - super.invalidate(); - sfx.finished = true; - } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java index 8b87108dd..a8e684653 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java @@ -13,7 +13,7 @@ public class TileEntityEnergizedSmelter extends TileEntityElectricMachine public TileEntityEnergizedSmelter() { - super("Smelter.ogg", "EnergizedSmelter", usage.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy); + super("smelter", "EnergizedSmelter", usage.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java b/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java index e1b5f7cd1..32b4f45a4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java @@ -10,7 +10,7 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine { public TileEntityEnrichmentChamber() { - super("Chamber.ogg", "EnrichmentChamber", usage.enrichmentChamberUsage, 200, MachineType.ENRICHMENT_CHAMBER.baseEnergy); + super("enrichment", "EnrichmentChamber", usage.enrichmentChamberUsage, 200, MachineType.ENRICHMENT_CHAMBER.baseEnergy); } @Override @@ -20,7 +20,7 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine } @Override - public float getVolumeMultiplier() + public float getVolume() { return 0.3F; } diff --git a/src/main/java/mekanism/common/tile/TileEntityFactory.java b/src/main/java/mekanism/common/tile/TileEntityFactory.java index b9cfbe66e..87fec2a10 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityFactory.java @@ -39,6 +39,7 @@ import mekanism.api.util.StackUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; @@ -47,7 +48,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public class TileEntityFactory extends TileEntityElectricBlock implements IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl, IGasHandler, ITubeConnection +public class TileEntityFactory extends TileEntityNoisyElectricBlock implements IPeripheral, IInvConfiguration, IUpgradeTile, IRedstoneControl, IGasHandler, ITubeConnection { /** This Factory's tier. */ public FactoryTier tier; @@ -114,7 +115,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip public TileEntityFactory(FactoryTier type, MachineType machine) { - super(type.name + "Factory", machine.baseEnergy); + super("null", type.name + "Factory", machine.baseEnergy); tier = type; inventory = new ItemStack[5+type.processes*2]; @@ -829,17 +830,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip } @Override - public String getSoundPath() + public ResourceLocation getSoundLocation() { return RecipeType.values()[recipeType].getSound(); } - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public boolean renderUpdate() { diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 234b78aed..0427f73b1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -42,7 +42,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl +public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IPeripheral, IInvConfiguration, IUpgradeTile, IRedstoneControl { /** This machine's side configuration. */ public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4}; @@ -88,7 +88,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem public TileEntityMetallurgicInfuser() { - super("MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy); + super("metalinfuser", "MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy); sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0})); @@ -548,18 +548,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem return facing; } - @Override - public String getSoundPath() - { - return "MetallurgicInfuser.ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public boolean renderUpdate() { diff --git a/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java new file mode 100644 index 000000000..71af7b727 --- /dev/null +++ b/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java @@ -0,0 +1,107 @@ +package mekanism.common.tile; + +import mekanism.api.Pos3D; +import mekanism.client.sound.IHasSound; +import mekanism.client.sound.ISoundSource; +import mekanism.client.sound.SoundTile; +import mekanism.common.Mekanism; +import mekanism.common.base.IActiveState; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.ISound.AttenuationType; +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.client.FMLClientHandler; + +public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlock implements IHasSound, ISoundSource, IActiveState +{ + /** The ResourceLocation of the machine's sound */ + public ResourceLocation soundURL; + + /** The bundled URL of this machine's sound effect */ + public SoundTile sound; + + /** + * The base of all blocks that deal with electricity and make noise. + * + * @param name - full name of this block + * @param maxEnergy - how much energy this block can store + */ + public TileEntityNoisyElectricBlock(String soundPath, String name, double maxEnergy) + { + super(name, maxEnergy); + + soundURL = new ResourceLocation("mekanism", "tile." + soundPath); + } + + @Override + public ISound getSound() + { + return sound; + } + + @Override + public boolean shouldPlaySound() + { + return getActive() && !isInvalid(); + } + + @Override + public ResourceLocation getSoundLocation() + { + return soundURL; + } + + @Override + public float getVolume() + { + return 1F; + } + + @Override + public float getPitch() + { + return 1F; + } + + @Override + public Pos3D getSoundPosition() + { + return new Pos3D(xCoord+0.5, yCoord+0.5, zCoord+0.5); + } + + @Override + public boolean shouldRepeat() + { + return true; + } + + @Override + public int getRepeatDelay() + { + return 0; + } + + @Override + public AttenuationType getAttenuation() + { + return AttenuationType.LINEAR; + } + + @Override + public void validate() + { + super.validate(); + sound = new SoundTile(this, this); + } + + @Override + public void onUpdate() + { + if(worldObj.isRemote && shouldPlaySound() && sound.isDonePlaying()) + { + Mekanism.logger.info("Playing " + this.fullName + " noise"); + sound.reset(); + FMLClientHandler.instance().getClient().getSoundHandler().playSound(sound); + } + } +} diff --git a/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java b/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java index 621212021..c9e819edf 100644 --- a/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java +++ b/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java @@ -15,7 +15,7 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin { public TileEntityOsmiumCompressor() { - super("Compressor.ogg", "OsmiumCompressor", usage.osmiumCompressorUsage, 1, 200, MachineType.OSMIUM_COMPRESSOR.baseEnergy); + super("compressor", "OsmiumCompressor", usage.osmiumCompressorUsage, 1, 200, MachineType.OSMIUM_COMPRESSOR.baseEnergy); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index 4a3cf4f67..ab52df021 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -51,7 +51,7 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl public TileEntityPRC() { - super("PressurizedReactionChamber.ogg", "PressurizedReactionChamber", new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy); + super("prc", "PressurizedReactionChamber", new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy); sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0})); diff --git a/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java b/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java index 225afdd07..e9516bd2e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java +++ b/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java @@ -12,7 +12,7 @@ public class TileEntityPrecisionSawmill extends TileEntityChanceMachine { public TileEntityPrecisionSawmill() { - super("PrecisionSawmill.ogg", "PrecisionSawmill", MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), usage.precisionSawmillUsage, 200, MachineType.PRECISION_SAWMILL.baseEnergy); + super("sawmill", "PrecisionSawmill", MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), usage.precisionSawmillUsage, 200, MachineType.PRECISION_SAWMILL.baseEnergy); } @Override @@ -22,7 +22,7 @@ public class TileEntityPrecisionSawmill extends TileEntityChanceMachine } @Override - public float getVolumeMultiplier() + public float getVolume() { return 0.7F; } diff --git a/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java b/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java index 4263cfcf9..c34036156 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java @@ -22,7 +22,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac { public TileEntityPurificationChamber() { - super("PurificationChamber.ogg", "PurificationChamber", usage.purificationChamberUsage, 1, 200, MachineType.PURIFICATION_CHAMBER.baseEnergy); + super("purification", "PurificationChamber", usage.purificationChamberUsage, 1, 200, MachineType.PURIFICATION_CHAMBER.baseEnergy); } @Override diff --git a/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java b/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java index 4aa572196..c5e06b775 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java +++ b/src/main/java/mekanism/generators/client/gui/GuiWindTurbine.java @@ -81,7 +81,7 @@ public class GuiWindTurbine extends GuiMekanism int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.getVolumeMultiplier() > 0 ? 52 : 64), 12, 12); + drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.getActive() ? 52 : 64), 12, 12); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index 914c8e4ed..c03dd742f 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -30,16 +30,12 @@ import dan200.computercraft.api.peripheral.IComputerAccess; public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData { - /** The Sound instance for this machine. */ - @SideOnly(Side.CLIENT) - public TileSound audio; - /** The FluidSlot biofuel instance for this generator. */ public FluidSlot bioFuelSlot = new FluidSlot(24000, -1); public TileEntityBioGenerator() { - super("BioGenerator", 160000, generators.bioGeneration*2); + super("bio", "BioGenerator", 160000, generators.bioGeneration*2); inventory = new ItemStack[2]; } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index 6e76c744e..6f52b5e9c 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -39,7 +39,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH public TileEntityGasGenerator() { - super("GasGenerator", general.FROM_H2*100, general.FROM_H2*2); + super("gas", "GasGenerator", general.FROM_H2*100, general.FROM_H2*2); inventory = new ItemStack[2]; fuelTank = new GasTank(MAX_GAS); } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 93394c900..bb4453410 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -6,18 +6,26 @@ import java.util.ArrayList; import java.util.EnumSet; import mekanism.api.Coord4D; +import mekanism.api.Pos3D; import mekanism.api.Range4D; import mekanism.api.MekanismConfig.general; import mekanism.client.sound.IHasSound; +import mekanism.client.sound.ISoundSource; +import mekanism.client.sound.SoundTile; import mekanism.common.Mekanism; import mekanism.common.base.IActiveState; import mekanism.common.base.IRedstoneControl; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityElectricBlock; +import mekanism.common.tile.TileEntityNoisyElectricBlock; import mekanism.common.util.CableUtils; import mekanism.common.util.MekanismUtils; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.ISound.AttenuationType; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Method; @@ -27,7 +35,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPeripheral, IActiveState, IHasSound, IRedstoneControl +public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock implements IPeripheral, IActiveState, IHasSound, ISoundSource, IRedstoneControl { /** Output per tick this generator can transfer. */ public double output; @@ -49,9 +57,9 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem * @param name - full name of this generator * @param maxEnergy - how much energy this generator can store */ - public TileEntityGenerator(String name, double maxEnergy, double out) + public TileEntityGenerator(String soundPath, String name, double maxEnergy, double out) { - super(name, maxEnergy); + super("gen." + soundPath, name, maxEnergy); if(MekanismUtils.useBuildCraft()) { @@ -123,14 +131,11 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } @Override - public void invalidate() + public void validate() { - super.invalidate(); + super.validate(); - if(worldObj.isRemote) - { - Mekanism.proxy.unregisterSound(this); - } + sound = new SoundTile(this, this); } /** @@ -239,18 +244,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem return INFINITE_EXTENT_AABB; } - @Override - public String getSoundPath() - { - return fullName.replace("Advanced", "") + ".ogg"; - } - - @Override - public float getVolumeMultiplier() - { - return 1; - } - @Override public boolean renderUpdate() { diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index d3e3d9905..81b2e9840 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -36,7 +36,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu public TileEntityHeatGenerator() { - super("HeatGenerator", 160000, generators.heatGeneration*2); + super("heat", "HeatGenerator", 160000, generators.heatGeneration*2); inventory = new ItemStack[2]; } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index 0e1902132..d39ab474e 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -29,14 +29,13 @@ public class TileEntitySolarGenerator extends TileEntityGenerator public TileEntitySolarGenerator() { - super("SolarGenerator", 96000, generators.solarGeneration*2); + this("SolarGenerator", 96000, generators.solarGeneration*2); GENERATION_RATE = generators.solarGeneration; - inventory = new ItemStack[1]; } public TileEntitySolarGenerator(String name, double maxEnergy, double output) { - super(name, maxEnergy, output); + super("solar", name, maxEnergy, output); inventory = new ItemStack[1]; } @@ -47,7 +46,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator } @Override - public float getVolumeMultiplier() + public float getVolume() { return 0.05F; } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityWindTurbine.java b/src/main/java/mekanism/generators/common/tile/TileEntityWindTurbine.java index e61467af6..c48700731 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityWindTurbine.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityWindTurbine.java @@ -19,7 +19,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound public TileEntityWindTurbine() { - super("WindTurbine", 200000, (generators.windGenerationMax)*2); + super("wind", "WindTurbine", 200000, (generators.windGenerationMax)*2); inventory = new ItemStack[1]; } @@ -67,7 +67,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound } @Override - public float getVolumeMultiplier() + public float getVolume() { return 1.5F; } diff --git a/src/main/resources/assets/mekanism/sounds.json b/src/main/resources/assets/mekanism/sounds.json index d4fcd0e8f..4705a62a0 100644 --- a/src/main/resources/assets/mekanism/sounds.json +++ b/src/main/resources/assets/mekanism/sounds.json @@ -7,5 +7,27 @@ "etc.Hydraulic": {"category": "master","sounds": [{"name": "etc/Hydraulic","stream": false}]}, "etc.Pop": {"category": "master","sounds": [{"name": "etc/Pop","stream": false}]}, "etc.Success": {"category": "master","sounds": [{"name": "etc/Success","stream": false}]}, - "tile.machine.crusher": {"category": "block", "sounds": [{"name": "Crusher","stream": false}]} + + "tile.machine.chargepad": {"category": "block", "sounds": [{"name": "Chargepad","stream": false}]}, + "tile.machine.crystallizer": {"category": "block", "sounds": [{"name": "ChemicalCrystallizer","stream": false}]}, + "tile.machine.dissolution": {"category": "block", "sounds": [{"name": "ChemicalDissolutionChamber","stream": false}]}, + "tile.machine.cheminfuser": {"category": "block", "sounds": [{"name": "ChemicalInfuser","stream": false}]}, + "tile.machine.injection": {"category": "block", "sounds": [{"name": "ChemicalInjectionChamber","stream": false}]}, + "tile.machine.oxidizer": {"category": "block", "sounds": [{"name": "ChemicalOxidizer","stream": false}]}, + "tile.machine.washer": {"category": "block", "sounds": [{"name": "ChemicalWasher","stream": false}]}, + "tile.machine.combiner": {"category": "block", "sounds": [{"name": "Combiner","stream": false}]}, + "tile.machine.compressor": {"category": "block", "sounds": [{"name": "Compressor","stream": false}]}, + "tile.machine.crusher": {"category": "block", "sounds": [{"name": "Crusher","stream": false}]}, + "tile.machine.enrichment": {"category": "block", "sounds": [{"name": "EnrichmentChamber","stream": false}]}, + "tile.machine.metalinfuser": {"category": "block", "sounds": [{"name": "MetallurgicInfuser","stream": false}]}, + "tile.machine.sawmill": {"category": "block", "sounds": [{"name": "PrecisionSawmill","stream": false}]}, + "tile.machine.prc": {"category": "block", "sounds": [{"name": "PressurizedReactionChamber","stream": false}]}, + "tile.machine.purification": {"category": "block", "sounds": [{"name": "PurificationChamber","stream": false}]}, + "tile.machine.smelter": {"category": "block", "sounds": [{"name": "Smelter","stream": false}]}, + + "tile.gen.bio": {"category": "block", "sounds": [{"name": "BioGenerator","stream": false}]}, + "tile.gen.gas": {"category": "block", "sounds": [{"name": "GasGenerator","stream": false}]}, + "tile.gen.heat": {"category": "block", "sounds": [{"name": "HeatGenerator","stream": false}]}, + "tile.gen.solar": {"category": "block", "sounds": [{"name": "SolarGenerator","stream": false}]}, + "tile.gen.wind": {"category": "block", "sounds": [{"name": "WindTurbine","stream": false}]} } \ No newline at end of file diff --git a/src/main/resources/assets/mekanism/sounds/Elementizer.ogg b/src/main/resources/assets/mekanism/sounds/Elementizer.ogg deleted file mode 100644 index 61a24468c..000000000 Binary files a/src/main/resources/assets/mekanism/sounds/Elementizer.ogg and /dev/null differ diff --git a/src/main/resources/assets/mekanism/sounds/Chamber.ogg b/src/main/resources/assets/mekanism/sounds/EnrichmentChamber.ogg similarity index 100% rename from src/main/resources/assets/mekanism/sounds/Chamber.ogg rename to src/main/resources/assets/mekanism/sounds/EnrichmentChamber.ogg