Skip to content

Commit

Permalink
make steam great again
Browse files Browse the repository at this point in the history
  • Loading branch information
DStrand1 committed Aug 11, 2021
1 parent 346ce2c commit 8f5ad1d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class MetaTileEntities {
public static SteamCoalBoiler STEAM_BOILER_COAL_BRONZE;
public static SteamCoalBoiler STEAM_BOILER_COAL_STEEL;
public static SteamSolarBoiler STEAM_BOILER_SOLAR_BRONZE;
public static SteamSolarBoiler STEAM_BOILER_SOLAR_STEEL;
public static SteamLavaBoiler STEAM_BOILER_LAVA_BRONZE;
public static SteamLavaBoiler STEAM_BOILER_LAVA_STEEL;
public static SteamExtractor STEAM_EXTRACTOR_BRONZE;
Expand Down Expand Up @@ -200,6 +201,7 @@ public static void init() {
STEAM_BOILER_COAL_STEEL = GregTechAPI.registerMetaTileEntity(2, new SteamCoalBoiler(gregtechId("steam_boiler_coal_steel"), true));

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

STEAM_BOILER_LAVA_BRONZE = GregTechAPI.registerMetaTileEntity(5, new SteamLavaBoiler(gregtechId("steam_boiler_lava_bronze"), false));
STEAM_BOILER_LAVA_STEEL = GregTechAPI.registerMetaTileEntity(6, new SteamLavaBoiler(gregtechId("steam_boiler_lava_steel"), true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@
public abstract class SteamBoiler extends MetaTileEntity {

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

public final TextureArea BRONZE_BACKGROUND_TEXTURE;
public final TextureArea BRONZE_SLOT_BACKGROUND_TEXTURE;

public final TextureArea SLOT_FURNACE_BACKGROUND;

protected final boolean isHighPressure;
protected final int baseSteamOutput;
private final OrientedOverlayRenderer renderer;

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

public SteamBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure, OrientedOverlayRenderer renderer, int baseSteamOutput) {
public SteamBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure, OrientedOverlayRenderer renderer) {
super(metaTileEntityId);
this.renderer = renderer;
this.isHighPressure = isHighPressure;
this.baseSteamOutput = baseSteamOutput;
BRONZE_BACKGROUND_TEXTURE = getGuiTexture("%s_gui");
BRONZE_SLOT_BACKGROUND_TEXTURE = getGuiTexture("slot_%s");
SLOT_FURNACE_BACKGROUND = getGuiTexture("slot_%s_furnace_background");
Expand Down Expand Up @@ -155,7 +151,9 @@ public void update() {
super.update();
if (!getWorld().isRemote) {
updateCurrentTemperature();
generateSteam();
if (getOffsetTimer() % 10 == 0) {
generateSteam();
}

fillInternalTankFromFluidContainer(containerInventory, containerInventory, 0, 1);

Expand Down Expand Up @@ -198,30 +196,28 @@ private void updateCurrentTemperature() {
} else --timeBeforeCoolingDown;
}

protected abstract int getBaseSteamOutput();

private void generateSteam() {
if (currentTemperature >= 100) {
if (getOffsetTimer() % getBoilingCycleLength() == 0) {
int fillAmount = (int) (baseSteamOutput * (currentTemperature / (getMaxTemperate() * 1.0)));
boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
int filledSteam = 0;
if (hasDrainedWater) {
filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
}
if (this.hasNoWater && hasDrainedWater) {
getWorld().setBlockToAir(getPos());
getWorld().createExplosion(null,
getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
2.0f, true);
} else this.hasNoWater = !hasDrainedWater;
if (filledSteam == 0 && hasDrainedWater) {
getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
steamFluidTank.drain(4000, true);
}
int fillAmount = (int) (getBaseSteamOutput() * (currentTemperature / (getMaxTemperate() * 1.0)) / 2);
boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
int filledSteam = 0;
if (hasDrainedWater) {
filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
}
} else {
this.hasNoWater = false;
}
if (this.hasNoWater && hasDrainedWater) {
getWorld().setBlockToAir(getPos());
getWorld().createExplosion(null,
getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
2.0f, true);
} else this.hasNoWater = !hasDrainedWater;
if (filledSteam == 0 && hasDrainedWater) {
getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
steamFluidTank.drain(4000, true);
}
} else this.hasNoWater = false;
}

public boolean isBurning() {
Expand Down Expand Up @@ -292,12 +288,8 @@ public ModularUI.Builder createUITemplate(EntityPlayer player) {
.bindPlayerInventory(player.inventory, BRONZE_SLOT_BACKGROUND_TEXTURE, 0);
}

private int getBoilingCycleLength() {
return isHighPressure ? HIGH_PRESSURE_BOILING_CYCLE_LENGTH : BOILING_CYCLE_LENGTH;
}

@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
tooltip.add(I18n.format("gregtech.machine.steam_boiler.tooltip_produces", baseSteamOutput, getBoilingCycleLength()));
tooltip.add(I18n.format("gregtech.machine.steam_boiler.tooltip_produces", getBaseSteamOutput()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@
public class SteamCoalBoiler extends SteamBoiler implements IFuelable {

public SteamCoalBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) {
super(metaTileEntityId, isHighPressure, Textures.COAL_BOILER_OVERLAY, 150);
super(metaTileEntityId, isHighPressure, Textures.COAL_BOILER_OVERLAY);
}

@Override
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
return new SteamCoalBoiler(metaTileEntityId, isHighPressure);
}

@Override
protected int getBaseSteamOutput() {
return isHighPressure ? 300 : 120;
}

@Override
protected void tryConsumeNewFuel() {
ItemStack fuelInSlot = importItems.extractItem(0, 1, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ public class SteamLavaBoiler extends SteamBoiler implements IFuelable {
private FluidTank lavaFluidTank;

public SteamLavaBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) {
super(metaTileEntityId, isHighPressure, Textures.LAVA_BOILER_OVERLAY, 100);
super(metaTileEntityId, isHighPressure, Textures.LAVA_BOILER_OVERLAY);
}

@Override
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
return new SteamLavaBoiler(metaTileEntityId, isHighPressure);
}

@Override
protected int getBaseSteamOutput() {
return isHighPressure ? 600 : 240;
}

@Override
protected FluidTankList createImportFluidHandler() {
FluidTankList superHandler = super.createImportFluidHandler();
Expand All @@ -44,7 +49,7 @@ protected FluidTankList createImportFluidHandler() {

}

public static final int LAVA_PER_OPERATION = 100;
public static final int LAVA_PER_OPERATION = 100; // todo this may be too good?

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
public class SteamSolarBoiler extends SteamBoiler {

public SteamSolarBoiler(ResourceLocation metaTileEntityId, boolean isHighPressure) {
super(metaTileEntityId, isHighPressure, Textures.SOLAR_BOILER_OVERLAY, 55);
super(metaTileEntityId, isHighPressure, Textures.SOLAR_BOILER_OVERLAY);
}

@Override
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
return new SteamSolarBoiler(metaTileEntityId, isHighPressure);
}

@Override
protected int getBaseSteamOutput() {
return isHighPressure ? 360 : 120;
}

protected boolean checkCanSeeSun() {
BlockPos blockPos = getPos().up();
if (!getWorld().canBlockSeeSky(blockPos))
Expand Down
Loading

0 comments on commit 8f5ad1d

Please sign in to comment.