mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-11 12:15:35 +00:00
now with sound
This commit is contained in:
parent
12e8da8750
commit
ec076fb97a
@ -51,3 +51,4 @@
|
|||||||
* Fixed constant cascading chunk gen caused by meteorites and flower patches
|
* Fixed constant cascading chunk gen caused by meteorites and flower patches
|
||||||
* Fixed garbage loot pool sometimes producing "stone wires"
|
* Fixed garbage loot pool sometimes producing "stone wires"
|
||||||
* Fixed mining lasers targeting blocks with the "gas" material
|
* Fixed mining lasers targeting blocks with the "gas" material
|
||||||
|
* Fixed gun looping sounds behaving weird when moving while firing
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.hbm.main.MainRegistry;
|
|||||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||||
import com.hbm.particle.SpentCasing;
|
import com.hbm.particle.SpentCasing;
|
||||||
import com.hbm.particle.helper.CasingCreator;
|
import com.hbm.particle.helper.CasingCreator;
|
||||||
|
import com.hbm.render.anim.HbmAnimations;
|
||||||
import com.hbm.render.anim.AnimationEnums.GunAnimation;
|
import com.hbm.render.anim.AnimationEnums.GunAnimation;
|
||||||
import com.hbm.sound.AudioWrapper;
|
import com.hbm.sound.AudioWrapper;
|
||||||
import com.hbm.util.EntityDamageUtil;
|
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);
|
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);
|
ItemGunBaseNT.loopedSounds.put(entity, audio);
|
||||||
audio.startSound();
|
audio.startSound();
|
||||||
|
audio.attachTo(entity);
|
||||||
}
|
}
|
||||||
//keepalive
|
//keepalive
|
||||||
if(runningAudio != null && runningAudio.isPlaying()) {
|
if(runningAudio != null && runningAudio.isPlaying()) {
|
||||||
runningAudio.keepAlive();
|
runningAudio.keepAlive();
|
||||||
runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ);
|
runningAudio.attachTo(entity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//stop sound due to timeout
|
//stop sound due to timeout
|
||||||
@ -1188,10 +1190,11 @@ public class Orchestras {
|
|||||||
audio.updatePitch(0.75F);
|
audio.updatePitch(0.75F);
|
||||||
ItemGunBaseNT.loopedSounds.put(entity, audio);
|
ItemGunBaseNT.loopedSounds.put(entity, audio);
|
||||||
audio.startSound();
|
audio.startSound();
|
||||||
|
audio.attachTo(entity);
|
||||||
}
|
}
|
||||||
if(runningAudio != null && runningAudio.isPlaying()) {
|
if(runningAudio != null && runningAudio.isPlaying()) {
|
||||||
runningAudio.keepAlive();
|
runningAudio.keepAlive();
|
||||||
runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ);
|
runningAudio.attachTo(entity);
|
||||||
runningAudio.updatePitch(0.75F + timer * 0.01F);
|
runningAudio.updatePitch(0.75F + timer * 0.01F);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1519,4 +1522,51 @@ public class Orchestras {
|
|||||||
if(timer == 40) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.boltClose", 1F, 1F);
|
if(timer == 40) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.boltClose", 1F, 1F);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static BiConsumer<ItemStack, LambdaContext> 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class XFactoryDrill {
|
|||||||
.offset(1, -0.0625 * 2.5, -0.25D)
|
.offset(1, -0.0625 * 2.5, -0.25D)
|
||||||
.canFire(Lego.LAMBDA_STANDARD_CAN_FIRE).fire(LAMBDA_DRILL_FIRE))
|
.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)
|
.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");
|
).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));
|
.addBus("EQUIP", new BusAnimationSequence().setPos(-1, 0, 0).addPos(0, 0, 0, 750, IType.SIN_DOWN));
|
||||||
case CYCLE:
|
case CYCLE:
|
||||||
double deploy = HbmAnimations.getRelevantTransformation("DEPLOY")[0];
|
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
|
double spin = HbmAnimations.getRelevantTransformation("SPIN")[0] % 360; // seamlessly continue from the previous animation state
|
||||||
return new BusAnimation()
|
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("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()
|
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("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()
|
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));
|
.addBus("LIFT", new BusAnimationSequence().addPos(-45, 0, 0, 500, IType.SIN_FULL).hold(1000).addPos(0, 0, 0, 500, IType.SIN_DOWN));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class AudioDynamic extends MovingSound {
|
|||||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||||
float f = 0;
|
float f = 0;
|
||||||
|
|
||||||
if(parentEntity != null) {
|
if(parentEntity != null && player != parentEntity) {
|
||||||
this.setPosition((float) parentEntity.posX, (float) parentEntity.posY, (float) parentEntity.posZ);
|
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));
|
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);
|
volume = func(f);
|
||||||
} else {
|
} 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;
|
volume = maxVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user