Merge branch 'soundsystem' into 1.8

@aidancbrady, I got this working, might need some more refinement but
it's pretty stable
This commit is contained in:
Ben Spiers 2014-08-30 00:11:14 +01:00
commit e83f3ee042
46 changed files with 791 additions and 1309 deletions

View file

@ -1,7 +1,6 @@
package mekanism.client; package mekanism.client;
import java.io.File; import java.io.File;
import java.util.HashMap;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.client;
@ -90,7 +89,6 @@ import mekanism.client.render.tileentity.RenderSalinationController;
import mekanism.client.render.tileentity.RenderSeismicVibrator; import mekanism.client.render.tileentity.RenderSeismicVibrator;
import mekanism.client.render.tileentity.RenderTeleporter; import mekanism.client.render.tileentity.RenderTeleporter;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.client.sound.SoundMap;
import mekanism.common.CommonProxy; import mekanism.common.CommonProxy;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks; import mekanism.common.MekanismBlocks;
@ -200,33 +198,6 @@ public class ClientProxy extends CommonProxy
return RenderingRegistry.addNewArmourRendererPrefix(string); return RenderingRegistry.addNewArmourRendererPrefix(string);
} }
@Override
public void registerSound(TileEntity tileEntity)
{
if(client.enableSounds && MekanismClient.audioHandler != null)
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
MekanismClient.audioHandler.registerTileSound(tileEntity);
}
}
}
@Override
public void unregisterSound(TileEntity tileEntity)
{
if(client.enableSounds && MekanismClient.audioHandler != null)
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
if(MekanismClient.audioHandler.getMap(tileEntity) != null)
{
MekanismClient.audioHandler.getMap(tileEntity).kill();
}
}
}
}
@Override @Override
public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z)
{ {
@ -520,29 +491,6 @@ public class ClientProxy extends CommonProxy
} }
} }
@Override
public void unloadSoundHandler()
{
if(client.enableSounds)
{
if(MekanismClient.audioHandler != null)
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
HashMap<Object, SoundMap> mapsCopy = new HashMap<Object, SoundMap>();
mapsCopy.putAll(MekanismClient.audioHandler.soundMaps);
for(SoundMap map : mapsCopy.values())
{
map.kill();
}
MekanismClient.audioHandler.soundMaps.clear();
}
}
}
}
@Override @Override
public void preInit() public void preInit()
{ {

View file

@ -7,45 +7,30 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import mekanism.api.EnumColor;
import mekanism.api.IClientTicker; import mekanism.api.IClientTicker;
import mekanism.api.MekanismConfig.client;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.client.sound.FlamethrowerSound; import mekanism.client.sound.FlamethrowerSound;
import mekanism.client.sound.GasMaskSound; import mekanism.client.sound.GasMaskSound;
import mekanism.client.sound.JetpackSound; import mekanism.client.sound.JetpackSound;
import mekanism.client.sound.SoundHandler;
import mekanism.common.KeySync; import mekanism.common.KeySync;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.ObfuscatedNames; import mekanism.common.ObfuscatedNames;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.item.ItemBlockMachine;
import mekanism.common.item.ItemConfigurator;
import mekanism.common.item.ItemElectricBow;
import mekanism.common.item.ItemFlamethrower; import mekanism.common.item.ItemFlamethrower;
import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemFreeRunners;
import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemGasMask;
import mekanism.common.item.ItemJetpack; import mekanism.common.item.ItemJetpack;
import mekanism.common.item.ItemJetpack.JetpackMode; import mekanism.common.item.ItemJetpack.JetpackMode;
import mekanism.common.item.ItemScubaTank; import mekanism.common.item.ItemScubaTank;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage;
import mekanism.common.network.PacketElectricBowState.ElectricBowStateMessage;
import mekanism.common.network.PacketFlamethrowerActive.FlamethrowerActiveMessage; import mekanism.common.network.PacketFlamethrowerActive.FlamethrowerActiveMessage;
import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import mekanism.common.network.PacketJetpackData.JetpackDataMessage;
import mekanism.common.network.PacketJetpackData.JetpackPacket; import mekanism.common.network.PacketJetpackData.JetpackPacket;
import mekanism.common.network.PacketPortableTankState.PortableTankStateMessage;
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage; import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket; import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.api.util.StackUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@ -54,6 +39,10 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import static mekanism.client.sound.SoundHandler.Channel.FLAMETHROWER;
import static mekanism.client.sound.SoundHandler.Channel.GASMASK;
import static mekanism.client.sound.SoundHandler.Channel.JETPACK;
/** /**
* Client-side tick handler for Mekanism. Used mainly for the update check upon startup. * Client-side tick handler for Mekanism. Used mainly for the update check upon startup.
* @author AidanBrady * @author AidanBrady
@ -90,27 +79,10 @@ public class ClientTickHandler
{ {
tickStart(); tickStart();
} }
else if(event.phase == Phase.END)
{
tickEnd();
}
} }
public void tickStart() public void tickStart()
{ {
if(!preloadedSounds && client.enableSounds && MekanismClient.audioHandler != null && MekanismClient.audioHandler.isSystemLoaded())
{
preloadedSounds = true;
new Thread(new Runnable() {
@Override
public void run()
{
MekanismClient.audioHandler.preloadSounds();
}
}).start();
}
MekanismClient.ticksPassed++; MekanismClient.ticksPassed++;
if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null) if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
@ -286,10 +258,11 @@ public class ClientTickHandler
if(player != null) if(player != null)
{ {
if(MekanismClient.audioHandler.getSound(player, SoundHandler.CHANNEL_JETPACK) == null) if(!MekanismClient.audioHandler.hasSound(player, JETPACK))
{ {
new JetpackSound(MekanismClient.audioHandler.getIdentifier(player), player); MekanismClient.audioHandler.addSound(player, JETPACK, new JetpackSound(player), false);
} }
MekanismClient.audioHandler.playSound(player, JETPACK);
} }
} }
@ -299,10 +272,11 @@ public class ClientTickHandler
if(player != null) if(player != null)
{ {
if(MekanismClient.audioHandler.getSound(player, SoundHandler.CHANNEL_GASMASK) == null) if(!MekanismClient.audioHandler.hasSound(player, GASMASK))
{ {
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(player), player); MekanismClient.audioHandler.addSound(player, GASMASK, new GasMaskSound(player), false);
} }
MekanismClient.audioHandler.playSound(player, GASMASK);
} }
} }
@ -310,10 +284,11 @@ public class ClientTickHandler
{ {
if(hasFlamethrower(player)) if(hasFlamethrower(player))
{ {
if(MekanismClient.audioHandler.getSound(player, SoundHandler.CHANNEL_FLAMETHROWER) == null) if(!MekanismClient.audioHandler.hasSound(player, FLAMETHROWER))
{ {
new FlamethrowerSound(MekanismClient.audioHandler.getIdentifier(player), player); MekanismClient.audioHandler.addSound(player, FLAMETHROWER, new FlamethrowerSound(player), false);
} }
MekanismClient.audioHandler.playSound(player, FLAMETHROWER);
} }
} }
} }
@ -484,15 +459,4 @@ public class ClientTickHandler
return false; return false;
} }
public void tickEnd()
{
if(MekanismClient.audioHandler != null)
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
MekanismClient.audioHandler.onTick();
}
}
}
} }

View file

@ -34,7 +34,7 @@ public class ThreadMultiblockSparkle extends Thread
try { try {
if(general.dynamicTankEasterEgg) if(general.dynamicTankEasterEgg)
{ {
MekanismClient.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(8)+1) + ".ogg", pointer.getWorldObj(), Coord4D.get(pointer)); pointer.getWorldObj().playSound(pointer.xCoord, pointer.yCoord, pointer.zCoord, "mekanism:etc.cj", 1F, 1F, false);
} }
loop(pointer); loop(pointer);

View file

@ -1,60 +1,58 @@
package mekanism.client.sound; package mekanism.client.sound;
import mekanism.client.ClientTickHandler; import mekanism.client.ClientTickHandler;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.util.ResourceLocation;
public class FlamethrowerSound extends PlayerSound public class FlamethrowerSound extends PlayerSound
{ {
public boolean inUse = false; public boolean inUse;
public FlamethrowerSound(String id, EntityPlayer entity) public ResourceLocation onSound;
public ResourceLocation offSound;
public FlamethrowerSound(EntityPlayer player)
{ {
super(id, getSound(ClientTickHandler.isFlamethrowerOn(entity)), SoundHandler.CHANNEL_FLAMETHROWER, entity); super(player, new ResourceLocation("mekanism", "item.flamethrower.idle"));
onSound = new ResourceLocation("mekanism", "item.flamethrower.active");
inUse = ClientTickHandler.isFlamethrowerOn(entity); offSound = new ResourceLocation("mekanism", "item.flamethrower.idle");
setFadeIn(0);
setFadeOut(0);
} }
@Override @Override
public boolean update(World world) public boolean isDonePlaying()
{ {
if(!super.update(world)) return donePlaying;
{ }
return false;
}
else if(!ClientTickHandler.hasFlamethrower(player))
{
return false;
}
else if(inUse != ClientTickHandler.isFlamethrowerOn(player))
{
return false;
}
if(!isPlaying)
{
play();
}
ticksSincePlay++;
@Override
public boolean shouldPlaySound()
{
return true; return true;
} }
@Override @Override
public float getMultiplier() public float getVolume()
{ {
return super.getMultiplier() * (inUse ? 2 : 1); return super.getVolume() * (inUse ? 2 : 1);
} }
@Override @Override
public boolean doGradualEffect() public void update()
{ {
return false; if(!ClientTickHandler.hasFlamethrower(player))
} {
donePlaying = true;
private static String getSound(boolean inUse)
{ return;
return inUse ? "FlamethrowerActive.ogg" : "FlamethrowerIdle.ogg"; }
if(inUse != ClientTickHandler.isFlamethrowerOn(player))
{
inUse = ClientTickHandler.isFlamethrowerOn(player);
sound = inUse ? onSound : offSound;
donePlaying = true;
}
} }
} }

View file

@ -2,46 +2,29 @@ package mekanism.client.sound;
import mekanism.client.ClientTickHandler; import mekanism.client.ClientTickHandler;
import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemGasMask;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.util.ResourceLocation;
public class GasMaskSound extends PlayerSound public class GasMaskSound extends PlayerSound
{ {
public GasMaskSound(String id, EntityPlayer entity) public GasMaskSound(EntityPlayer player)
{ {
super(id, "GasMask.ogg", SoundHandler.CHANNEL_GASMASK, entity); super(player, new ResourceLocation("mekanism", "item.gasMask"));
setFadeIn(0);
setFadeOut(0);
} }
@Override @Override
public boolean update(World world) public boolean isDonePlaying()
{ {
if(!super.update(world)) return donePlaying;
{ }
return false;
}
else if(!hasGasMask(player))
{
return false;
}
else {
if(ClientTickHandler.isGasMaskOn(player) != isPlaying)
{
if(ClientTickHandler.isGasMaskOn(player))
{
play();
}
else {
stopLoop();
}
}
}
if(isPlaying) @Override
{ public boolean shouldPlaySound()
ticksSincePlay++; {
} return hasGasMask(player) && ClientTickHandler.isGasMaskOn(player);
return true;
} }
private boolean hasGasMask(EntityPlayer player) private boolean hasGasMask(EntityPlayer player)

View file

@ -1,5 +1,7 @@
package mekanism.client.sound; package mekanism.client.sound;
import net.minecraft.client.audio.ISound;
/** /**
* Implement this if your TileEntity has a specific sound. * Implement this if your TileEntity has a specific sound.
* @author AidanBrady * @author AidanBrady
@ -7,15 +9,7 @@ package mekanism.client.sound;
*/ */
public interface IHasSound public interface IHasSound
{ {
/** public ISound getSound();
* Gets the sound path of this block's sound.
* @return sound path
*/
public String getSoundPath();
/** public boolean shouldPlaySound();
* Gets the multiplier to play this sound by.
* @return sound multiplier
*/
public float getVolumeMultiplier();
} }

View file

@ -0,0 +1,8 @@
package mekanism.client.sound;
import net.minecraft.client.audio.ITickableSound;
public interface IResettableSound extends ITickableSound
{
public void reset();
}

View file

@ -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();
}

View file

@ -2,46 +2,29 @@ package mekanism.client.sound;
import mekanism.client.ClientTickHandler; import mekanism.client.ClientTickHandler;
import mekanism.common.item.ItemJetpack; import mekanism.common.item.ItemJetpack;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.util.ResourceLocation;
public class JetpackSound extends PlayerSound public class JetpackSound extends PlayerSound
{ {
public JetpackSound(String id, EntityPlayer entity) public JetpackSound(EntityPlayer player)
{ {
super(id, "Jetpack.ogg", SoundHandler.CHANNEL_JETPACK, entity); super(player, new ResourceLocation("mekanism", "item.jetpack"));
setFadeIn(0);
setFadeOut(0);
} }
@Override @Override
public boolean update(World world) public boolean isDonePlaying()
{ {
if(!super.update(world)) return donePlaying;
{ }
return false;
}
else if(!hasJetpack(player))
{
return false;
}
else {
if(ClientTickHandler.isJetpackOn(player) != isPlaying)
{
if(ClientTickHandler.isJetpackOn(player))
{
play();
}
else {
stopLoop();
}
}
}
if(isPlaying) @Override
{ public boolean shouldPlaySound()
ticksSincePlay++; {
} return hasJetpack(player) && ClientTickHandler.isJetpackOn(player);
return true;
} }
private boolean hasJetpack(EntityPlayer player) private boolean hasJetpack(EntityPlayer player)

View file

@ -1,53 +1,114 @@
package mekanism.client.sound; package mekanism.client.sound;
import mekanism.api.Pos3D; import mekanism.common.Mekanism;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public abstract class PlayerSound extends Sound import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
public abstract class PlayerSound extends Sound implements IResettableSound
{ {
/** The TileEntity this sound is associated with. */
public EntityPlayer player; public EntityPlayer player;
public PlayerSound(String id, String sound, String chan, EntityPlayer entity) boolean beginFadeOut;
{ boolean donePlaying = true;
super(id, sound, chan, entity, new Pos3D(entity)); int ticks = 0;
int fadeIn = 50;
int fadeOut = 50;
float baseVolume = 0.3F;
player = entity;
public PlayerSound(EntityPlayer player, ResourceLocation location)
{
super(location, 0.3F, 1, true, 0, (float) player.posX, (float) player.posY, (float) player.posZ, AttenuationType.LINEAR);
this.player = player;
} }
@Override @Override
public float getMultiplier() public float getXPosF()
{ {
return super.getMultiplier()*0.3F;
return (float) player.posX;
} }
@Override @Override
public boolean update(World world) public float getYPosF()
{ {
if(!super.update(world))
{
return false;
}
else if(player.isDead)
{
return false;
}
else if(player.worldObj != world)
{
return false;
}
else if(!world.loadedEntityList.contains(player))
{
return false;
}
return true; return (float) player.posY;
} }
@Override @Override
public Pos3D getLocation() public float getZPosF()
{ {
return new Pos3D(player);
return (float) player.posZ;
}
public PlayerSound setFadeIn(int fadeIn) {
this.fadeIn = Math.min(0, fadeIn);
return this;
}
public PlayerSound 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);
}
@Override
public void update()
{
if(!beginFadeOut)
{
if(ticks < fadeIn)
{
ticks++;
}
if(!shouldPlaySound())
{
beginFadeOut = true;
ticks = 0;
}
} else
{
ticks++;
}
float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier();
volume = baseVolume * multiplier;
if(multiplier <= 0)
{
Mekanism.logger.info("Sound Stopping. " + this);
donePlaying = true;
}
}
@Override
public boolean isDonePlaying()
{
return donePlaying;
}
public abstract boolean shouldPlaySound();
@Override
public void reset()
{
donePlaying = false;
beginFadeOut = false;
volume = baseVolume;
ticks = 0;
} }
} }

View file

@ -1,251 +1,178 @@
package mekanism.client.sound; package mekanism.client.sound;
import java.net.URL; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.MekanismConfig.client;
import mekanism.api.Pos3D;
import mekanism.client.MekanismClient;
import mekanism.common.Mekanism;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.ISound.AttenuationType;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
public abstract class Sound /**
{ * Generic ISound class with lots of constructor functionality.
/** The bundled path where the sound is */ * Required because - of course - Mojang has no generic that
public String prevSoundPath; * lets you specify *any* arguments for this.
*
* Taken from CoFHLib
*
* @author skyboy
*
*/
@SideOnly(Side.CLIENT)
public class Sound implements ISound {
/** A unique identifier for this sound */ protected AttenuationType attenuation;
public String identifier; protected ResourceLocation sound;
protected float volume;
protected float pitch;
protected float x;
protected float y;
protected float z;
protected boolean repeat;
protected int repeatDelay;
/** Whether or not this sound is playing */ public Sound(String sound) {
public boolean isPlaying = false;
public int ticksSincePlay = 0; this(sound, 0);
private Object objRef;
public String channel;
protected Minecraft mc = Minecraft.getMinecraft();
/**
* A sound that runs off of the PaulsCode sound system.
* @param id - unique identifier
* @param sound - bundled path to the sound
* @param tileentity - the tile this sound is playing from.
*/
public Sound(String id, String sound, String chan, Object obj, Pos3D loc)
{
if(MekanismClient.audioHandler.getSound(obj, chan) != null)
{
return;
}
synchronized(MekanismClient.audioHandler.soundMaps)
{
prevSoundPath = sound;
identifier = id;
objRef = obj;
channel = chan;
URL url = getClass().getClassLoader().getResource("assets/mekanism/sounds/" + sound);
if(url == null)
{
Mekanism.logger.error("Invalid sound file: " + sound);
}
if(SoundHandler.getSoundSystem() != null)
{
SoundHandler.getSoundSystem().newSource(false, id, url, sound, true, (float)loc.xPos, (float)loc.yPos, (float)loc.zPos, 0, 16F);
updateVolume();
SoundHandler.getSoundSystem().activate(id);
}
MekanismClient.audioHandler.registerSound(objRef, channel, this);
}
} }
/** public Sound(String sound, float volume) {
* Start looping the sound effect
*/
public void play()
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
if(isPlaying)
{
return;
}
ISound sound = ForgeHooksClient.playSound(SoundHandler.getSoundManager(), new DummySound()); this(sound, volume, 0);
if (!(sound instanceof DummySound)) return;
ticksSincePlay = 0;
if(SoundHandler.getSoundSystem() != null)
{
updateVolume();
SoundHandler.getSoundSystem().play(identifier);
}
isPlaying = true;
}
} }
/** public Sound(String sound, float volume, float pitch) {
* Stop looping the sound effect
*/
public void stopLoop()
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
if(!isPlaying)
{
return;
}
if(SoundHandler.getSoundSystem() != null) this(sound, volume, pitch, false, 0);
{
updateVolume();
SoundHandler.getSoundSystem().stop(identifier);
}
isPlaying = false;
}
} }
/** public Sound(String sound, float volume, float pitch, boolean repeat, int repeatDelay) {
* Remove the sound effect from the PaulsCode SoundSystem and the Mekanism SoundHandler
*/
public void remove()
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
if(isPlaying)
{
stopLoop();
}
MekanismClient.audioHandler.removeSound(objRef, channel); this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE);
if(SoundHandler.getSoundSystem() != null)
{
updateVolume();
SoundHandler.getSoundSystem().removeSource(identifier);
}
}
}
public String getSoundPath()
{
return prevSoundPath;
} }
public boolean update(World world) public Sound(String sound, float volume, float pitch, double x, double y, double z) {
{
if(!getSoundPath().equals(prevSoundPath)) this(sound, volume, pitch, false, 0, x, y, z);
{
return false;
}
return true;
} }
public abstract Pos3D getLocation(); public Sound(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) {
public float getMultiplier() this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR);
{
return doGradualEffect() ? Math.min(1, ((float)ticksSincePlay/30F)) : 1;
}
public boolean doGradualEffect()
{
return true;
} }
/** public Sound(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, AttenuationType attenuation) {
* Updates the volume based on how far away the player is from the machine.
* @param entityplayer - player who is near the machine, always Minecraft.thePlayer
*/
public void updateVolume()
{
synchronized(MekanismClient.audioHandler.soundMaps)
{
try {
float multiplier = getMultiplier();
float volume = 0;
float masterVolume = MekanismClient.audioHandler.getMasterVolume();
double distance = mc.thePlayer.getDistance(getLocation().xPos, getLocation().yPos, getLocation().zPos);
volume = (float)Math.min(Math.max(masterVolume-((distance*.08F)*masterVolume), 0)*multiplier, 1);
volume *= Math.max(0, Math.min(1, client.baseSoundVolume));
if(SoundHandler.getSoundSystem() != null) this(new ResourceLocation(sound), volume, pitch, repeat, repeatDelay, x, y, z, attenuation);
{
SoundHandler.getSoundSystem().setVolume(identifier, volume);
}
} catch(Exception e) {}
}
} }
public class DummySound implements ISound public Sound(ResourceLocation sound) {
{
@Override
public ResourceLocation getPositionedSoundLocation()
{
return new ResourceLocation("mekanism", "sound.ogg");
}
@Override this(sound, 0);
public boolean canRepeat()
{
return false;
}
@Override
public int getRepeatDelay()
{
return 0;
}
@Override
public float getVolume()
{
return 1;
}
@Override
public float getPitch()
{
return 0;
}
@Override
public float getXPosF()
{
return (float)getLocation().xPos;
}
@Override
public float getYPosF()
{
return (float)getLocation().yPos;
}
@Override
public float getZPosF()
{
return (float)getLocation().zPos;
}
@Override
public AttenuationType getAttenuationType()
{
return AttenuationType.LINEAR;
}
} }
public Sound(ResourceLocation sound, float volume) {
this(sound, volume, 0);
}
public Sound(ResourceLocation sound, float volume, float pitch) {
this(sound, volume, pitch, false, 0);
}
public Sound(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay) {
this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE);
}
public Sound(ResourceLocation sound, float volume, float pitch, double x, double y, double z) {
this(sound, volume, pitch, false, 0, x, y, z);
}
public Sound(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 Sound(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 Sound(Sound 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;
}
} }

