Boiling it down, Part II

- Further adjustments to the steam engine's power balance
This commit is contained in:
simibubi 2022-05-03 14:50:11 +02:00
parent 1da8b6e538
commit 558241ca67
3 changed files with 32 additions and 34 deletions

View file

@ -31,6 +31,9 @@ public class BoilerData {
static final int SAMPLE_RATE = 5; static final int SAMPLE_RATE = 5;
private static final int waterSupplyPerLevel = 10;
private static final float passiveEngineEfficiency = 1 / 32f;
// pooled water supply // pooled water supply
int gatheredSupply; int gatheredSupply;
float[] supplyOverTime = new float[10]; float[] supplyOverTime = new float[10];
@ -67,7 +70,6 @@ public class BoilerData {
return; return;
ticksUntilNextSample = SAMPLE_RATE; ticksUntilNextSample = SAMPLE_RATE;
// waterSupply -= supplyOverTime[currentIndex] / supplyOverTime.length;
supplyOverTime[currentIndex] = gatheredSupply / (float) SAMPLE_RATE; supplyOverTime[currentIndex] = gatheredSupply / (float) SAMPLE_RATE;
waterSupply = Math.max(waterSupply, supplyOverTime[currentIndex]); waterSupply = Math.max(waterSupply, supplyOverTime[currentIndex]);
currentIndex = (currentIndex + 1) % supplyOverTime.length; currentIndex = (currentIndex + 1) % supplyOverTime.length;
@ -76,7 +78,6 @@ public class BoilerData {
if (currentIndex == 0) { if (currentIndex == 0) {
waterSupply = 0; waterSupply = 0;
for (float i : supplyOverTime) for (float i : supplyOverTime)
// waterSupply += i;
waterSupply = Math.max(i, waterSupply); waterSupply = Math.max(i, waterSupply);
} }
@ -92,16 +93,16 @@ public class BoilerData {
} }
public int getMaxHeatLevelForWaterSupply() { public int getMaxHeatLevelForWaterSupply() {
return Math.min(activeHeat, (int) Math.min(18, Mth.ceil(waterSupply) / 20)); return (int) Math.min(18, Mth.ceil(waterSupply) / waterSupplyPerLevel);
} }
public boolean isPassive(int boilerSize) { public boolean isPassive(int boilerSize) {
return passiveHeat || activeHeat != 0 && getActualHeat(boilerSize) == 0; return passiveHeat && getMaxHeatLevelForBoilerSize(boilerSize) > 0 && getMaxHeatLevelForWaterSupply() > 0;
} }
public float getEngineEfficiency(int boilerSize) { public float getEngineEfficiency(int boilerSize) {
if (isPassive(boilerSize)) if (isPassive(boilerSize))
return 1 / 16f / attachedEngines; return passiveEngineEfficiency / attachedEngines;
if (activeHeat == 0) if (activeHeat == 0)
return 0; return 0;
int actualHeat = getActualHeat(boilerSize); int actualHeat = getActualHeat(boilerSize);
@ -126,21 +127,15 @@ public class BoilerData {
int forWaterSupply = getMaxHeatLevelForWaterSupply(); int forWaterSupply = getMaxHeatLevelForWaterSupply();
int actualHeat = Math.min(activeHeat, Math.min(forWaterSupply, forBoilerSize)); int actualHeat = Math.min(activeHeat, Math.min(forWaterSupply, forBoilerSize));
tooltip.add(componentSpacing.plainCopy()
.append(new TextComponent("Boiler Information:")));
Component h = new TextComponent("Heat: ").withStyle(ChatFormatting.GRAY)
.append(new TextComponent(IHaveGoggleInformation.format(activeHeat)).withStyle(ChatFormatting.GOLD));
Component w = new TextComponent(", Water: ").withStyle(ChatFormatting.GRAY)
.append(new TextComponent(IHaveGoggleInformation.format(forWaterSupply)).withStyle(ChatFormatting.GOLD));
Component s = new TextComponent(", Size: ").withStyle(ChatFormatting.GRAY)
.append(new TextComponent(IHaveGoggleInformation.format(forBoilerSize)).withStyle(ChatFormatting.GOLD));
TextComponent heatLevel = isPassive(boilerSize) ? new TextComponent("Passive") TextComponent heatLevel = isPassive(boilerSize) ? new TextComponent("Passive")
: (activeHeat == 0 ? new TextComponent("No Heat") : (actualHeat == 0 ? new TextComponent("Idle")
: new TextComponent(IHaveGoggleInformation.format(actualHeat))); : new TextComponent("Lvl " + IHaveGoggleInformation.format(actualHeat)));
MutableComponent heatLabel = heatLevel.withStyle(ChatFormatting.GREEN); tooltip.add(componentSpacing.plainCopy()
Component level = new TextComponent("Boiler Level: ").append(heatLabel); .append(new TextComponent("Boiler Status: ").append(heatLevel.withStyle(ChatFormatting.GREEN))));
Component h = levelComponent("Temperature: ", "No heat", passiveHeat ? -1 : activeHeat);
Component w = levelComponent("Water supply: ", "Too slow", forWaterSupply);
Component s = levelComponent("Boiler size: ", "Too small", forBoilerSize);
double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(actualHeat, attachedEngines) double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(actualHeat, attachedEngines)
* BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get()); * BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get());
@ -153,14 +148,14 @@ public class BoilerData {
Component indent = new TextComponent(spacing); Component indent = new TextComponent(spacing);
Component indent2 = new TextComponent(spacing + " "); Component indent2 = new TextComponent(spacing + " ");
Component stats = indent.plainCopy() tooltip.add(indent.plainCopy()
.append(h) .append(w));
.append(w) tooltip.add(indent.plainCopy()
.append(s); .append(h));
tooltip.add(indent.plainCopy()
.append(s));
if (activeHeat > 0) tooltip.add(indent);
tooltip.add(stats);
tooltip.add(new TextComponent(" -> ").append(level));
tooltip.add(indent.plainCopy() tooltip.add(indent.plainCopy()
.append(Lang.translate("tooltip.capacityProvided") .append(Lang.translate("tooltip.capacityProvided")
.withStyle(ChatFormatting.GRAY))); .withStyle(ChatFormatting.GRAY)));
@ -171,6 +166,14 @@ public class BoilerData {
return true; return true;
} }
private MutableComponent levelComponent(String text, String whenZero, int level) {
return new TextComponent(text).withStyle(ChatFormatting.GRAY)
.append(level == 0 ? new TextComponent(whenZero).withStyle(ChatFormatting.RED)
: new TextComponent(
level == -1 ? "Passive" : level == 18 ? "Max" : "Lvl " + IHaveGoggleInformation.format(level))
.withStyle(ChatFormatting.GOLD));
}
public boolean evaluate(FluidTankTileEntity controller) { public boolean evaluate(FluidTankTileEntity controller) {
BlockPos controllerPos = controller.getBlockPos(); BlockPos controllerPos = controller.getBlockPos();
Level level = controller.getLevel(); Level level = controller.getLevel();
@ -297,14 +300,9 @@ public class BoilerData {
public int fill(FluidStack resource, FluidAction action) { public int fill(FluidStack resource, FluidAction action) {
if (!isFluidValid(0, resource)) if (!isFluidValid(0, resource))
return 0; return 0;
int maxAccepted = (int) ((passiveHeat ? 1 : activeHeat + 1) * 20) * SAMPLE_RATE; int amount = resource.getAmount();
if (maxAccepted == 0)
return 0;
int amount = Math.min(maxAccepted - gatheredSupply, resource.getAmount());
if (action.execute()) if (action.execute())
gatheredSupply += amount; gatheredSupply += amount;
if (action.simulate())
return Math.max(amount, 1);
return amount; return amount;
} }

View file

@ -10,8 +10,8 @@ import net.minecraft.world.level.block.state.BlockState;
public class BoilerHeaters { // API? public class BoilerHeaters { // API?
public static boolean canHeatPassively(BlockState state) { public static boolean canHeatPassively(BlockState state) {
if (AllBlocks.BLAZE_BURNER.has(state) && state.getValue(BlazeBurnerBlock.HEAT_LEVEL) != HeatLevel.NONE) if (AllBlocks.BLAZE_BURNER.has(state))
return true; return state.getValue(BlazeBurnerBlock.HEAT_LEVEL) != HeatLevel.NONE;
if (AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state)) if (AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state))
return true; return true;
return false; return false;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB