-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f860ca3
commit 8d7c951
Showing
5 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/main/java/com/nomiceu/nomilabs/gregtech/mixinhelper/AccessibleSteamBoiler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.nomiceu.nomilabs.gregtech.mixinhelper; | ||
|
||
public interface AccessibleSteamBoiler { | ||
|
||
int labs$getCurrentTemperature(); | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/SteamBoilerInfoProviderMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.text.TextFormatting; | ||
import net.minecraft.world.World; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import com.nomiceu.nomilabs.gregtech.mixinhelper.AccessibleSteamBoiler; | ||
|
||
import gregtech.api.metatileentity.MetaTileEntity; | ||
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; | ||
import gregtech.api.unification.material.Materials; | ||
import gregtech.api.util.TextFormattingUtil; | ||
import gregtech.common.metatileentities.steam.boiler.SteamBoiler; | ||
import gregtech.integration.theoneprobe.provider.SteamBoilerInfoProvider; | ||
import mcjty.theoneprobe.api.IProbeHitData; | ||
import mcjty.theoneprobe.api.IProbeInfo; | ||
import mcjty.theoneprobe.api.ProbeMode; | ||
import mcjty.theoneprobe.api.TextStyleClass; | ||
|
||
/** | ||
* Improves Steam Boiler TOP Display. | ||
*/ | ||
@Mixin(value = SteamBoilerInfoProvider.class, remap = false) | ||
public class SteamBoilerInfoProviderMixin { | ||
|
||
@Inject(method = "addProbeInfo", at = @At("HEAD"), cancellable = true) | ||
private void replaceProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, | ||
IBlockState state, IProbeHitData data, CallbackInfo ci) { | ||
ci.cancel(); | ||
|
||
if (!state.getBlock().hasTileEntity(state)) return; | ||
|
||
TileEntity te = world.getTileEntity(data.getPos()); | ||
if (!(te instanceof IGregTechTileEntity igtte)) return; | ||
|
||
MetaTileEntity mte = igtte.getMetaTileEntity(); | ||
if (!(mte instanceof SteamBoiler boiler)) return; | ||
|
||
int steamOutput = boiler.getTotalSteamOutput(); | ||
|
||
// If we are not producing steam, and we have no fuel | ||
if (steamOutput <= 0 && !boiler.isBurning()) return; | ||
|
||
// Creating steam | ||
if (steamOutput > 0 && boiler.hasWater()) { | ||
probeInfo.text(TextStyleClass.INFO + "{*gregtech.top.energy_production*} " + | ||
TextFormatting.AQUA + TextFormattingUtil.formatNumbers(steamOutput / 10) + | ||
TextStyleClass.INFO + " L/t" + " {*" + | ||
Materials.Steam.getUnlocalizedName() + "*}"); | ||
} | ||
|
||
// Cooling Down | ||
if (!boiler.isBurning()) { | ||
probeInfo.text(TextStyleClass.INFO.toString() + TextFormatting.RED + | ||
"{*nomilabs.top.steam_cooling_down*}"); | ||
} | ||
|
||
// Initial Heat-Up | ||
if (steamOutput <= 0 && ((AccessibleSteamBoiler) boiler).labs$getCurrentTemperature() > 0) { | ||
// Current Temperature = the % until the boiler reaches 100 | ||
probeInfo.text(TextStyleClass.INFO.toString() + TextFormatting.RED + | ||
"{*nomilabs.top.steam_heating_up*} " + | ||
TextFormattingUtil | ||
.formatNumbers(((AccessibleSteamBoiler) boiler).labs$getCurrentTemperature()) + | ||
"%"); | ||
} | ||
|
||
// No Water | ||
if (!boiler.hasWater()) { | ||
probeInfo.text(TextStyleClass.WARNING + "{*gregtech.top.steam_no_water*}"); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/SteamBoilerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import com.nomiceu.nomilabs.gregtech.mixinhelper.AccessibleSteamBoiler; | ||
|
||
import gregtech.api.metatileentity.MetaTileEntity; | ||
import gregtech.common.metatileentities.steam.boiler.SteamBoiler; | ||
|
||
/** | ||
* Allows Accessing Steam Boiler Info, and Fixes Continuous Running. | ||
*/ | ||
@Mixin(value = SteamBoiler.class, remap = false) | ||
public abstract class SteamBoilerMixin extends MetaTileEntity implements AccessibleSteamBoiler { | ||
|
||
@Shadow | ||
private int currentTemperature; | ||
|
||
@Shadow | ||
private int fuelMaxBurnTime; | ||
|
||
@Shadow | ||
protected abstract int getCooldownInterval(); | ||
|
||
@Shadow | ||
private int timeBeforeCoolingDown; | ||
|
||
@Shadow | ||
private boolean wasBurningAndNeedsUpdate; | ||
|
||
@Shadow | ||
private int fuelBurnTimeLeft; | ||
|
||
/** | ||
* Mandatory Ignored Constructor | ||
*/ | ||
public SteamBoilerMixin(ResourceLocation metaTileEntityId) { | ||
super(metaTileEntityId); | ||
} | ||
|
||
@Inject(method = "updateCurrentTemperature", at = @At("RETURN")) | ||
private void checkForNegativeBurnTime(CallbackInfo ci) { | ||
if (fuelMaxBurnTime > 0 && getOffsetTimer() % 12 == 0) { | ||
if (fuelBurnTimeLeft < 0) { | ||
fuelMaxBurnTime = 0; | ||
timeBeforeCoolingDown = getCooldownInterval(); | ||
// boiler has no fuel now, so queue burning state update | ||
wasBurningAndNeedsUpdate = true; | ||
} else if (fuelBurnTimeLeft % 2 != 0) currentTemperature++; | ||
} | ||
} | ||
|
||
@Override | ||
@Unique | ||
public int labs$getCurrentTemperature() { | ||
return currentTemperature; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters