mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-23 21:49:49 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78b49c45d7 | ||
|
|
66cbe586ef | ||
|
|
00118d3905 | ||
|
|
2ea05f2ad9 | ||
|
|
3bba4e931c | ||
|
|
4b9ffa5f2c | ||
|
|
61cb18bad0 | ||
|
|
c9db4f214b |
No files matched your search
+5
-14
@@ -5,19 +5,10 @@ dependencies {
|
||||
|
||||
shadowImplementation('au.com.bytecode:opencsv:2.4')
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.111:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.106:dev") { transitive = false }
|
||||
|
||||
runtimeOnly("com.github.GTNewHorizons:WAILAPlugins:0.7.0:dev") {
|
||||
exclude group: 'com.github.GTNewHorizons', module: 'waila'
|
||||
}
|
||||
runtimeOnly("com.github.GTNewHorizons:EnderCore:0.5.0:dev")
|
||||
runtimeOnly("com.github.GTNewHorizons:BuildCraft:7.1.45:dev")
|
||||
runtimeOnly("curse.maven:cofh-lib-220333:2388748")
|
||||
runtimeOnly("curse.maven:extrautils-225561:2264383")
|
||||
runtimeOnly("com.github.GTNewHorizons:OpenBlocks:1.12.3-GTNH:dev")
|
||||
runtimeOnly("com.github.GTNewHorizons:Railcraft:9.17.6:dev")
|
||||
runtimeOnly('curse.maven:thermal-foundation-222880:2388753')
|
||||
runtimeOnly('curse.maven:thermal-expansion-69163:2388759')
|
||||
runtimeOnly('curse.maven:thermal-dynamics-227443:2388756')
|
||||
implementation('curse.maven:cofh-core-69162:2388751')
|
||||
// For testing addon integration
|
||||
runtimeOnly("com.github.GTNewHorizons:WAILAPlugins:0.7.0:dev") { transitive = false }
|
||||
runtimeOnly("com.github.GTNewHorizons:EnderCore:0.5.0:dev") { transitive = false }
|
||||
runtimeOnly("com.mod-buildcraft:buildcraft:7.1.23:dev") { transitive = false }
|
||||
}
|
||||
@@ -79,10 +79,6 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
}
|
||||
|
||||
private FluidTank getTank(TileEntity tileEntity) {
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Object tank = RailcraftModule.TileTankBase_getTank.invoke(tileEntity);
|
||||
|
||||
|
||||
+8
-21
@@ -1,6 +1,5 @@
|
||||
package mcp.mobius.waila.addons.thermalexpansion;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -14,7 +13,7 @@ import mcp.mobius.waila.api.ITaggedList;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
@@ -35,27 +34,15 @@ public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
|
||||
|
||||
if (!config.getConfig("thermalexpansion.energyhandler")) return currenttip;
|
||||
if (!accessor.getNBTData().hasKey("Energy")) return currenttip;
|
||||
if (!accessor.getNBTData().hasKey("MaxStorage")) return currenttip;
|
||||
|
||||
if (currenttip instanceof ITaggedList taggedTips) {
|
||||
int energy = accessor.getNBTInteger(accessor.getNBTData(), "Energy");
|
||||
int maxEnergy = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage");
|
||||
|
||||
if (maxEnergy > 0 && taggedTips.getEntries("RFEnergyStorage").isEmpty()) {
|
||||
if (config.getConfig("thermalexpansion.rfenergybar")) {
|
||||
taggedTips.add(
|
||||
SpecialChars.getRenderString("waila.rfenergy", energy + "", maxEnergy + ""),
|
||||
"RFEnergyStorage");
|
||||
} else {
|
||||
taggedTips.add(
|
||||
// TODO: Use NumberFormatter from #54
|
||||
String.format(
|
||||
"%s / %s RF",
|
||||
NumberFormat.getInstance().format(energy),
|
||||
NumberFormat.getInstance().format(maxEnergy)),
|
||||
"RFEnergyStorage");
|
||||
}
|
||||
int energy = accessor.getNBTInteger(accessor.getNBTData(), "Energy");
|
||||
int maxEnergy = accessor.getNBTInteger(accessor.getNBTData(), "MaxStorage");
|
||||
try {
|
||||
if ((maxEnergy != 0) && (((ITaggedList) currenttip).getEntries("RFEnergyStorage").size() == 0)) {
|
||||
((ITaggedList) currenttip).add(String.format("%d / %d RF", energy, maxEnergy), "RFEnergyStorage");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
currenttip = WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -32,11 +32,9 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = accessor.getTileEntity();
|
||||
if (tileEntity == null) return currenttip;
|
||||
|
||||
try {
|
||||
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid.invoke(tileEntity);
|
||||
FluidStack fluid = (FluidStack) ThermalExpansionModule.TileTank_getTankFluid
|
||||
.invoke(accessor.getTileEntity());
|
||||
String name = currenttip.get(0);
|
||||
String fluidName = fluid == null ? LangUtil.translateG("hud.msg.empty")
|
||||
: fluid.getFluid().getLocalizedName(fluid);
|
||||
@@ -44,7 +42,7 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
currenttip.set(0, name + " < " + fluidName + " >");
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -58,12 +56,9 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = accessor.getTileEntity();
|
||||
if (tileEntity == null) return currenttip;
|
||||
|
||||
try {
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(tileEntity);
|
||||
int capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity.invoke(tileEntity);
|
||||
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(accessor.getTileEntity());
|
||||
int capacity = (Integer) ThermalExpansionModule.TileTank_getTankCapacity.invoke(accessor.getTileEntity());
|
||||
|
||||
currenttip.add(
|
||||
String.format(
|
||||
@@ -73,7 +68,7 @@ public class TankFluidHandler implements IWailaDataProvider {
|
||||
ConfigHandler.instance().fluidUnit));
|
||||
|
||||
} catch (Exception e) {
|
||||
WailaExceptionHandler.handleErr(e, tileEntity.getClass().getName(), currenttip);
|
||||
WailaExceptionHandler.handleErr(e, accessor.getTileEntity().getClass().getName(), currenttip);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
@@ -37,15 +36,17 @@ public class TankModeHandler implements IWailaDataProvider {
|
||||
if (mode == 0) {
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s : %s",
|
||||
"%s : \u00a7a%s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
SpecialChars.GREEN + LangUtil.translateG("hud.msg.input")));
|
||||
LangUtil.translateG("hud.msg.input")));
|
||||
} else if (mode == 1) {
|
||||
currenttip.add(
|
||||
String.format(
|
||||
"%s : %s",
|
||||
"%s : \u00a7c%s",
|
||||
LangUtil.translateG("hud.msg.mode"),
|
||||
SpecialChars.RED + LangUtil.translateG("hud.msg.output")));
|
||||
LangUtil.translateG("hud.msg.output")));
|
||||
} else {
|
||||
currenttip.add(String.format("Mode : Unknown (%d)", mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ public class ThermalExpansionModule {
|
||||
IEnergyInfo_getCurStorage = IEnergyInfo.getMethod("getInfoEnergyStored");
|
||||
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.energyhandler");
|
||||
ModuleRegistrar.instance().addConfigRemote("Thermal Expansion", "thermalexpansion.rfenergybar");
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyProvider);
|
||||
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyProvider);
|
||||
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerIEnergyHandler(), IEnergyReceiver);
|
||||
|
||||
@@ -24,7 +24,6 @@ import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderAspectString;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderRFBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.server.ProxyServer;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
@@ -62,7 +61,6 @@ public class ProxyClient extends ProxyServer {
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.rfenergy", new TTRenderRFBar());
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.tcaspect", new TTRenderAspectString());
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
|
||||
}
|
||||
barText = String.format(
|
||||
"%s / %s %s%s",
|
||||
LangUtil.translateG("hud.msg.empty"),
|
||||
LangUtil.translateG("hud.msg.empty2"),
|
||||
params[3],
|
||||
ConfigHandler.instance().fluidUnit,
|
||||
sb);
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
|
||||
|
||||
int maxStringW;
|
||||
|
||||
private final Function<Integer, String> formatNumber;
|
||||
private static final NumberFormat energyFormat = NumberFormat.getInstance();
|
||||
private static final int height = 12;
|
||||
private static final int width = 2;
|
||||
|
||||
static {
|
||||
energyFormat.setGroupingUsed(true);
|
||||
}
|
||||
|
||||
public TTRenderRFBar() {
|
||||
formatNumber = energyFormat::format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
int commaCount = (int) (Math.floor((params[0].length() - 1) / 3D) + Math.floor((params[1].length() - 1) / 3D));
|
||||
StringBuilder sb = new StringBuilder(commaCount);
|
||||
for (int i = 0; i < commaCount; i++) {
|
||||
sb.append(",");
|
||||
}
|
||||
return new Dimension(
|
||||
DisplayUtil.getDisplayWidth(String.format("%s / %s RF%s", params[0], params[1], sb)) + 4,
|
||||
height);
|
||||
}
|
||||
|
||||
public static final ResourceLocation barTexture = new ResourceLocation("waila", "textures/rf_energy_bar.png");
|
||||
public static final ResourceLocation gradientTexture = new ResourceLocation("waila", "textures/gradient.png");
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
int amount = Integer.parseInt(params[0]);
|
||||
int capacity = Integer.parseInt(params[1]);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.getTextureManager().bindTexture(barTexture);
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
// Draw dark (uncharged) background for whole bar first
|
||||
for (int i = 0; i < (maxStringW - 2); i += width) {
|
||||
drawRect(tessellator, 1 + i, 0, 0, width, height, 0.0, 0.0, 0.5, 1.0);
|
||||
}
|
||||
|
||||
double i = (double) (maxStringW - 2) * amount / capacity;
|
||||
int drawnRects = 0;
|
||||
for (; i > width; i -= width) {
|
||||
drawRect(tessellator, 1 + (drawnRects * width), 0, 0, width, height, 0.5, 0.0, 1.0, 1.0);
|
||||
drawnRects++;
|
||||
}
|
||||
// Do less than full increments just as much as they take up on the scaled texture
|
||||
drawRectD(tessellator, 1 + (drawnRects * width), 0, 0, i, height, 0.5, 0.0, 0.5 + 0.25 * i, 1.0);
|
||||
tessellator.draw();
|
||||
|
||||
// Border
|
||||
drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
|
||||
|
||||
// Gradient
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.5F);
|
||||
mc.getTextureManager().bindTexture(gradientTexture);
|
||||
tessellator.startDrawingQuads();
|
||||
drawRect(tessellator, 1, 1, 0, maxStringW - 2, height - 2, 0, 0, 1, 1);
|
||||
tessellator.draw();
|
||||
|
||||
DisplayUtil.drawString(
|
||||
String.format("%s / %s RF", formatNumber.apply(amount), formatNumber.apply(capacity)),
|
||||
2,
|
||||
2,
|
||||
0xFFFFFFFF,
|
||||
true);
|
||||
|
||||
}
|
||||
|
||||
public static void drawRect(Tessellator tessellator, int x, int y, double z, int width, int height, double minU,
|
||||
double minV, double maxU, double maxV) {
|
||||
tessellator.addVertexWithUV(x, y + height, z, minU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + height, z, maxU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y, z, maxU, minV);
|
||||
tessellator.addVertexWithUV(x, y, z, minU, minV);
|
||||
}
|
||||
|
||||
public static void drawRectD(Tessellator tessellator, double x, double y, double z, double width, double height,
|
||||
double minU, double minV, double maxU, double maxV) {
|
||||
tessellator.addVertexWithUV(x, y + height, z, minU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y + height, z, maxU, maxV);
|
||||
tessellator.addVertexWithUV(x + width, y, z, maxU, minV);
|
||||
tessellator.addVertexWithUV(x, y, z, minU, minV);
|
||||
}
|
||||
|
||||
public static void drawThickBeveledBox(int x1, int y1, int x2, int y2, int thickness, int topleftcolor,
|
||||
int botrightcolor, int fillcolor) {
|
||||
if (fillcolor != -1) {
|
||||
Gui.drawRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
|
||||
}
|
||||
Gui.drawRect(x1, y1, x2 - 1, y1 + thickness, topleftcolor);
|
||||
Gui.drawRect(x1, y1, x1 + thickness, y2 - 1, topleftcolor);
|
||||
Gui.drawRect(x2 - thickness, y1, x2, y2 - 1, botrightcolor);
|
||||
Gui.drawRect(x1, y2 - thickness, x2, y2, botrightcolor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ public class NumberFormatter {
|
||||
|
||||
private static NumberFormat numberFormat = NumberFormat.getInstance(getCurrentLocale());
|
||||
|
||||
static {
|
||||
numberFormat.setGroupingUsed(true);
|
||||
}
|
||||
|
||||
public static String format(long number) {
|
||||
if (LoadedMods.GT5U) {
|
||||
return GTUtility.formatNumbers(number);
|
||||
@@ -30,5 +34,6 @@ public class NumberFormatter {
|
||||
|
||||
public static void onResourcesReload() {
|
||||
numberFormat = NumberFormat.getInstance(getCurrentLocale());
|
||||
numberFormat.setGroupingUsed(true);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,6 @@ option.ic2.consump=Show consumption
|
||||
option.ic2.tradeomat=Show Trade-O-Mat request
|
||||
option.thaumcraft.storedvis=Capacitor storage
|
||||
option.thermalexpansion.energyhandler=Show RF storage
|
||||
option.thermalexpansion.rfenergybar=Use Progress Bar for RF
|
||||
option.thermalexpansion.energycell=Show ECell IN/OUT
|
||||
option.thermalexpansion.fluidtype=Show fluid type
|
||||
option.thermalexpansion.fluidamount=Show fluid amount
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
Reference in new issue
Block a user