diff --git a/changelog b/changelog index 990dda0b8..000d45b97 100644 --- a/changelog +++ b/changelog @@ -50,4 +50,5 @@ * Fixed crash caused when another tile entity replaces an RBMK component due to an unchecked cast * Fixed constant cascading chunk gen caused by meteorites and flower patches * Fixed garbage loot pool sometimes producing "stone wires" -* Fixed mining lasers targeting blocks with the "gas" material \ No newline at end of file +* Fixed mining lasers targeting blocks with the "gas" material +* Fixed gun looping sounds behaving weird when moving while firing diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index 0f96b5e87..0192bb059 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -17,6 +17,7 @@ import com.hbm.main.MainRegistry; import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.particle.SpentCasing; import com.hbm.particle.helper.CasingCreator; +import com.hbm.render.anim.HbmAnimations; import com.hbm.render.anim.AnimationEnums.GunAnimation; import com.hbm.sound.AudioWrapper; import com.hbm.util.EntityDamageUtil; @@ -820,11 +821,12 @@ public class Orchestras { AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) entity.posX, (float) entity.posY, (float) entity.posZ, 1F, 15F, 1F, 10); ItemGunBaseNT.loopedSounds.put(entity, audio); audio.startSound(); + audio.attachTo(entity); } //keepalive if(runningAudio != null && runningAudio.isPlaying()) { runningAudio.keepAlive(); - runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ); + runningAudio.attachTo(entity); } } else { //stop sound due to timeout @@ -1188,10 +1190,11 @@ public class Orchestras { audio.updatePitch(0.75F); ItemGunBaseNT.loopedSounds.put(entity, audio); audio.startSound(); + audio.attachTo(entity); } if(runningAudio != null && runningAudio.isPlaying()) { runningAudio.keepAlive(); - runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ); + runningAudio.attachTo(entity); runningAudio.updatePitch(0.75F + timer * 0.01F); } } else { @@ -1519,4 +1522,51 @@ public class Orchestras { if(timer == 40) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.boltClose", 1F, 1F); } }; + + public static BiConsumer ORCHESTRA_DRILL = (stack, ctx) -> { + EntityLivingBase entity = ctx.entity; + GunAnimation type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); + int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); + + if(entity.worldObj.isRemote) { + double speed = HbmAnimations.getRelevantTransformation("SPEED")[0]; + + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); + + if(speed > 0) { + //start sound + if(runningAudio == null || !runningAudio.isPlaying()) { + boolean electric = XWeaponModManager.hasUpgrade(stack, ctx.configIndex, XWeaponModManager.ID_ENGINE_ELECTRIC); + AudioWrapper audio = MainRegistry.proxy.getLoopedSound(electric ? "hbm:block.largeTurbineRunning" : "hbm:block.engine", (float) entity.posX, (float) entity.posY, (float) entity.posZ, (float) speed, 15F, (float) speed, 25); + ItemGunBaseNT.loopedSounds.put(entity, audio); + audio.startSound(); + audio.attachTo(entity); + } + //keepalive + if(runningAudio != null && runningAudio.isPlaying()) { + runningAudio.keepAlive(); + runningAudio.updateVolume((float) speed); + runningAudio.updatePitch((float) speed); + } + } else { + //stop sound due to timeout + //if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound(); + // for some reason this causes stutters, even though speed shouldn't be 0 then + } + } + //stop sound due to state change + if(type != GunAnimation.CYCLE && type != GunAnimation.CYCLE_DRY && entity.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); + if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound(); + } + if(entity.worldObj.isRemote) return; + + if(type == GunAnimation.RELOAD) { + if(timer == 15) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.openLatch", 1F, 1F); + if(timer == 35) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.impact", 0.5F, 1F); + if(timer == 60) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.75F); + if(timer == 70) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.insertCanister", 1F, 1F); + if(timer == 85) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pressureValve", 1F, 1F); + } + }; } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryDrill.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryDrill.java index cf343708d..3c877da90 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryDrill.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryDrill.java @@ -57,7 +57,7 @@ public class XFactoryDrill { .offset(1, -0.0625 * 2.5, -0.25D) .canFire(Lego.LAMBDA_STANDARD_CAN_FIRE).fire(LAMBDA_DRILL_FIRE)) .pp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY).pr(Lego.LAMBDA_STANDARD_RELOAD).decider(GunStateDecider.LAMBDA_STANDARD_DECIDER) - .anim(LAMBDA_DRILL_ANIMS) + .anim(LAMBDA_DRILL_ANIMS).orchestra(Orchestras.ORCHESTRA_DRILL) ).setUnlocalizedName("gun_drill"); } @@ -132,13 +132,16 @@ public class XFactoryDrill { .addBus("EQUIP", new BusAnimationSequence().setPos(-1, 0, 0).addPos(0, 0, 0, 750, IType.SIN_DOWN)); case CYCLE: double deploy = HbmAnimations.getRelevantTransformation("DEPLOY")[0]; + double speed = HbmAnimations.getRelevantTransformation("SPEED")[0]; double spin = HbmAnimations.getRelevantTransformation("SPIN")[0] % 360; // seamlessly continue from the previous animation state return new BusAnimation() .addBus("DEPLOY", new BusAnimationSequence().setPos(deploy, 0, 0).addPos(1, 0, 0, (int) (500 * (1 - deploy)), IType.SIN_FULL).hold(1000).addPos(0, 0, 0, 500, IType.SIN_FULL)) - .addBus("SPIN", new BusAnimationSequence().setPos(spin, 0, 0).addPos(spin + 360 * 1.5, 0, 0, 1500).addPos(spin + 360 * 2, 0, 0, 750, IType.SIN_DOWN)); + .addBus("SPIN", new BusAnimationSequence().setPos(spin, 0, 0).addPos(spin + 360 * 1.5, 0, 0, 1500).addPos(360 * 3, 0, 0, 750 + (int) (1000 * (1D - spin / 360D)), IType.SIN_DOWN)) + .addBus("SPEED", new BusAnimationSequence().setPos(speed, 0, 0).addPos(1, 0, 0, 500).hold(1000).addPos(0, 0, 0, 750 + (int) (1000 * (1D - spin / 360D)), IType.SIN_DOWN)); case CYCLE_DRY: return new BusAnimation() .addBus("DEPLOY", new BusAnimationSequence().addPos(0.25, 0, 0, 250, IType.SIN_FULL).addPos(0, 0, 0, 250, IType.SIN_FULL)) - .addBus("SPIN", new BusAnimationSequence().addPos(360 * 1, 0, 0, 1500, IType.SIN_DOWN)); + .addBus("SPIN", new BusAnimationSequence().addPos(360 * 1, 0, 0, 1500, IType.SIN_DOWN)) + .addBus("SPEED", new BusAnimationSequence().addPos(0.75, 0, 0, 250).addPos(0, 0, 0, 1000, IType.SIN_DOWN)); case INSPECT: return new BusAnimation() .addBus("LIFT", new BusAnimationSequence().addPos(-45, 0, 0, 500, IType.SIN_FULL).hold(1000).addPos(0, 0, 0, 500, IType.SIN_DOWN)); } diff --git a/src/main/java/com/hbm/sound/AudioDynamic.java b/src/main/java/com/hbm/sound/AudioDynamic.java index a3bf973db..547a7be0d 100644 --- a/src/main/java/com/hbm/sound/AudioDynamic.java +++ b/src/main/java/com/hbm/sound/AudioDynamic.java @@ -44,7 +44,7 @@ public class AudioDynamic extends MovingSound { EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; float f = 0; - if(parentEntity != null) { + if(parentEntity != null && player != parentEntity) { this.setPosition((float) parentEntity.posX, (float) parentEntity.posY, (float) parentEntity.posZ); } @@ -53,6 +53,8 @@ public class AudioDynamic extends MovingSound { f = (float)Math.sqrt(Math.pow(xPosF - player.posX, 2) + Math.pow(yPosF - player.posY, 2) + Math.pow(zPosF - player.posZ, 2)); volume = func(f); } else { + // shitty hack that prevents stereo weirdness when using 0 0 0 + if(player == parentEntity) this.setPosition((float) parentEntity.posX, (float) parentEntity.posY + 10, (float) parentEntity.posZ); volume = maxVolume; }