diff --git a/resources/assets/resonantinduction/sound/electricshock1.ogg b/resources/assets/resonantinduction/sound/electricshock1.ogg new file mode 100644 index 00000000..d7356d4b Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock1.ogg differ diff --git a/resources/assets/resonantinduction/sound/electricshock2.ogg b/resources/assets/resonantinduction/sound/electricshock2.ogg new file mode 100644 index 00000000..84ff1999 Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock2.ogg differ diff --git a/resources/assets/resonantinduction/sound/electricshock3.ogg b/resources/assets/resonantinduction/sound/electricshock3.ogg new file mode 100644 index 00000000..83b527b5 Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock3.ogg differ diff --git a/resources/assets/resonantinduction/sound/electricshock4.ogg b/resources/assets/resonantinduction/sound/electricshock4.ogg new file mode 100644 index 00000000..06393882 Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock4.ogg differ diff --git a/resources/assets/resonantinduction/sound/electricshock5.ogg b/resources/assets/resonantinduction/sound/electricshock5.ogg new file mode 100644 index 00000000..5b16eb5f Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock5.ogg differ diff --git a/resources/assets/resonantinduction/sound/electricshock6.ogg b/resources/assets/resonantinduction/sound/electricshock6.ogg new file mode 100644 index 00000000..5784b116 Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock6.ogg differ diff --git a/resources/assets/resonantinduction/sound/electricshock7.ogg b/resources/assets/resonantinduction/sound/electricshock7.ogg new file mode 100644 index 00000000..6a1868ea Binary files /dev/null and b/resources/assets/resonantinduction/sound/electricshock7.ogg differ diff --git a/src/resonantinduction/ClientProxy.java b/src/resonantinduction/ClientProxy.java index 285d40b5..f4a2779f 100644 --- a/src/resonantinduction/ClientProxy.java +++ b/src/resonantinduction/ClientProxy.java @@ -5,6 +5,7 @@ package resonantinduction; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import resonantinduction.base.Vector3; import resonantinduction.contractor.TileEntityEMContractor; import resonantinduction.fx.FXElectricBolt; @@ -28,8 +29,10 @@ public class ClientProxy extends CommonProxy @Override public void registerRenderers() { + MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE); + RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE); - + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor()); } diff --git a/src/resonantinduction/SoundHandler.java b/src/resonantinduction/SoundHandler.java new file mode 100644 index 00000000..adf3408d --- /dev/null +++ b/src/resonantinduction/SoundHandler.java @@ -0,0 +1,32 @@ +/** + * + */ +package resonantinduction; + +import net.minecraftforge.client.event.sound.SoundLoadEvent; +import net.minecraftforge.event.ForgeSubscribe; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * @author Calclavia + * + */ +@SideOnly(Side.CLIENT) +public class SoundHandler +{ + public static final SoundHandler INSTANCE = new SoundHandler(); + + public static final String[] SOUND_FILES = { "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg" }; + + @ForgeSubscribe + public void loadSoundEvents(SoundLoadEvent event) + { + for (int i = 0; i < SOUND_FILES.length; i++) + { + event.manager.soundPoolSounds.addSound(ResonantInduction.PREFIX + SOUND_FILES[i]); + } + + ResonantInduction.LOGGER.fine("Loaded sound fxs"); + } +} diff --git a/src/resonantinduction/tesla/TileEntityTesla.java b/src/resonantinduction/tesla/TileEntityTesla.java index 4f246697..fbc1e5cb 100644 --- a/src/resonantinduction/tesla/TileEntityTesla.java +++ b/src/resonantinduction/tesla/TileEntityTesla.java @@ -78,8 +78,10 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe for (ITesla tesla : transferTeslaCoils) { - tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f))); - this.transfer(-transferEnergy); + if (this.ticks % 20 == 0) + { + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergyStored() / 10, (float) (1 - 0.2 * (this.dyeID / 16))); + } Vector3 teslaVector = new Vector3((TileEntity) tesla); @@ -89,6 +91,9 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe } ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this.getTopTelsa()).translate(new Vector3(0.5)), teslaVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z); + + tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f))); + this.transfer(-transferEnergy); } } }