View file

@ -1,36 +1,18 @@
package mekanism.client.sound; package mekanism.client.sound;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.client;
import mekanism.client.HolidayManager;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.ObfuscatedNames; import mekanism.common.ObfuscatedNames;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.ITickableSound;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.audio.SoundManager; import net.minecraft.client.audio.SoundManager;
import net.minecraft.tileentity.TileEntity; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkEvent;
import paulscode.sound.SoundSystem;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -43,319 +25,80 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class SoundHandler public class SoundHandler
{ {
/** All the sound references in the Minecraft game. */ public Map<String, Map<String, IResettableSound>> soundMaps = new HashMap<String, Map<String, IResettableSound>>();
public Map<Object, SoundMap> soundMaps = Collections.synchronizedMap(new HashMap<Object, SoundMap>());
public static Map<ISound, String> invPlayingSounds;
public static Minecraft mc = Minecraft.getMinecraft(); public static Minecraft mc = Minecraft.getMinecraft();
public static final String CHANNEL_TILE_DEFAULT = "tile";
public static final String CHANNEL_JETPACK = "jetpack";
public static final String CHANNEL_GASMASK = "gasMask";
public static final String CHANNEL_FLAMETHROWER = "flamethrower";
/** public enum Channel
* SoundHandler -- a class that handles all Sounds used by Mekanism.
*/
public SoundHandler()
{ {
MinecraftForge.EVENT_BUS.register(this); JETPACK("jetpack"),
GASMASK("gasMask"),
FLAMETHROWER("flamethrower");
Mekanism.logger.info("Successfully set up SoundHandler."); String channelName;
private Channel(String name)
{
channelName = name;
}
public String getName()
{
return channelName;
}
} }
public void preloadSounds() public boolean hasSound(EntityPlayer player, Channel channel)
{ {
CodeSource src = getClass().getProtectionDomain().getCodeSource(); String name = player.getCommandSenderName();
String corePath = src.getLocation().getFile().split("/mekanism/client")[0]; Map<String, IResettableSound> map = getMap(name);
List<String> listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sounds"); IResettableSound sound = map.get(channel.getName());
for(String s : listings) return sound != null;
}
public void addSound(EntityPlayer player, Channel channel, IResettableSound newSound, boolean replace)
{
String name = player.getCommandSenderName();
Map<String, IResettableSound> map = getMap(name);
IResettableSound sound = map.get(channel.getName());
if(sound == null || replace)
{ {
if(s.contains("etc") || s.contains("holiday")) map.put(channel.getName(), newSound);
}
}
public boolean playSound(EntityPlayer player, Channel channel)
{
String name = player.getCommandSenderName();
Map<String, IResettableSound> map = getMap(name);
IResettableSound sound = map.get(channel.getName());
if(sound != null)
{
if(sound.isDonePlaying() && !getSoundMap().containsKey(sound))
{ {
continue; sound.reset();
} Mekanism.logger.info("Playing sound " + sound);
playSound(sound);
if(s.contains("/mekanism/sounds/"))
{
s = s.split("/mekanism/sounds/")[1];
}
preloadSound(s);
}
Mekanism.logger.info("Preloaded " + listings.size() + " object sounds.");
if(client.holidays)
{
listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sounds/holiday");
for(String s : listings)
{
if(s.contains("/mekanism/sounds/"))
{
s = s.split("/mekanism/sounds/")[1];
}
if(!s.contains("holiday"))
{
s = "holiday/" + s;
}
preloadSound(s);
} }
return true;
} }
return false;
} }
private List<String> listFiles(String path, String s) public Map<String, IResettableSound> getMap(String name)
{ {
List<String> names = new ArrayList<String>(); Map<String, IResettableSound> map = soundMaps.get(name);
if(map == null)
File f = new File(path);
if(!f.exists())
{ {
return names; map = new HashMap<String, IResettableSound>();
soundMaps.put(name, map);
} }
return map;
if(!f.isDirectory())
{
try {
ZipInputStream zip = new ZipInputStream(new FileInputStream(path));
while(true)
{
ZipEntry e = zip.getNextEntry();
if(e == null)
{
break;
}
String name = e.getName();
if(name.contains(s) && name.endsWith(".ogg"))
{
names.add(name);
}
}
zip.close();
} catch(Exception e) {
e.printStackTrace();
}
}
else {
f = new File(path + "/" + s);
for(File file : f.listFiles())
{
if(file.getPath().contains(s) && file.getName().endsWith(".ogg"))
{
names.add(file.getName());
}
}
}
return names;
} }
private void preloadSound(String sound)
{
String id = "pre_" + sound;
URL url = getClass().getClassLoader().getResource("assets/mekanism/sounds/" + sound);
if(getSoundSystem() != null)
{
getSoundSystem().newSource(false, id, url, sound, true, 0, 0, 0, 0, 16F);
getSoundSystem().activate(id);
getSoundSystem().removeSource(id);
}
}
/**
* Ticks the sound handler. Should be called every Minecraft tick, or 20 times per second.
*/
public void onTick()
{
synchronized(soundMaps)
{
if(getSoundSystem() != null)
{
if(!Mekanism.proxy.isPaused())
{
ArrayList<Sound> soundsToRemove = new ArrayList<Sound>();
World world = FMLClientHandler.instance().getClient().theWorld;
if(FMLClientHandler.instance().getClient().thePlayer != null && world != null)
{
for(SoundMap map : soundMaps.values())
{
for(Sound sound : map)
{
if(!sound.update(world))
{
soundsToRemove.add(sound);
continue;
}
if(sound.isPlaying)
{
sound.updateVolume();
}
}
}
for(Sound sound : soundsToRemove)
{
sound.remove();
}
}
}
else {
for(SoundMap map : soundMaps.values())
{
map.stopLoops();
}
}
}
else {
Mekanism.proxy.unloadSoundHandler();
}
}
}
public void removeSound(Object ref, String channel)
{
if(soundMaps.get(ref) == null)
{
return;
}
soundMaps.get(ref).remove(channel);
if(soundMaps.get(ref).isEmpty())
{
soundMaps.remove(ref);
}
}
public void registerSound(Object ref, String channel, Sound sound)
{
if(soundMaps.get(ref) == null)
{
soundMaps.put(ref, new SoundMap(ref, channel, sound));
return;
}
soundMaps.get(ref).add(channel, sound);
}
/**
* Gets a sound object from a specific TileEntity, null if there is none.
* @param tileEntity - the holder of the sound
* @return Sound instance
*/
public SoundMap getMap(Object ref)
{
synchronized(soundMaps)
{
return soundMaps.get(ref);
}
}
public Sound getSound(Object ref, String channel)
{
if(soundMaps.get(ref) == null)
{
return null;
}
return soundMaps.get(ref).getSound(channel);
}
/**
* Create and return an instance of a Sound.
* @param tileEntity - the holder of this sound.
* @return Sound instance
*/
public void registerTileSound(TileEntity tile)
{
if(!(tile instanceof IHasSound))
{
return;
}
synchronized(soundMaps)
{
if(getMap(tile) == null)
{
new TileSound(getIdentifier(tile), HolidayManager.filterSound(((IHasSound)tile).getSoundPath()), CHANNEL_TILE_DEFAULT, tile);
}
}
}
/**
* Get a unique identifier for a sound effect instance by combining the mod's name,
* Mekanism, the new sound's unique position on the 'sounds' ArrayList, and a random
* number between 0 and 10,000. Example: "Mekanism_6_6123"
* @return unique identifier
*/
public String getIdentifier(Object obj)
{
synchronized(soundMaps)
{
String toReturn = "Mekanism_" + getActiveSize() + "_" + new Random().nextInt(10000);
return toReturn;
}
}
public int getActiveSize()
{
int count = 0;
for(SoundMap map : soundMaps.values())
{
count += map.size();
}
return count;
}
/**
* Plays a sound in a specific location.
* @param soundPath - sound path to play
* @param world - world to play in
* @param object - location to play
*/
public void quickPlay(String soundPath, World world, Coord4D object)
{
URL url = getClass().getClassLoader().getResource("assets/mekanism/sounds/" + soundPath);
if(url == null)
{
Mekanism.logger.info("Invalid sound file: " + soundPath);
}
String s = getSoundSystem().quickPlay(false, url, soundPath, false, object.xCoord, object.yCoord, object.zCoord, 0, 16F);
getSoundSystem().setVolume(s, getMasterVolume());
}
public float getMasterVolume()
{
return FMLClientHandler.instance().getClient().gameSettings.getSoundLevel(SoundCategory.MASTER);
}
public static SoundSystem getSoundSystem()
{
try {
return (SoundSystem)MekanismUtils.getPrivateValue(getSoundManager(), SoundManager.class, ObfuscatedNames.SoundManager_sndSystem);
} catch(Exception e) {
return null;
}
}
public static SoundManager getSoundManager() public static SoundManager getSoundManager()
{ {
try { try {
@ -364,44 +107,32 @@ public class SoundHandler
return null; return null;
} }
} }
public static boolean isSystemLoaded() //Fudge required because sound thread gets behind and the biMap crashes when rapidly toggling sounds.
public static Map<ISound, String> getSoundMap()
{ {
if(invPlayingSounds == null)
try { try {
return (Boolean)MekanismUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, new String[] {"loaded"}); invPlayingSounds = (Map<ISound, String>)MekanismUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, ObfuscatedNames.SoundManager_invPlayingSounds);
} catch(Exception e) { } catch(Exception e) {
return false; invPlayingSounds = null;
} }
return invPlayingSounds;
}
public static boolean canRestartSound(ITickableSound sound)
{
return sound.isDonePlaying() && !getSoundMap().containsKey(sound);
} }
public static void playSound(String sound) public static void playSound(String sound)
{ {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(sound), 1.0F)); playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(sound), 1.0F));
} }
@SubscribeEvent public static void playSound(ISound sound)
public void onChunkUnload(ChunkEvent.Unload event)
{ {
if(event.getChunk() != null) mc.getSoundHandler().playSound(sound);
{
for(Object obj : event.getChunk().chunkTileEntityMap.values())
{
if(obj instanceof TileEntity)
{
TileEntity tileEntity = (TileEntity)obj;
if(tileEntity instanceof IHasSound)
{
if(getMap(tileEntity) != null)
{
if(soundMaps.containsKey(tileEntity))
{
getMap(tileEntity).kill();
}
}
}
}
}
}
} }
} }

