-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display the maximum input and output rates, and average I/O in ATs. (#…
- Loading branch information
Showing
6 changed files
with
183 additions
and
5 deletions.
There are no files selected for viewing
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
70 changes: 70 additions & 0 deletions
70
src/main/java/gregtech/integration/hwyla/provider/ActiveTransformerDataProvider.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,70 @@ | ||
package gregtech.integration.hwyla.provider; | ||
|
||
import gregtech.api.GTValues; | ||
import gregtech.api.capability.GregtechCapabilities; | ||
import gregtech.api.capability.IMultiblockController; | ||
import gregtech.api.util.TextFormattingUtil; | ||
import gregtech.common.metatileentities.multi.electric.MetaTileEntityActiveTransformer; | ||
|
||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraftforge.common.capabilities.Capability; | ||
|
||
import mcp.mobius.waila.api.IWailaConfigHandler; | ||
import mcp.mobius.waila.api.IWailaDataAccessor; | ||
import mcp.mobius.waila.api.IWailaRegistrar; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class ActiveTransformerDataProvider extends CapabilityDataProvider<IMultiblockController> { | ||
|
||
public static final ActiveTransformerDataProvider INSTANCE = new ActiveTransformerDataProvider(); | ||
|
||
@Override | ||
public void register(@NotNull IWailaRegistrar registrar) { | ||
registrar.registerBodyProvider(this, TileEntity.class); | ||
registrar.registerNBTProvider(this, TileEntity.class); | ||
registrar.addConfig(GTValues.MOD_NAME, "gregtech.multiblock.activetransformer"); | ||
} | ||
|
||
@Override | ||
protected @NotNull Capability<IMultiblockController> getCapability() { | ||
return GregtechCapabilities.CAPABILITY_MULTIBLOCK_CONTROLLER; | ||
} | ||
|
||
@Override | ||
protected NBTTagCompound getNBTData(IMultiblockController capability, NBTTagCompound tag) { | ||
if (capability instanceof MetaTileEntityActiveTransformer activeTransformer) { | ||
if (activeTransformer.isStructureFormed() && activeTransformer.isActive()) { | ||
NBTTagCompound subTag = new NBTTagCompound(); | ||
|
||
subTag.setLong("AverageIO", activeTransformer.getAverageIOLastSec()); | ||
|
||
tag.setTag("gregtech.IMultiblockController.ActiveTransformer", subTag); | ||
} | ||
} | ||
return tag; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, | ||
IWailaConfigHandler config) { | ||
if (!config.getConfig("gregtech.multiblock") || accessor.getTileEntity() == null) { | ||
return tooltip; | ||
} | ||
|
||
if (accessor.getNBTData().hasKey("gregtech.IMultiblockController.ActiveTransformer")) { | ||
NBTTagCompound tag = accessor.getNBTData() | ||
.getCompoundTag("gregtech.IMultiblockController.ActiveTransformer"); | ||
|
||
tooltip.add(I18n.format("gregtech.waila.active_transformer.average_io", | ||
TextFormattingUtil.formatNumbers(tag.getLong("AverageIO")))); | ||
} | ||
|
||
return tooltip; | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
src/main/java/gregtech/integration/theoneprobe/provider/ActiveTransformerInfoProvider.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,53 @@ | ||
package gregtech.integration.theoneprobe.provider; | ||
|
||
import gregtech.api.GTValues; | ||
import gregtech.api.capability.GregtechCapabilities; | ||
import gregtech.api.capability.IMultiblockController; | ||
import gregtech.api.util.TextComponentUtil; | ||
import gregtech.api.util.TextFormattingUtil; | ||
import gregtech.common.metatileentities.multi.electric.MetaTileEntityActiveTransformer; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.TextFormatting; | ||
import net.minecraftforge.common.capabilities.Capability; | ||
|
||
import mcjty.theoneprobe.api.IProbeHitData; | ||
import mcjty.theoneprobe.api.IProbeInfo; | ||
import mcjty.theoneprobe.api.NumberFormat; | ||
import mcjty.theoneprobe.apiimpl.elements.ElementProgress; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ActiveTransformerInfoProvider extends CapabilityInfoProvider<IMultiblockController> { | ||
|
||
@Override | ||
public String getID() { | ||
return GTValues.MODID + ":active_transformer_info_provider"; | ||
} | ||
|
||
@Override | ||
protected boolean allowDisplaying(@NotNull IMultiblockController capability) { | ||
return capability instanceof MetaTileEntityActiveTransformer activeTransformer && activeTransformer.isActive(); | ||
} | ||
|
||
@Override | ||
protected @NotNull Capability<IMultiblockController> getCapability() { | ||
return GregtechCapabilities.CAPABILITY_MULTIBLOCK_CONTROLLER; | ||
} | ||
|
||
@Override | ||
protected void addProbeInfo(IMultiblockController capability, IProbeInfo probeInfo, EntityPlayer player, | ||
TileEntity tileEntity, IProbeHitData data) { | ||
long averageIO = ((MetaTileEntityActiveTransformer) capability).getAverageIOLastSec(); | ||
ITextComponent text = TextComponentUtil.translationWithColor( | ||
TextFormatting.AQUA, | ||
"gregtech.multiblock.active_transformer.average_io", | ||
TextComponentUtil.stringWithColor(TextFormatting.WHITE, | ||
player.isSneaking() || averageIO < 10_000 ? | ||
TextFormattingUtil.formatNumbers(averageIO) + " EU/t" : | ||
ElementProgress.format(averageIO, NumberFormat.COMPACT, "EU/t"))); | ||
|
||
probeInfo.text(text.getFormattedText()); | ||
} | ||
} |
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