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;
|
||||||
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
|
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
|
||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.packet.NBTPacket;
|
import com.hbm.packet.NBTPacket;
|
||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
|
import com.hbm.sound.AudioWrapper;
|
||||||
import com.hbm.tileentity.INBTPacketReceiver;
|
import com.hbm.tileentity.INBTPacketReceiver;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
@ -50,11 +52,16 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
|
|
||||||
public FluidTank[] tanks;
|
public FluidTank[] tanks;
|
||||||
|
|
||||||
public TileEntityChungus() {
|
private AudioWrapper audio;
|
||||||
|
private float audioDesync;
|
||||||
|
|
||||||
|
public TileEntityChungus() {
|
||||||
tanks = new FluidTank[2];
|
tanks = new FluidTank[2];
|
||||||
tanks[0] = new FluidTank(Fluids.STEAM, 1000000000, 0);
|
tanks[0] = new FluidTank(Fluids.STEAM, 1000000000, 0);
|
||||||
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 1000000000, 1);
|
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 1000000000, 1);
|
||||||
|
|
||||||
|
Random rand = new Random();
|
||||||
|
audioDesync = rand.nextFloat() * 0.05F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -119,8 +126,8 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(turnTimer > 0) {
|
if(turnTimer > 0) {
|
||||||
|
// 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.1F));
|
this.fanAcceleration = Math.max(0F, Math.min(25F, this.fanAcceleration += 0.075F + audioDesync));
|
||||||
|
|
||||||
Random rand = worldObj.rand;
|
Random rand = worldObj.rand;
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
@ -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,
|
zCoord + 0.5 + dir.offsetZ * (rand.nextDouble() + 1.25) + rand.nextGaussian() * side.offsetZ * 0.65,
|
||||||
-dir.offsetX * 0.2, 0, -dir.offsetZ * 0.2);
|
-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));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,6 +314,24 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
return "ntm_turbine";
|
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)
|
@Callback(direct = true)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getFluid(Context context, Arguments args) {
|
public Object[] getFluid(Context context, Arguments args) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.hbm.tileentity.machine;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.handler.CompatHandler;
|
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.fluid.trait.FT_Coolable.CoolingType;
|
||||||
import com.hbm.inventory.gui.GUIMachineLargeTurbine;
|
import com.hbm.inventory.gui.GUIMachineLargeTurbine;
|
||||||
import com.hbm.lib.Library;
|
import com.hbm.lib.Library;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
|
import com.hbm.sound.AudioWrapper;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
@ -52,12 +55,18 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
|||||||
public float lastRotor;
|
public float lastRotor;
|
||||||
public float fanAcceleration = 0F;
|
public float fanAcceleration = 0F;
|
||||||
|
|
||||||
|
private AudioWrapper audio;
|
||||||
|
private float audioDesync;
|
||||||
|
|
||||||
public TileEntityMachineLargeTurbine() {
|
public TileEntityMachineLargeTurbine() {
|
||||||
super(7);
|
super(7);
|
||||||
|
|
||||||
tanks = new FluidTank[2];
|
tanks = new FluidTank[2];
|
||||||
tanks[0] = new FluidTank(Fluids.STEAM, 512000, 0);
|
tanks[0] = new FluidTank(Fluids.STEAM, 512000, 0);
|
||||||
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 10240000, 1);
|
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 10240000, 1);
|
||||||
|
|
||||||
|
Random rand = new Random();
|
||||||
|
audioDesync = rand.nextFloat() * 0.05F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -129,11 +138,30 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(shouldTurn) {
|
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(audio == null) {
|
||||||
}
|
audio = MainRegistry.proxy.getLoopedSound("hbm:block.largeTurbineRunning", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F);
|
||||||
if(!shouldTurn) {
|
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));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,6 +322,24 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
|
|||||||
return "ntm_turbine";
|
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)
|
@Callback(direct = true)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getFluid(Context context, Arguments args) {
|
public Object[] getFluid(Context context, Arguments args) {
|
||||||
|
|||||||
@ -51,6 +51,8 @@
|
|||||||
"block.turbinegasStartup": {"category": "block", "sounds": [{"name": "block/turbinegasStartup", "stream": true}]},
|
"block.turbinegasStartup": {"category": "block", "sounds": [{"name": "block/turbinegasStartup", "stream": true}]},
|
||||||
"block.turbinegasRunning": {"category": "block", "sounds": [{"name": "block/turbinegasRunning", "stream": false}]},
|
"block.turbinegasRunning": {"category": "block", "sounds": [{"name": "block/turbinegasRunning", "stream": false}]},
|
||||||
"block.turbinegasShutdown": {"category": "block", "sounds": [{"name": "block/turbinegasShutdown", "stream": true}]},
|
"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.damage": {"category": "block", "sounds": ["block/dam1", "block/dam2", "block/dam3", "block/dam4"]},
|
||||||
"block.electricHum": {"category": "block", "sounds": [{"name": "block/electricHum", "stream": false}]},
|
"block.electricHum": {"category": "block", "sounds": [{"name": "block/electricHum", "stream": false}]},
|
||||||
"block.boiler": {"category": "block", "sounds": [{"name": "block/boiler", "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