mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Add operating sounds to large and chungus turbines
This commit is contained in:
parent
c6450d78b2
commit
13afe67eb3
@ -14,8 +14,10 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.fluid.trait.FT_Coolable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.packet.NBTPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.sound.AudioWrapper;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
@ -50,11 +52,16 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
||||
|
||||
public FluidTank[] tanks;
|
||||
|
||||
private AudioWrapper audio;
|
||||
private float audioDesync;
|
||||
|
||||
public TileEntityChungus() {
|
||||
|
||||
tanks = new FluidTank[2];
|
||||
tanks[0] = new FluidTank(Fluids.STEAM, 1000000000, 0);
|
||||
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 1000000000, 1);
|
||||
|
||||
Random rand = new Random();
|
||||
audioDesync = rand.nextFloat() * 0.05F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,9 +126,9 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
||||
}
|
||||
|
||||
if(turnTimer > 0) {
|
||||
|
||||
this.fanAcceleration = Math.max(0F, Math.min(25F, this.fanAcceleration += 0.1F));
|
||||
|
||||
// Fan accelerates with a random offset to ensure the audio doesn't perfectly align, makes for a more pleasant hum
|
||||
this.fanAcceleration = Math.max(0F, Math.min(25F, this.fanAcceleration += 0.075F + audioDesync));
|
||||
|
||||
Random rand = worldObj.rand;
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection side = dir.getRotation(ForgeDirection.UP);
|
||||
@ -133,9 +140,29 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
||||
zCoord + 0.5 + dir.offsetZ * (rand.nextDouble() + 1.25) + rand.nextGaussian() * side.offsetZ * 0.65,
|
||||
-dir.offsetX * 0.2, 0, -dir.offsetZ * 0.2);
|
||||
}
|
||||
}
|
||||
if(turnTimer < 0) {
|
||||
|
||||
|
||||
if(audio == null) {
|
||||
audio = MainRegistry.proxy.getLoopedSound("hbm:block.chungusTurbineRunning", xCoord, yCoord, zCoord, 1.0F, 20F, 1.0F);
|
||||
audio.startSound();
|
||||
}
|
||||
|
||||
float turbineSpeed = this.fanAcceleration / 25F;
|
||||
audio.updateVolume(getVolume(0.5f * turbineSpeed));
|
||||
audio.updatePitch(0.25F + 0.75F * turbineSpeed);
|
||||
} else {
|
||||
this.fanAcceleration = Math.max(0F, Math.min(25F, this.fanAcceleration -= 0.1F));
|
||||
|
||||
if(audio != null) {
|
||||
if(this.fanAcceleration > 0) {
|
||||
float turbineSpeed = this.fanAcceleration / 25F;
|
||||
audio.updateVolume(getVolume(0.5f * turbineSpeed));
|
||||
audio.updatePitch(0.25F + 0.75F * turbineSpeed);
|
||||
} else {
|
||||
audio.stopSound();
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,6 +313,24 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
||||
public String getComponentName() {
|
||||
return "ntm_turbine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if(audio != null) {
|
||||
audio.stopSound();
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(audio != null) {
|
||||
audio.stopSound();
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Callback(direct = true)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.handler.CompatHandler;
|
||||
@ -16,6 +17,8 @@ import com.hbm.inventory.fluid.trait.FT_Coolable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
|
||||
import com.hbm.inventory.gui.GUIMachineLargeTurbine;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.sound.AudioWrapper;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
@ -51,6 +54,9 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
||||
public float rotor;
|
||||
public float lastRotor;
|
||||
public float fanAcceleration = 0F;
|
||||
|
||||
private AudioWrapper audio;
|
||||
private float audioDesync;
|
||||
|
||||
public TileEntityMachineLargeTurbine() {
|
||||
super(7);
|
||||
@ -58,6 +64,9 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
||||
tanks = new FluidTank[2];
|
||||
tanks[0] = new FluidTank(Fluids.STEAM, 512000, 0);
|
||||
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 10240000, 1);
|
||||
|
||||
Random rand = new Random();
|
||||
audioDesync = rand.nextFloat() * 0.05F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,11 +138,30 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
||||
}
|
||||
|
||||
if(shouldTurn) {
|
||||
// Fan accelerates with a random offset to ensure the audio doesn't perfectly align, makes for a more pleasant hum
|
||||
this.fanAcceleration = Math.max(0F, Math.min(15F, this.fanAcceleration += 0.075F + audioDesync));
|
||||
|
||||
this.fanAcceleration = Math.max(0F, Math.min(15F, this.fanAcceleration += 0.1F));
|
||||
}
|
||||
if(!shouldTurn) {
|
||||
if(audio == null) {
|
||||
audio = MainRegistry.proxy.getLoopedSound("hbm:block.largeTurbineRunning", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F);
|
||||
audio.startSound();
|
||||
}
|
||||
|
||||
float turbineSpeed = this.fanAcceleration / 15F;
|
||||
audio.updateVolume(getVolume(0.4f * turbineSpeed));
|
||||
audio.updatePitch(0.25F + 0.75F * turbineSpeed);
|
||||
} else {
|
||||
this.fanAcceleration = Math.max(0F, Math.min(15F, this.fanAcceleration -= 0.1F));
|
||||
|
||||
if(audio != null) {
|
||||
if(this.fanAcceleration > 0) {
|
||||
float turbineSpeed = this.fanAcceleration / 15F;
|
||||
audio.updateVolume(getVolume(0.4f * turbineSpeed));
|
||||
audio.updatePitch(0.25F + 0.75F * turbineSpeed);
|
||||
} else {
|
||||
audio.stopSound();
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,6 +321,24 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
||||
public String getComponentName() {
|
||||
return "ntm_turbine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if(audio != null) {
|
||||
audio.stopSound();
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(audio != null) {
|
||||
audio.stopSound();
|
||||
audio = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Callback(direct = true)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
|
||||
@ -51,6 +51,8 @@
|
||||
"block.turbinegasStartup": {"category": "block", "sounds": [{"name": "block/turbinegasStartup", "stream": true}]},
|
||||
"block.turbinegasRunning": {"category": "block", "sounds": [{"name": "block/turbinegasRunning", "stream": false}]},
|
||||
"block.turbinegasShutdown": {"category": "block", "sounds": [{"name": "block/turbinegasShutdown", "stream": true}]},
|
||||
"block.chungusTurbineRunning": {"category": "block", "sounds": [{"name": "block/chungusTurbine", "stream": false}]},
|
||||
"block.largeTurbineRunning": {"category": "block", "sounds": [{"name": "block/largeTurbine", "stream": false}]},
|
||||
"block.damage": {"category": "block", "sounds": ["block/dam1", "block/dam2", "block/dam3", "block/dam4"]},
|
||||
"block.electricHum": {"category": "block", "sounds": [{"name": "block/electricHum", "stream": false}]},
|
||||
"block.boiler": {"category": "block", "sounds": [{"name": "block/boiler", "stream": false}]},
|
||||
|
||||
BIN
src/main/resources/assets/hbm/sounds/block/chungusTurbine.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/chungusTurbine.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/hbm/sounds/block/largeTurbine.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/largeTurbine.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user