turbine temperature tweaks

This commit is contained in:
Boblet 2023-02-15 16:55:06 +01:00
parent 90b7ee2ab7
commit 344dd55dfa

View File

@ -37,8 +37,8 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
public long power; public long power;
public static final long maxPower = 1000000L; public static final long maxPower = 1000000L;
public int rpm; //0-100 public int rpm; //0-100, crescent moon gauge, used for calculating the amount of power generated, starts past 10%
public int temp; //0-800 public int temp; //0-800, used for figuring out how much water to boil, starts boiling at 300°C
public int rpmIdle = 10; public int rpmIdle = 10;
public int tempIdle = 300; public int tempIdle = 300;
@ -128,15 +128,20 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
} }
} }
if(this.power > this.maxPower)
this.power = this.maxPower;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP); ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", this.power); //set first to get an unmodified view of how much power was generated before deductions from the net
//do net/battery deductions first...
power = Library.chargeItemsFromTE(slots, 0, power, maxPower); power = Library.chargeItemsFromTE(slots, 0, power, maxPower);
this.sendPower(worldObj, xCoord - dir.offsetZ * 5, yCoord + 1, zCoord + dir.offsetX * 5, rot); //sends out power this.sendPower(worldObj, xCoord - dir.offsetZ * 5, yCoord + 1, zCoord + dir.offsetX * 5, rot); //sends out power
//...and then cap it. Prevents potential future cases where power would be limited due to the fuel being too strong and the buffer too small.
if(this.power > this.maxPower)
this.power = this.maxPower;
for(int i = 0; i < 2; i++) { //fuel and lube for(int i = 0; i < 2; i++) { //fuel and lube
this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord - dir.offsetX * 2 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ, dir.getOpposite()); this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord - dir.offsetX * 2 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ, dir.getOpposite());
this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ, dir); this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ, dir);
@ -147,12 +152,9 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
//steam //steam
this.sendFluid(tanks[3].getTankType(), worldObj, xCoord + dir.offsetZ * 6, yCoord + 1, zCoord - dir.offsetX * 6, rot.getOpposite()); this.sendFluid(tanks[3].getTankType(), worldObj, xCoord + dir.offsetZ * 6, yCoord + 1, zCoord - dir.offsetX * 6, rot.getOpposite());
if(audio != null) //if(audio != null) // audio shouldn't even exist serverside
audio.updatePitch((float) (0.45 + 0.05 * rpm / 10)); // audio.updatePitch((float) (0.45 + 0.05 * rpm / 10));
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", this.power);
data.setInteger("rpm", this.rpm); data.setInteger("rpm", this.rpm);
data.setInteger("temp", this.temp); data.setInteger("temp", this.temp);
data.setInteger("state", this.state); data.setInteger("state", this.state);
@ -160,10 +162,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
data.setInteger("throttle", this.throttle); data.setInteger("throttle", this.throttle);
data.setInteger("slidpos", this.powerSliderPos); data.setInteger("slidpos", this.powerSliderPos);
if(state != 1) if(state != 1) {
data.setInteger("counter", this.counter); //sent during startup and shutdown data.setInteger("counter", this.counter); //sent during startup and shutdown
else } else {
data.setInteger("instantPow", this.instantPowerOutput); //sent while running data.setInteger("instantPow", this.instantPowerOutput); //sent while running
}
tanks[0].writeToNBT(data, "fuel"); tanks[0].writeToNBT(data, "fuel");
tanks[1].writeToNBT(data, "lube"); tanks[1].writeToNBT(data, "lube");
@ -277,8 +280,10 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
} }
} }
/** Dynamically calculates a (hopefully) sensible burn heat from the combustion energy, scales from 300°C - 800°C */
protected int getFluidBurnTemp(FluidType type) { protected int getFluidBurnTemp(FluidType type) {
return 800; double dFuel = type.hasTrait(FT_Combustible.class) ? type.getTrait(FT_Combustible.class).getCombustionEnergy() : 0;
return (int) Math.floor(800D - (Math.pow(Math.E, -dFuel / 100_000D)) * 300D);
} }
private void run() { private void run() {
@ -340,19 +345,21 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
long energy = 0; //energy per mb of fuel long energy = 0; //energy per mb of fuel
if(tanks[0].getTankType().hasTrait(FT_Combustible.class)) { if(tanks[0].getTankType().hasTrait(FT_Combustible.class)) {
energy = tanks[0].getTankType().getTrait(FT_Combustible.class).getCombustionEnergy() / 1000; energy = tanks[0].getTankType().getTrait(FT_Combustible.class).getCombustionEnergy() / 1000L;
} }
int rpmEff = rpm - rpmIdle; // RPM above idle level, 0-90
//consMax*energy is equivalent to power production at 100% //consMax*energy is equivalent to power production at 100%
if(instantPowerOutput < (consMax * energy * (rpm - rpmIdle) / 90)) { //this shit avoids power rising in steps of 2000 or so HE at a time, instead it does it smoothly if(instantPowerOutput < (consMax * energy * rpmEff / 90)) { //this shit avoids power rising in steps of 2000 or so HE at a time, instead it does it smoothly
instantPowerOutput += Math.random() * 0.005 * consMax * energy; instantPowerOutput += Math.random() * 0.005 * consMax * energy;
if(instantPowerOutput > (consMax * energy * (rpm - rpmIdle) / 90)) if(instantPowerOutput > (consMax * energy * rpmEff / 90))
instantPowerOutput = (int) (consMax * energy * (rpm - rpmIdle) / 90); instantPowerOutput = (int) (consMax * energy * rpmEff / 90);
} }
else if(instantPowerOutput > (consMax * energy * (rpm - rpmIdle) / 90)) { else if(instantPowerOutput > (consMax * energy * rpmEff / 90)) {
instantPowerOutput -= Math.random() * 0.011 * consMax * energy; instantPowerOutput -= Math.random() * 0.011 * consMax * energy;
if(instantPowerOutput < (consMax * energy * (rpm - rpmIdle) / 90)) if(instantPowerOutput < (consMax * energy * rpmEff / 90))
instantPowerOutput = (int) (consMax * energy * (rpm - rpmIdle) / 90); instantPowerOutput = (int) (consMax * energy * rpmEff / 90);
} }
this.power += instantPowerOutput; this.power += instantPowerOutput;
@ -498,7 +505,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB;
if(bb == null) return bb;
this.bb = AxisAlignedBB.getBoundingBox(xCoord - 10, yCoord, zCoord - 10, xCoord + 10, yCoord + 3, zCoord + 10);
return bb;
} }
@Override @Override