start on new power api
This commit is contained in:
parent
ea23ef7038
commit
4f80a8c651
35 changed files with 275 additions and 250 deletions
|
@ -40,10 +40,11 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.api.power.ItemPowerManager;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import team.reborn.energy.EnergyHolder;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import techreborn.TechReborn;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -59,7 +60,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
Item item = stack.getItem();
|
||||
if (item instanceof IListInfoProvider) {
|
||||
((IListInfoProvider) item).addInfo(components, false, false);
|
||||
} else if (stack.getItem() instanceof IEnergyItemInfo) {
|
||||
} else if (stack.getItem() instanceof EnergyHolder) {
|
||||
ItemPowerManager itemPowerManager = new ItemPowerManager(stack);
|
||||
LiteralText line1 = new LiteralText(PowerSystem.getLocaliszedPowerFormattedNoSuffix(itemPowerManager.getEnergyStored()));
|
||||
line1.append("/");
|
||||
|
@ -75,7 +76,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
Formatting color = StringUtils.getPercentageColour(percentage);
|
||||
components.add(2, new LiteralText(color + "" + percentage + "%" + Formatting.GRAY + " Charged"));
|
||||
// TODO: show both input and output rates
|
||||
components.add(3, new LiteralText(Formatting.GRAY + "I/O Rate: " + Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(((IEnergyItemInfo) item).getMaxInput())));
|
||||
components.add(3, new LiteralText(Formatting.GRAY + "I/O Rate: " + Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(((EnergyHolder) item).getMaxInput(EnergySide.UNKNOWN))));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
@ -105,4 +106,10 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||
}
|
||||
|
||||
public int percentage(double MaxValue, double CurrentValue) {
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue