4040public 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}
0 commit comments