Skip to content

Commit 8f5ad1d

Browse files
committed
make steam great again
1 parent 346ce2c commit 8f5ad1d

File tree

7 files changed

+61
-49
lines changed

7 files changed

+61
-49
lines changed

src/main/java/gregtech/common/metatileentities/MetaTileEntities.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class MetaTileEntities {
4747
public static SteamCoalBoiler STEAM_BOILER_COAL_BRONZE;
4848
public static SteamCoalBoiler STEAM_BOILER_COAL_STEEL;
4949
public static SteamSolarBoiler STEAM_BOILER_SOLAR_BRONZE;
50+
public static SteamSolarBoiler STEAM_BOILER_SOLAR_STEEL;
5051
public static SteamLavaBoiler STEAM_BOILER_LAVA_BRONZE;
5152
public static SteamLavaBoiler STEAM_BOILER_LAVA_STEEL;
5253
public static SteamExtractor STEAM_EXTRACTOR_BRONZE;
@@ -200,6 +201,7 @@ public static void init() {
200201
STEAM_BOILER_COAL_STEEL = GregTechAPI.registerMetaTileEntity(2, new SteamCoalBoiler(gregtechId("steam_boiler_coal_steel"), true));
201202

202203
STEAM_BOILER_SOLAR_BRONZE = GregTechAPI.registerMetaTileEntity(3, new SteamSolarBoiler(gregtechId("steam_boiler_solar_bronze"), false));
204+
STEAM_BOILER_SOLAR_STEEL = GregTechAPI.registerMetaTileEntity(4, new SteamSolarBoiler(gregtechId("steam_boiler_solar_steel"), true));
203205

204206
STEAM_BOILER_LAVA_BRONZE = GregTechAPI.registerMetaTileEntity(5, new SteamLavaBoiler(gregtechId("steam_boiler_lava_bronze"), false));
205207
STEAM_BOILER_LAVA_STEEL = GregTechAPI.registerMetaTileEntity(6, new SteamLavaBoiler(gregtechId("steam_boiler_lava_steel"), true));

src/main/java/gregtech/common/metatileentities/steam/boiler/SteamBoiler.java

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,13 @@
4040
public abstract class SteamBoiler extends MetaTileEntity {
4141

4242
private static final EnumFacing[] STEAM_PUSH_DIRECTIONS = ArrayUtils.add(EnumFacing.HORIZONTALS, EnumFacing.UP);
43-
public static final int BOILING_CYCLE_LENGTH = 25;
44-
public static final int HIGH_PRESSURE_BOILING_CYCLE_LENGTH = 10;
4543

4644
public final TextureArea BRONZE_BACKGROUND_TEXTURE;
4745
public final TextureArea BRONZE_SLOT_BACKGROUND_TEXTURE;
4846

4947
public final TextureArea SLOT_FURNACE_BACKGROUND;
5048

5149
protected final boolean isHighPressure;
52-
protected final int baseSteamOutput;
5350
private final OrientedOverlayRenderer renderer;
5451

5552
protected FluidTank waterFluidTank;
@@ -65,11 +62,10 @@ public abstract class SteamBoiler extends MetaTileEntity {
6562
private boolean wasBurningAndNeedsUpdate;
6663
private final ItemStackHandler containerInventory;
6764

68-
public SteamBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure, OrientedOverlayRenderer renderer, int baseSteamOutput) {
65+
public SteamBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure, OrientedOverlayRenderer renderer) {
6966
super(metaTileEntityId);
7067
this.renderer = renderer;
7168
this.isHighPressure = isHighPressure;
72-
this.baseSteamOutput = baseSteamOutput;
7369
BRONZE_BACKGROUND_TEXTURE = getGuiTexture("%s_gui");
7470
BRONZE_SLOT_BACKGROUND_TEXTURE = getGuiTexture("slot_%s");
7571
SLOT_FURNACE_BACKGROUND = getGuiTexture("slot_%s_furnace_background");
@@ -155,7 +151,9 @@ public void update() {
155151
super.update();
156152
if (!getWorld().isRemote) {
157153
updateCurrentTemperature();
158-
generateSteam();
154+
if (getOffsetTimer() % 10 == 0) {
155+
generateSteam();
156+
}
159157

160158
fillInternalTankFromFluidContainer(containerInventory, containerInventory, 0, 1);
161159

@@ -198,30 +196,28 @@ private void updateCurrentTemperature() {
198196
} else --timeBeforeCoolingDown;
199197
}
200198

199+
protected abstract int getBaseSteamOutput();
200+
201201
private void generateSteam() {
202202
if (currentTemperature >= 100) {
203-
if (getOffsetTimer() % getBoilingCycleLength() == 0) {
204-
int fillAmount = (int) (baseSteamOutput * (currentTemperature / (getMaxTemperate() * 1.0)));
205-
boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
206-
int filledSteam = 0;
207-
if (hasDrainedWater) {
208-
filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
209-
}
210-
if (this.hasNoWater && hasDrainedWater) {
211-
getWorld().setBlockToAir(getPos());
212-
getWorld().createExplosion(null,
213-
getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
214-
2.0f, true);
215-
} else this.hasNoWater = !hasDrainedWater;
216-
if (filledSteam == 0 && hasDrainedWater) {
217-
getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
218-
SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
219-
steamFluidTank.drain(4000, true);
220-
}
203+
int fillAmount = (int) (getBaseSteamOutput() * (currentTemperature / (getMaxTemperate() * 1.0)) / 2);
204+
boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
205+
int filledSteam = 0;
206+
if (hasDrainedWater) {
207+
filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
221208
}
222-
} else {
223-
this.hasNoWater = false;
224-
}
209+
if (this.hasNoWater && hasDrainedWater) {
210+
getWorld().setBlockToAir(getPos());
211+
getWorld().createExplosion(null,
212+
getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
213+
2.0f, true);
214+
} else this.hasNoWater = !hasDrainedWater;
215+
if (filledSteam == 0 && hasDrainedWater) {
216+
getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
217+
SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
218+
steamFluidTank.drain(4000, true);
219+
}
220+
} else this.hasNoWater = false;
225221
}
226222

227223
public boolean isBurning() {
@@ -292,12 +288,8 @@ public ModularUI.Builder createUITemplate(EntityPlayer player) {
292288
.bindPlayerInventory(player.inventory, BRONZE_SLOT_BACKGROUND_TEXTURE, 0);
293289
}
294290

295-
private int getBoilingCycleLength() {
296-
return isHighPressure ? HIGH_PRESSURE_BOILING_CYCLE_LENGTH : BOILING_CYCLE_LENGTH;
297-
}
298-
299291
@Override
300292
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
301-
tooltip.add(I18n.format("gregtech.machine.steam_boiler.tooltip_produces", baseSteamOutput, getBoilingCycleLength()));
293+
tooltip.add(I18n.format("gregtech.machine.steam_boiler.tooltip_produces", getBaseSteamOutput()));
302294
}
303295
}

src/main/java/gregtech/common/metatileentities/steam/boiler/SteamCoalBoiler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@
2828
public class SteamCoalBoiler extends SteamBoiler implements IFuelable {
2929

3030
public SteamCoalBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) {
31-
super(metaTileEntityId, isHighPressure, Textures.COAL_BOILER_OVERLAY, 150);
31+
super(metaTileEntityId, isHighPressure, Textures.COAL_BOILER_OVERLAY);
3232
}
3333

3434
@Override
3535
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
3636
return new SteamCoalBoiler(metaTileEntityId, isHighPressure);
3737
}
3838

39+
@Override
40+
protected int getBaseSteamOutput() {
41+
return isHighPressure ? 300 : 120;
42+
}
43+
3944
@Override
4045
protected void tryConsumeNewFuel() {
4146
ItemStack fuelInSlot = importItems.extractItem(0, 1, true);

src/main/java/gregtech/common/metatileentities/steam/boiler/SteamLavaBoiler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@ public class SteamLavaBoiler extends SteamBoiler implements IFuelable {
2727
private FluidTank lavaFluidTank;
2828

2929
public SteamLavaBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) {
30-
super(metaTileEntityId, isHighPressure, Textures.LAVA_BOILER_OVERLAY, 100);
30+
super(metaTileEntityId, isHighPressure, Textures.LAVA_BOILER_OVERLAY);
3131
}
3232

3333
@Override
3434
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
3535
return new SteamLavaBoiler(metaTileEntityId, isHighPressure);
3636
}
3737

38+
@Override
39+
protected int getBaseSteamOutput() {
40+
return isHighPressure ? 600 : 240;
41+
}
42+
3843
@Override
3944
protected FluidTankList createImportFluidHandler() {
4045
FluidTankList superHandler = super.createImportFluidHandler();
@@ -44,7 +49,7 @@ protected FluidTankList createImportFluidHandler() {
4449

4550
}
4651

47-
public static final int LAVA_PER_OPERATION = 100;
52+
public static final int LAVA_PER_OPERATION = 100; // todo this may be too good?
4853

4954
@Override
5055
protected void tryConsumeNewFuel() {
@@ -71,7 +76,7 @@ public Collection<IFuelInfo> getFuels() {
7176
return Collections.emptySet();
7277
final int fuelRemaining = lava.amount;
7378
final int fuelCapacity = lavaFluidTank.getCapacity();
74-
final long burnTime = fuelRemaining * (this.isHighPressure ? 6 : 12); // 100 mb lasts 600 or 1200 ticks
79+
final long burnTime = (long) fuelRemaining * (this.isHighPressure ? 6 : 12); // 100 mb lasts 600 or 1200 ticks
7580
return Collections.singleton(new FluidFuelInfo(lava, fuelRemaining, fuelCapacity, LAVA_PER_OPERATION, burnTime));
7681
}
7782

src/main/java/gregtech/common/metatileentities/steam/boiler/SteamSolarBoiler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@
1313
public class SteamSolarBoiler extends SteamBoiler {
1414

1515
public SteamSolarBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) {
16-
super(metaTileEntityId, isHighPressure, Textures.SOLAR_BOILER_OVERLAY, 55);
16+
super(metaTileEntityId, isHighPressure, Textures.SOLAR_BOILER_OVERLAY);
1717
}
1818

1919
@Override
2020
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
2121
return new SteamSolarBoiler(metaTileEntityId, isHighPressure);
2222
}
2323

24+
@Override
25+
protected int getBaseSteamOutput() {
26+
return isHighPressure ? 360 : 120;
27+
}
28+
2429
protected boolean checkCanSeeSun() {
2530
BlockPos blockPos = getPos().up();
2631
if (!getWorld().canBlockSeeSky(blockPos))

0 commit comments

Comments
 (0)