View file

@ -1,83 +0,0 @@
package mekanism.client.sound;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import mekanism.client.MekanismClient;
public class SoundMap implements Iterable<Sound>
{
public Map<String, Sound> soundMap = new HashMap<String, Sound>();
public Object objRef;
public SoundMap(Object obj)
{
objRef = obj;
}
public SoundMap(Object obj, String channel, Sound sound)
{
this(obj);
soundMap.put(channel, sound);
}
@Override
public Iterator<Sound> iterator()
{
return soundMap.values().iterator();
}
public Sound getSound(String channel)
{
return soundMap.get(channel);
}
public boolean hasSound(String channel)
{
return soundMap.containsKey(channel);
}
public void remove(String channel)
{
soundMap.remove(channel);
}
public void add(String channel, Sound sound)
{
soundMap.put(channel, sound);
}
public void stopLoops()
{
for(Sound sound : soundMap.values())
{
if(sound.isPlaying)
{
sound.stopLoop();
}
}
}
public void kill()
{
for(Sound sound : soundMap.values())
{
sound.remove();
}
MekanismClient.audioHandler.soundMaps.remove(objRef);
}
public boolean isEmpty()
{
return soundMap.isEmpty();
}
public int size()
{
return soundMap.size();
}
}

View file

@ -1,90 +1,103 @@
package mekanism.client.sound; package mekanism.client.sound;
import mekanism.api.Pos3D; import net.minecraft.util.ResourceLocation;
import mekanism.client.HolidayManager;
import mekanism.common.base.IActiveState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** public class TileSound extends Sound implements IResettableSound {
* Sound -- an object that is created in SoundHandler. A 'Sound' object runs off of
* PaulsCode's SoundSystem. It has several methods; play(), for looping the clip,
* stop(), for stopping the loop, remove(), for removing the sound from PaulsCode,
* and updateVolume() for updating the volume based on where the player is.
* @author AidanBrady
*
*/
@SideOnly(Side.CLIENT)
public class TileSound extends Sound
{
/** The TileEntity this sound is associated with. */
public TileEntity tileEntity;
/** IHasSound source;
* A sound that runs off of the PaulsCode sound system. boolean beginFadeOut;
* @param id - unique identifier boolean donePlaying = true;
* @param sound - bundled path to the sound int ticks = 0;
* @param tileentity - the tile this sound is playing from. int fadeIn = 50;
*/ int fadeOut = 50;
public TileSound(String id, String sound, String chan, TileEntity tileentity) float baseVolume = 1.0F;
public TileSound(IHasSound source, ISoundSource values)
{ {
super(id, sound, chan, tileentity, new Pos3D(tileentity)); this(source, values.getSoundLocation(), values.getVolume(), values.getPitch(), values.shouldRepeat(), values.getRepeatDelay(), values.getSoundPosition().xPos, values.getSoundPosition().yPos, values.getSoundPosition().zPos);
tileEntity = tileentity;
} }
@Override public TileSound(IHasSound source, String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) {
public float getMultiplier()
{ this(source, sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR);
return super.getMultiplier()*((IHasSound)tileEntity).getVolumeMultiplier();
} }
@Override public TileSound(IHasSound source, String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z,
public Pos3D getLocation() AttenuationType attenuation) {
{
return new Pos3D(tileEntity); this(source, new ResourceLocation(sound), volume, pitch, repeat, repeatDelay, x, y, z, attenuation);
} }
public TileSound(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 TileSound(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 TileSound setFadeIn(int fadeIn) {
this.fadeIn = Math.min(0, fadeIn);
return this;
}
public TileSound 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 @Override
public boolean update(World world) public void update() {
{
if(!super.update(world)) if (!beginFadeOut) {
{ if (ticks < fadeIn) {
return false; ticks++;
}
else if(!(tileEntity instanceof IHasSound))
{
return false;
}
else if(world.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity)
{
return false;
}
else if(!HolidayManager.filterSound(((IHasSound)tileEntity).getSoundPath()).equals(prevSoundPath))
{
return false;
}
else if(tileEntity instanceof IActiveState)
{
if(((IActiveState)tileEntity).getActive() != isPlaying)
{
if(((IActiveState)tileEntity).getActive())
{
play();
}
else {
stopLoop();
}
} }
if (!source.shouldPlaySound()) {
beginFadeOut = true;
ticks = 0;
}
} else {
ticks++;
} }
float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier();
volume = baseVolume * multiplier;
if(isPlaying) if (multiplier <= 0) {
{ donePlaying = true;
ticksSincePlay++;
} }
}
return true; @Override
public boolean isDonePlaying()
{
return donePlaying;
}
@Override
public void reset()
{
donePlaying = false;
beginFadeOut = false;
volume = baseVolume;
ticks = 0;
} }
} }

View file

@ -149,12 +149,6 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier"); GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier");
} }
/**
* Registers a client-side sound, assigned to a TileEntity.
* @param tileEntity - TileEntity who is registering the sound
*/
public void registerSound(TileEntity tileEntity) {}
/** /**
* Unregisters a client-side sound, assigned to a TileEntity; * Unregisters a client-side sound, assigned to a TileEntity;
* @param tileEntity - TileEntity who is unregistering the sound * @param tileEntity - TileEntity who is unregistering the sound

View file

@ -14,4 +14,5 @@ public final class ObfuscatedNames
public static String[] NetHandlerPlayServer_floatingTickCount = new String[] {"floatingTickCount", "field_147365_f"}; public static String[] NetHandlerPlayServer_floatingTickCount = new String[] {"floatingTickCount", "field_147365_f"};
public static String[] SoundHandler_sndManager = new String[] {"sndManager", "field_147694_f"}; public static String[] SoundHandler_sndManager = new String[] {"sndManager", "field_147694_f"};
public static String[] SoundManager_sndSystem = new String[] {"sndSystem", "field_148620_e"}; public static String[] SoundManager_sndSystem = new String[] {"sndSystem", "field_148620_e"};
public static String[] SoundManager_invPlayingSounds = new String[] {"invPlayingSounds", "field_148630_i"};
} }

View file

@ -14,6 +14,7 @@ import mekanism.api.util.StackUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
/** /**
@ -39,16 +40,16 @@ public interface IFactory
public static enum RecipeType public static enum RecipeType
{ {
SMELTING("smelting", "Smelter.ogg", MachineType.ENERGIZED_SMELTER.getStack(), false, null), SMELTING("smelting", "smelter", MachineType.ENERGIZED_SMELTER.getStack(), false, null),
ENRICHING("enriching", "Chamber.ogg", MachineType.ENRICHMENT_CHAMBER.getStack(), false, Recipe.ENRICHMENT_CHAMBER), ENRICHING("enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER.getStack(), false, Recipe.ENRICHMENT_CHAMBER),
CRUSHING("crushing", "Crusher.ogg", MachineType.CRUSHER.getStack(), false, Recipe.CRUSHER), CRUSHING("crushing", "crusher", MachineType.CRUSHER.getStack(), false, Recipe.CRUSHER),
COMPRESSING("compressing", "Compressor.ogg", MachineType.OSMIUM_COMPRESSOR.getStack(), true, Recipe.OSMIUM_COMPRESSOR), COMPRESSING("compressing", "compressor", MachineType.OSMIUM_COMPRESSOR.getStack(), true, Recipe.OSMIUM_COMPRESSOR),
COMBINING("combining", "Combiner.ogg", MachineType.COMBINER.getStack(), true, Recipe.COMBINER), COMBINING("combining", "combiner", MachineType.COMBINER.getStack(), true, Recipe.COMBINER),
PURIFYING("purifying", "PurificationChamber.ogg", MachineType.PURIFICATION_CHAMBER.getStack(), true, Recipe.PURIFICATION_CHAMBER), PURIFYING("purifying", "purifier", MachineType.PURIFICATION_CHAMBER.getStack(), true, Recipe.PURIFICATION_CHAMBER),
INJECTING("injecting", "ChemicalInjectionChamber.ogg", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, Recipe.CHEMICAL_INJECTION_CHAMBER); INJECTING("injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, Recipe.CHEMICAL_INJECTION_CHAMBER);
private String name; private String name;
private String sound; private ResourceLocation sound;
private ItemStack stack; private ItemStack stack;
private boolean usesFuel; private boolean usesFuel;
private Recipe recipe; private Recipe recipe;
@ -188,7 +189,7 @@ public interface IFactory
return MekanismUtils.localize("gui.factory." + name); return MekanismUtils.localize("gui.factory." + name);
} }
public String getSound() public ResourceLocation getSound()
{ {
return sound; return sound;
} }
@ -201,7 +202,7 @@ public interface IFactory
private RecipeType(String s, String s1, ItemStack is, boolean b, Recipe r) private RecipeType(String s, String s1, ItemStack is, boolean b, Recipe r)
{ {
name = s; name = s;
sound = s1; sound = new ResourceLocation("mekanism", s1);
stack = is; stack = is;
usesFuel = b; usesFuel = b;
recipe = r; recipe = r;

View file

@ -5,9 +5,9 @@ import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.Pos3D;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.client.sound.IHasSound;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
@ -20,15 +20,19 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.MekanismUtils; 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.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @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. */ /** This machine's side configuration. */
public byte[] sideConfig; public byte[] sideConfig;
@ -36,9 +40,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
/** An arraylist of SideData for this machine. */ /** An arraylist of SideData for this machine. */
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>(); public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
/** The bundled URL of this machine's sound effect */
public String soundURL;
/** How much energy this machine uses per tick. */ /** How much energy this machine uses per tick. */
public double ENERGY_PER_TICK; public double ENERGY_PER_TICK;
@ -80,10 +81,9 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
*/ */
public TileEntityBasicMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy) 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; ENERGY_PER_TICK = perTick;
TICKS_REQUIRED = ticksRequired; TICKS_REQUIRED = ticksRequired;
soundURL = soundPath;
guiLocation = location; guiLocation = location;
isActive = false; isActive = false;
} }
@ -93,19 +93,14 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{ {
super.onUpdate(); super.onUpdate();
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -291,18 +286,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
return facing; return facing;
} }
@Override
public String getSoundPath()
{
return soundURL;
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public boolean renderUpdate() public boolean renderUpdate()
{ {

View file

@ -29,7 +29,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyContainerItem; import cofh.api.energy.IEnergyContainerItem;
public class TileEntityChargepad extends TileEntityElectricBlock implements IActiveState, IHasSound public class TileEntityChargepad extends TileEntityNoisyElectricBlock
{ {
public boolean isActive; public boolean isActive;
@ -39,7 +39,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
public TileEntityChargepad() public TileEntityChargepad()
{ {
super("Chargepad", MachineType.CHARGEPAD.baseEnergy); super("chargepad", "Chargepad", MachineType.CHARGEPAD.baseEnergy);
inventory = new ItemStack[0]; inventory = new ItemStack[0];
} }
@ -51,8 +51,8 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
isActive = false; isActive = false;
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+0.2, zCoord+1)); List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 0.2, zCoord + 1));
for(EntityLivingBase entity : entities) for(EntityLivingBase entity : entities)
{ {
if(entity instanceof EntityPlayer || entity instanceof EntityRobit) if(entity instanceof EntityPlayer || entity instanceof EntityRobit)
@ -64,17 +64,16 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
{ {
if(entity instanceof EntityRobit) if(entity instanceof EntityRobit)
{ {
EntityRobit robit = (EntityRobit)entity; EntityRobit robit = (EntityRobit) entity;
double canGive = Math.min(getEnergy(), 1000); double canGive = Math.min(getEnergy(), 1000);
double toGive = Math.min(robit.MAX_ELECTRICITY-robit.getEnergy(), canGive); double toGive = Math.min(robit.MAX_ELECTRICITY - robit.getEnergy(), canGive);
robit.setEnergy(robit.getEnergy() + toGive); robit.setEnergy(robit.getEnergy() + toGive);
setEnergy(getEnergy() - toGive); setEnergy(getEnergy() - toGive);
} } else if(entity instanceof EntityPlayer)
else if(entity instanceof EntityPlayer)
{ {
EntityPlayer player = (EntityPlayer)entity; EntityPlayer player = (EntityPlayer) entity;
double prevEnergy = getEnergy(); double prevEnergy = getEnergy();
@ -107,13 +106,9 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
setActive(isActive); setActive(isActive);
} }
} }
else { else if(isActive)
Mekanism.proxy.registerSound(this); {
worldObj.spawnParticle("reddust", xCoord+random.nextDouble(), yCoord+0.15, zCoord+random.nextDouble(), 0, 0, 0);
if(isActive)
{
worldObj.spawnParticle("reddust", xCoord+random.nextDouble(), yCoord+0.15, zCoord+random.nextDouble(), 0, 0, 0);
}
} }
} }
@ -217,13 +212,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
} }
@Override @Override
public String getSoundPath() public float getVolume()
{
return "Chargepad.ogg";
}
@Override
public float getVolumeMultiplier()
{ {
return 0.4F; return 0.4F;
} }

View file

@ -41,7 +41,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; 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_GAS = 10000;
public static final int MAX_FLUID = 10000; public static final int MAX_FLUID = 10000;
@ -82,7 +82,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl
public TileEntityChemicalCrystallizer() 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.GREY, InventoryUtils.EMPTY));
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {0}));
@ -96,19 +96,14 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl
@Override @Override
public void onUpdate() public void onUpdate()
{ {
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -469,18 +464,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl
return InventoryUtils.EMPTY; return InventoryUtils.EMPTY;
} }
@Override
public String getSoundPath()
{
return "ChemicalCrystallizer.ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public ArrayList<SideData> getSideData() public ArrayList<SideData> getSideData()
{ {

View file

@ -34,7 +34,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; 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 injectTank = new GasTank(MAX_GAS);
public GasTank outputTank = new GasTank(MAX_GAS); public GasTank outputTank = new GasTank(MAX_GAS);
@ -65,26 +65,21 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc
public TileEntityChemicalDissolutionChamber() public TileEntityChemicalDissolutionChamber()
{ {
super("ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy); super("machine.dissolution", "ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy);
inventory = new ItemStack[5]; inventory = new ItemStack[5];
} }
@Override @Override
public void onUpdate() public void onUpdate()
{ {
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -396,18 +391,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc
MekanismUtils.saveChunk(this); MekanismUtils.saveChunk(this);
} }
@Override
public String getSoundPath()
{
return "ChemicalDissolutionChamber.ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer)
{ {

View file

@ -33,7 +33,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; 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 leftTank = new GasTank(MAX_GAS);
public GasTank rightTank = new GasTank(MAX_GAS); public GasTank rightTank = new GasTank(MAX_GAS);
@ -58,26 +58,21 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
public TileEntityChemicalInfuser() public TileEntityChemicalInfuser()
{ {
super("ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy); super("machine.cheminfuser", "ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy);
inventory = new ItemStack[4]; inventory = new ItemStack[4];
} }
@Override @Override
public void onUpdate() public void onUpdate()
{ {
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -315,21 +310,6 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
return null; 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 @Override
public void setActive(boolean active) public void setActive(boolean active)
{ {
@ -468,18 +448,6 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
return InventoryUtils.EMPTY; return InventoryUtils.EMPTY;
} }
@Override
public String getSoundPath()
{
return "ChemicalInfuser.ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public void writeSustainedData(ItemStack itemStack) public void writeSustainedData(ItemStack itemStack)
{ {

View file

@ -22,7 +22,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
{ {
public TileEntityChemicalInjectionChamber() 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 @Override

View file

@ -33,7 +33,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; 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); public GasTank gasTank = new GasTank(MAX_GAS);
@ -61,26 +61,21 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen
public TileEntityChemicalOxidizer() public TileEntityChemicalOxidizer()
{ {
super("ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy); super("machine.oxidiser", "ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy);
inventory = new ItemStack[4]; inventory = new ItemStack[4];
} }
@Override @Override
public void onUpdate() public void onUpdate()
{ {
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -295,11 +290,6 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen
return MekanismUtils.getMaxEnergy(this, MAX_ELECTRICITY); return MekanismUtils.getMaxEnergy(this, MAX_ELECTRICITY);
} }
public int getScaledGasLevel(int i)
{
return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_GAS : 0;
}
@Override @Override
public void setActive(boolean active) public void setActive(boolean active)
{ {
@ -351,18 +341,6 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen
MekanismUtils.saveChunk(this); MekanismUtils.saveChunk(this);
} }
@Override
public String getSoundPath()
{
return "ChemicalInfuser.ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public TileComponentUpgrade getComponent() public TileComponentUpgrade getComponent()
{ {

View file

@ -43,7 +43,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler; 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 FluidTank fluidTank = new FluidTank(MAX_FLUID);
public GasTank inputTank = new GasTank(MAX_GAS); public GasTank inputTank = new GasTank(MAX_GAS);
@ -71,26 +71,21 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements
public TileEntityChemicalWasher() public TileEntityChemicalWasher()
{ {
super("ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); super("washer", "ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy);
inventory = new ItemStack[4]; inventory = new ItemStack[4];
} }
@Override @Override
public void onUpdate() public void onUpdate()
{ {
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -533,18 +528,6 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements
return InventoryUtils.EMPTY; return InventoryUtils.EMPTY;
} }
@Override
public String getSoundPath()
{
return "ChemicalWasher.ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {

View file

@ -17,7 +17,7 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine
{ {
public TileEntityCombiner() public TileEntityCombiner()
{ {
super("Combiner.ogg", "Combiner", usage.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy); super("combiner", "Combiner", usage.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy);
} }
@Override @Override

View file

@ -8,41 +8,9 @@ import mekanism.common.recipe.RecipeHandler.Recipe;
public class TileEntityCrusher extends TileEntityElectricMachine public class TileEntityCrusher extends TileEntityElectricMachine
{ {
public float crushMatrix = 0;
public TileEntityCrusher() 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(crushMatrix < 6)
{
crushMatrix+=0.2F;
}
else {
crushMatrix = 0;
}
}
}
public float getMatrix()
{
float matrix = 0;
if(crushMatrix <= 3)
{
return crushMatrix;
}
else {
return 3 - (crushMatrix-3);
}
} }
@Override @Override
@ -52,7 +20,7 @@ public class TileEntityCrusher extends TileEntityElectricMachine
} }
@Override @Override
public float getVolumeMultiplier() public float getVolume()
{ {
return 0.5F; return 0.5F;
} }

View file

@ -13,7 +13,7 @@ public class TileEntityEnergizedSmelter extends TileEntityElectricMachine
public TileEntityEnergizedSmelter() public TileEntityEnergizedSmelter()
{ {
super("Smelter.ogg", "EnergizedSmelter", usage.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy); super("smelter", "EnergizedSmelter", usage.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy);
} }
@Override @Override

View file

@ -10,7 +10,7 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine
{ {
public TileEntityEnrichmentChamber() public TileEntityEnrichmentChamber()
{ {
super("Chamber.ogg", "EnrichmentChamber", usage.enrichmentChamberUsage, 200, MachineType.ENRICHMENT_CHAMBER.baseEnergy); super("enrichment", "EnrichmentChamber", usage.enrichmentChamberUsage, 200, MachineType.ENRICHMENT_CHAMBER.baseEnergy);
} }
@Override @Override
@ -20,7 +20,7 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine
} }
@Override @Override
public float getVolumeMultiplier() public float getVolume()
{ {
return 0.3F; return 0.3F;
} }

View file

@ -39,6 +39,7 @@ import mekanism.api.util.StackUtils;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
@ -47,7 +48,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @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. */ /** This Factory's tier. */
public FactoryTier tier; public FactoryTier tier;
@ -114,7 +115,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
public TileEntityFactory(FactoryTier type, MachineType machine) public TileEntityFactory(FactoryTier type, MachineType machine)
{ {
super(type.name + "Factory", machine.baseEnergy); super("null", type.name + "Factory", machine.baseEnergy);
tier = type; tier = type;
inventory = new ItemStack[5+type.processes*2]; inventory = new ItemStack[5+type.processes*2];
@ -129,19 +130,14 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
{ {
super.onUpdate(); super.onUpdate();
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -829,17 +825,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
} }
@Override @Override
public String getSoundPath() public ResourceLocation getSoundLocation()
{ {
return RecipeType.values()[recipeType].getSound(); return RecipeType.values()[recipeType].getSound();
} }
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public boolean renderUpdate() public boolean renderUpdate()
{ {

View file

@ -42,7 +42,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @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. */ /** This machine's side configuration. */
public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4}; public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4};
@ -88,7 +88,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
public TileEntityMetallurgicInfuser() 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.GREY, InventoryUtils.EMPTY));
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0}));
@ -106,19 +106,14 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
{ {
super.onUpdate(); super.onUpdate();
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -548,18 +543,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
return facing; return facing;
} }
@Override
public String getSoundPath()
{
return "MetallurgicInfuser.ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public boolean renderUpdate() public boolean renderUpdate()
{ {

View file

@ -0,0 +1,113 @@
package mekanism.common.tile;
import mekanism.api.Pos3D;
import mekanism.client.sound.IHasSound;
import mekanism.client.sound.IResettableSound;
import mekanism.client.sound.ISoundSource;
import mekanism.client.sound.SoundHandler;
import mekanism.client.sound.TileSound;
import mekanism.common.Upgrade;
import mekanism.common.base.IActiveState;
import mekanism.common.base.IUpgradeTile;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.ISound.AttenuationType;
import net.minecraft.util.ResourceLocation;
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 IResettableSound 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()
{
if(this instanceof IUpgradeTile)
{
float speedUpgrades = ((IUpgradeTile)this).getComponent().getUpgrades(Upgrade.SPEED);
return 1F + 20 * speedUpgrades / (float)Upgrade.SPEED.getMax();
}
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 TileSound(this, this);
}
@Override
public void onUpdate()
{
if(worldObj.isRemote && shouldPlaySound() && SoundHandler.canRestartSound(sound))
{
sound.reset();
SoundHandler.playSound(sound);
}
}
}

View file

@ -15,7 +15,7 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin
{ {
public TileEntityOsmiumCompressor() 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 @Override

View file

@ -51,7 +51,7 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
public TileEntityPRC() 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.GREY, InventoryUtils.EMPTY));
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0}));

View file

@ -12,7 +12,7 @@ public class TileEntityPrecisionSawmill extends TileEntityChanceMachine
{ {
public TileEntityPrecisionSawmill() 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 @Override
@ -22,7 +22,7 @@ public class TileEntityPrecisionSawmill extends TileEntityChanceMachine
} }
@Override @Override
public float getVolumeMultiplier() public float getVolume()
{ {
return 0.7F; return 0.7F;
} }

View file

@ -22,7 +22,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
{ {
public TileEntityPurificationChamber() 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 @Override

View file

@ -81,7 +81,7 @@ public class GuiWindTurbine extends GuiMekanism
int guiHeight = (height - ySize) / 2; int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); 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); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
} }

View file

@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import mekanism.api.MekanismConfig.generators; import mekanism.api.MekanismConfig.generators;
import mekanism.client.sound.TileSound;
import mekanism.common.FluidSlot; import mekanism.common.FluidSlot;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.MekanismItems; import mekanism.common.MekanismItems;
@ -23,23 +22,18 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData 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. */ /** The FluidSlot biofuel instance for this generator. */
public FluidSlot bioFuelSlot = new FluidSlot(24000, -1); public FluidSlot bioFuelSlot = new FluidSlot(24000, -1);
public TileEntityBioGenerator() public TileEntityBioGenerator()
{ {
super("BioGenerator", 160000, generators.bioGeneration*2); super("bio", "BioGenerator", 160000, generators.bioGeneration*2);
inventory = new ItemStack[2]; inventory = new ItemStack[2];
} }

View file

@ -39,7 +39,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
public TileEntityGasGenerator() 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]; inventory = new ItemStack[2];
fuelTank = new GasTank(MAX_GAS); fuelTank = new GasTank(MAX_GAS);
} }

View file

@ -9,13 +9,16 @@ import mekanism.api.Coord4D;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.client.sound.IHasSound; import mekanism.client.sound.IHasSound;
import mekanism.client.sound.ISoundSource;
import mekanism.client.sound.TileSound;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; 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.CableUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -27,7 +30,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @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. */ /** Output per tick this generator can transfer. */
public double output; public double output;
@ -49,9 +52,9 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
* @param name - full name of this generator * @param name - full name of this generator
* @param maxEnergy - how much energy this generator can store * @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()) if(MekanismUtils.useBuildCraft())
{ {
@ -68,19 +71,14 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
{ {
super.onUpdate(); super.onUpdate();
if(worldObj.isRemote) if(worldObj.isRemote && updateDelay > 0)
{ {
Mekanism.proxy.registerSound(this); updateDelay--;
if(updateDelay > 0) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay--; isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
} }
} }
@ -123,14 +121,11 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
} }
@Override @Override
public void invalidate() public void validate()
{ {
super.invalidate(); super.validate();
if(worldObj.isRemote) sound = new TileSound(this, this);
{
Mekanism.proxy.unregisterSound(this);
}
} }
/** /**
@ -239,18 +234,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
return INFINITE_EXTENT_AABB; return INFINITE_EXTENT_AABB;
} }
@Override
public String getSoundPath()
{
return fullName.replace("Advanced", "") + ".ogg";
}
@Override
public float getVolumeMultiplier()
{
return 1;
}
@Override @Override
public boolean renderUpdate() public boolean renderUpdate()
{ {

View file

@ -36,7 +36,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
public TileEntityHeatGenerator() public TileEntityHeatGenerator()
{ {
super("HeatGenerator", 160000, generators.heatGeneration*2); super("heat", "HeatGenerator", 160000, generators.heatGeneration*2);
inventory = new ItemStack[2]; inventory = new ItemStack[2];
} }

View file

@ -29,14 +29,13 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
public TileEntitySolarGenerator() public TileEntitySolarGenerator()
{ {
super("SolarGenerator", 96000, generators.solarGeneration*2); this("SolarGenerator", 96000, generators.solarGeneration*2);
GENERATION_RATE = generators.solarGeneration; GENERATION_RATE = generators.solarGeneration;
inventory = new ItemStack[1];
} }
public TileEntitySolarGenerator(String name, double maxEnergy, double output) public TileEntitySolarGenerator(String name, double maxEnergy, double output)
{ {
super(name, maxEnergy, output); super("solar", name, maxEnergy, output);
inventory = new ItemStack[1]; inventory = new ItemStack[1];
} }
@ -47,7 +46,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
} }
@Override @Override
public float getVolumeMultiplier() public float getVolume()
{ {
return 0.05F; return 0.05F;
} }

View file

@ -19,7 +19,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
public TileEntityWindTurbine() public TileEntityWindTurbine()
{ {
super("WindTurbine", 200000, (generators.windGenerationMax)*2); super("wind", "WindTurbine", 200000, (generators.windGenerationMax)*2);
inventory = new ItemStack[1]; inventory = new ItemStack[1];
} }
@ -67,7 +67,7 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound
} }
@Override @Override
public float getVolumeMultiplier() public float getVolume()
{ {
return 1.5F; return 1.5F;
} }

View file

@ -1,10 +1,49 @@
{ {
"etc.Beep": {"category": "master","sounds": [{"name": "etc/Beep","stream": false}]}, "etc.Beep": {"category": "master", "sounds": [{"name": "etc/Beep", "stream": false}]},
"etc.Click": {"category": "master","sounds": [{"name": "etc/Click","stream": false}]}, "etc.Click": {"category": "master", "sounds": [{"name": "etc/Click", "stream": false}]},
"etc.Ding": {"category": "master","sounds": [{"name": "etc/Ding","stream": false}]}, "etc.Ding": {"category": "master", "sounds": [{"name": "etc/Ding", "stream": false}]},
"etc.Error": {"category": "master","sounds": [{"name": "etc/Error","stream": false}]}, "etc.Error": {"category": "master", "sounds": [{"name": "etc/Error", "stream": false}]},
"etc.GasMask": {"category": "master","sounds": [{"name": "etc/GasMask","stream": false}]}, "etc.GasMask": {"category": "master", "sounds": [{"name": "etc/GasMask", "stream": false}]},
"etc.Hydraulic": {"category": "master","sounds": [{"name": "etc/Hydraulic","stream": false}]}, "etc.Hydraulic": {"category": "master", "sounds": [{"name": "etc/Hydraulic", "stream": false}]},
"etc.Pop": {"category": "master","sounds": [{"name": "etc/Pop","stream": false}]}, "etc.Pop": {"category": "master", "sounds": [{"name": "etc/Pop", "stream": false}]},
"etc.Success": {"category": "master","sounds": [{"name": "etc/Success","stream": false}]} "etc.Success": {"category": "master", "sounds": [{"name": "etc/Success", "stream": false}]},
"etc.cj": {"category": "block", "sounds": [
{"name": "cj/CJ_1", "stream": false},
{"name": "cj/CJ_2", "stream": false},
{"name": "cj/CJ_3", "stream": false},
{"name": "cj/CJ_4", "stream": false},
{"name": "cj/CJ_5", "stream": false},
{"name": "cj/CJ_6", "stream": false},
{"name": "cj/CJ_7", "stream": false},
{"name": "cj/CJ_8", "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}]},
"item.flamethrower.idle": {"category": "player", "sounds": [{"name": "FlamethrowerIdle", "stream": false}]},
"item.flamethrower.active": {"category": "player", "sounds": [{"name": "FlamethrowerActive", "stream": false}]},
"item.gasMask": {"category": "player", "sounds": [{"name": "GasMask", "stream": false}]},
"item.jetpack": {"category": "player", "sounds": [{"name": "Jetpack", "stream": false}]}
} }