Compare commits

...
10 Commits
Author SHA1 Message Date
UltraProdigy d5669e3000 ci: run build and test on release branches 2026-11-09 01:43:44 -05:00
evgengoldwarandMartin Robertz f998f9ebfe Fix TTRenderStack (#75)
Co-authored-by: Martin Robertz <[email protected]>
2026-08-24 00:08:51 +07:00
evgengoldwar 6d0f162453 Add ColorUtils (#74) 2026-08-23 13:27:35 +02:00
evgengoldwar 9e3ef39e30 Improve progress bar (#73) 2026-08-22 23:16:21 -04:00
SuperSoupr 452fbfa47c Change progress bars lengths (#71) 2026-07-19 13:47:43 +03:00
Guillaume MercierandGuillaume Mercier d8477007c9 Add compat for fluid colors for non GT5u fluids (#69)
Co-authored-by: Guillaume Mercier <[email protected]>
2026-06-05 16:01:44 -04:00
flamingowrangler2869 bd5905dfc0 fix comparator "substractor" mode spelling (#70) 2026-05-24 00:26:01 +00:00
Algent 80e761d83f Allow Waila to handle bigger NBT packet (#68) 2026-05-12 14:12:37 +02:00
MalTeeezandgithub-actions[bot] ef0f8b5329 Prevent overflowing of bars in tooltip renderers (#66)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-05-11 18:50:24 +02:00
Alexdoru 65e4a773d0 [Memory-opti:fix leak] fix client leak from DataAccessorFMP (#65) 2026-05-10 20:19:36 +02:00
16 changed files with 341 additions and 149 deletions

No files matched your search

+2 -2
View File
@@ -3,9 +3,9 @@ name: Build and test
on:
pull_request:
branches: [ master, main ]
branches: [ master, main, release/** ]
push:
branches: [ master, main ]
branches: [ master, main, release/** ]
jobs:
build-and-test:
+1 -1
View File
@@ -20,5 +20,5 @@ dependencies {
runtimeOnlyNonPublishable(deobfCurse('thermal-expansion-69163:2388759'))
runtimeOnlyNonPublishable(deobfCurse('thermal-dynamics-227443:2388756'))
implementation(deobfCurse('cofh-core-69162:2388751'))
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
api("com.github.GTNewHorizons:GTNHLib:0.11.37:dev")
}
@@ -2,21 +2,29 @@ package mcp.mobius.waila.addons.vanillamc;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameData;
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.api.impl.ModuleRegistrar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
import mcp.mobius.waila.utils.ColorUtils;
public class HUDHandlerFurnace implements IWailaDataProvider {
static Block furanace = Blocks.furnace;
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
@@ -31,45 +39,68 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
int cookTime = accessor.getNBTData().getShort("CookTime");
NBTTagList tag = accessor.getNBTData().getTagList("Items", 10);
NBTTagCompound tag = accessor.getNBTData();
NBTTagList items = accessor.getNBTData().getTagList("Items", 10);
String itemsText = "";
ItemStack inputStack = null;
ItemStack fuelStack = null;
ItemStack outputStack = null;
String renderStr = "";
{
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(0));
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
renderStr += SpecialChars.getRenderString(
"waila.stack",
"1",
name,
String.valueOf(stack.stackSize),
String.valueOf(stack.getItemDamage()));
}
{
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(1));
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
renderStr += SpecialChars.getRenderString(
"waila.stack",
"1",
name,
String.valueOf(stack.stackSize),
String.valueOf(stack.getItemDamage()));
int smeltTime = tag.getInteger("Smelt");
int fuelTime = tag.getInteger("Fuel");
int maxFuelTime = tag.getInteger("MaxFuel");
double smeltProgress = (double) smeltTime / 200;
double fuelProgress = (double) fuelTime / maxFuelTime;
for (int i = 0; i < items.tagCount(); i++) {
NBTTagCompound itemTag = items.getCompoundTagAt(i);
byte slot = itemTag.getByte("Slot");
ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag);
if (slot == 0) {
inputStack = stack;
} else if (slot == 1) {
fuelStack = stack;
} else if (slot == 2) {
outputStack = stack;
}
}
renderStr += SpecialChars.getRenderString("waila.progress", String.valueOf(cookTime), String.valueOf(200));
{
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(2));
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
renderStr += SpecialChars.getRenderString(
"waila.stack",
"1",
name,
String.valueOf(stack.stackSize),
String.valueOf(stack.getItemDamage()));
if (fuelProgress > 0) {
String fuelBar = TTRenderBar.create(
String.format("Fuel %ds / %ds", (maxFuelTime - fuelTime) / 20, maxFuelTime / 20),
ColorUtils.fuelFurnaceBarTop.getColor(),
ColorUtils.fuelFurnaceBarBottom.getColor(),
1.0 - fuelProgress);
currenttip.add(fuelBar);
}
currenttip.add(renderStr);
if (smeltProgress > 0) {
String cookBar = TTRenderBar.create(
String.format("Smelt %ds / %ds", smeltTime / 20, 200 / 20),
ColorUtils.progressBarTop.getColor(),
ColorUtils.progressBarBottom.getColor(),
smeltProgress);
currenttip.add(cookBar);
}
if (inputStack != null) {
itemsText += TTRenderStack.create(inputStack, inputStack.stackSize);
}
if (fuelStack != null) {
itemsText += TTRenderStack.create(fuelStack, fuelStack.stackSize);
}
if (outputStack != null) {
if (inputStack != null || fuelStack != null) {
itemsText += TTRenderProgressBar.create(0, 1);
}
itemsText += TTRenderStack.create(outputStack, outputStack.stackSize);
}
currenttip.add(itemsText);
return currenttip;
}
@@ -83,9 +114,19 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
if (te != null) te.writeToNBT(tag);
if (te instanceof TileEntityFurnace furnace) {
tag.setInteger("Smelt", furnace.furnaceCookTime);
tag.setInteger("Fuel", furnace.furnaceBurnTime);
tag.setInteger("MaxFuel", furnace.currentItemBurnTime);
te.writeToNBT(tag);
}
return tag;
}
public static void register() {}
public static void register() {
IWailaDataProvider provider = new HUDHandlerFurnace();
ModuleRegistrar.instance().registerBodyProvider(provider, furanace.getClass());
ModuleRegistrar.instance().registerNBTProvider(provider, furanace.getClass());
}
}
@@ -12,18 +12,18 @@ import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorFMP implements IWailaFMPAccessor {
String id;
World world;
EntityPlayer player;
MovingObjectPosition mop;
Vec3 renderingvec = null;
TileEntity entity;
NBTTagCompound partialNBT = null;
NBTTagCompound remoteNBT = null;
long timeLastUpdate = System.currentTimeMillis();
double partialFrame;
public static final DataAccessorFMP instance = new DataAccessorFMP();
public static DataAccessorFMP instance = new DataAccessorFMP();
private String id;
private World world;
private EntityPlayer player;
private MovingObjectPosition mop;
private Vec3 renderingvec;
private TileEntity tileEntity;
private NBTTagCompound partialNBT;
private double partialFrame;
private DataAccessorFMP() {}
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, NBTTagCompound _partialNBT,
String id) {
@@ -35,13 +35,24 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
this.world = _world;
this.player = _player;
this.mop = _mop;
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
this.partialNBT = _partialNBT;
this.id = id;
this.renderingvec = renderVec;
this.partialFrame = partialTicks;
}
public void reset() {
id = null;
world = null;
player = null;
mop = null;
renderingvec = null;
tileEntity = null;
partialNBT = null;
partialFrame = 0.0D;
}
@Override
public World getWorld() {
return this.world;
@@ -54,7 +65,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
@Override
public TileEntity getTileEntity() {
return this.entity;
return this.tileEntity;
}
@Override
@@ -69,12 +80,9 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
@Override
public NBTTagCompound getFullNBTData() {
if (this.entity == null) return null;
if (this.isTagCorrect(this.remoteNBT)) return this.remoteNBT;
if (this.tileEntity == null) return null;
NBTTagCompound tag = new NBTTagCompound();
this.entity.writeToNBT(tag);
this.tileEntity.writeToNBT(tag);
return tag;
}
@@ -98,20 +106,4 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
return this.id;
}
private boolean isTagCorrect(NBTTagCompound tag) {
if (tag == null) {
this.timeLastUpdate = System.currentTimeMillis() - 250;
return false;
}
int x = tag.getInteger("x");
int y = tag.getInteger("y");
int z = tag.getInteger("z");
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) return true;
else {
this.timeLastUpdate = System.currentTimeMillis() - 250;
return false;
}
}
}
@@ -17,6 +17,7 @@ import mcp.mobius.waila.handlers.HUDHandlerEntities;
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
import mcp.mobius.waila.handlers.nei.NEIHandler;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderAspectString;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
@@ -55,6 +56,7 @@ public class ProxyClient extends ProxyServer {
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
ModuleRegistrar.instance().registerTooltipRenderer("waila.bar", new TTRenderBar());
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
ModuleRegistrar.instance().registerTooltipRenderer("waila.rfenergy", new TTRenderRFBar());
@@ -35,9 +35,13 @@ public class DecoratorFMP implements IWailaBlockDecorator {
accessor.getRenderingPosition(),
accessor.getPartialFrame());
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id).values())
for (IWailaFMPDecorator provider : providersList)
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id)
.values()) {
for (IWailaFMPDecorator provider : providersList) {
provider.decorateBlock(itemStack, DataAccessorFMP.instance, config);
}
}
DataAccessorFMP.instance.reset();
}
}
}
@@ -41,9 +41,11 @@ public class HUDHandlerFMP implements IWailaDataProvider {
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getHeadFMPProviders(id)
.values()) {
for (IWailaFMPProvider provider : providersList)
for (IWailaFMPProvider provider : providersList) {
currenttip = provider.getWailaHead(itemStack, currenttip, DataAccessorFMP.instance, config);
}
}
DataAccessorFMP.instance.reset();
}
}
@@ -64,9 +66,11 @@ public class HUDHandlerFMP implements IWailaDataProvider {
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getBodyFMPProviders(id)
.values()) {
for (IWailaFMPProvider provider : providersList)
for (IWailaFMPProvider provider : providersList) {
currenttip = provider.getWailaBody(itemStack, currenttip, DataAccessorFMP.instance, config);
}
}
DataAccessorFMP.instance.reset();
}
}
@@ -87,9 +91,11 @@ public class HUDHandlerFMP implements IWailaDataProvider {
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getTailFMPProviders(id)
.values()) {
for (IWailaFMPProvider provider : providersList)
for (IWailaFMPProvider provider : providersList) {
currenttip = provider.getWailaTail(itemStack, currenttip, DataAccessorFMP.instance, config);
}
}
DataAccessorFMP.instance.reset();
}
}
@@ -90,20 +90,20 @@ public enum WailaPacketHandler {
}
public void writeNBT(ByteBuf target, NBTTagCompound tag) throws IOException {
if (tag == null) target.writeShort(-1);
if (tag == null) target.writeInt(-1);
else {
byte[] abyte = CompressedStreamTools.compress(tag);
target.writeShort((short) abyte.length);
target.writeInt(abyte.length);
target.writeBytes(abyte);
}
}
public NBTTagCompound readNBT(ByteBuf dat) throws IOException {
short short1 = dat.readShort();
int val = dat.readInt();
if (short1 < 0) return null;
if (val < 0) return null;
else {
byte[] abyte = new byte[short1];
byte[] abyte = new byte[val];
dat.readBytes(abyte);
return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a);
}
@@ -179,4 +179,23 @@ public class DisplayUtil {
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
}
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 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);
}
}
@@ -0,0 +1,107 @@
package mcp.mobius.waila.overlay.tooltiprenderers;
import java.awt.Dimension;
import net.minecraft.client.gui.Gui;
import mcp.mobius.waila.api.IWailaCommonAccessor;
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
import mcp.mobius.waila.api.SpecialChars;
import mcp.mobius.waila.overlay.DisplayUtil;
public class TTRenderBar implements IWailaVariableWidthTooltipRenderer {
private int maxStringW;
private static final int HEIGHT = 12;
@Override
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
String text = params[0];
int displayWidth = DisplayUtil.getDisplayWidth(text);
return new Dimension(displayWidth + 4, HEIGHT);
}
@Override
public void draw(String[] params, IWailaCommonAccessor accessor) {
String text = params[0];
int topColor = 0xFFFFEE55;
int bottomColor = 0xFFFFA500;
int fillWidth = maxStringW - 2;
if (params.length > 2) {
try {
topColor = Integer.parseInt(params[1]);
bottomColor = Integer.parseInt(params[2]);
} catch (NumberFormatException ignored) {}
}
if (params.length > 3) {
try {
double ratio = Double.parseDouble(params[3]);
ratio = Math.max(0.0, Math.min(1.0, ratio));
fillWidth = (int) ((maxStringW - 2) * ratio);
} catch (NumberFormatException ignored) {}
}
drawVerticalGradient(maxStringW - 1, 0xFF2A2A2A, 0xFF111111);
if (fillWidth > 0) {
drawVerticalGradient(1 + fillWidth, topColor, bottomColor);
}
DisplayUtil.drawThickBeveledBox(0, 0, maxStringW, HEIGHT, 1, 0xFF505050, 0xFF505050, -1);
DisplayUtil.drawString(text, 2, 2, 0xFFFFFFFF, true);
}
@Override
public void setMaxLineWidth(int width) {
maxStringW = width;
}
@Override
public int getMaxLineWidth() {
return maxStringW;
}
private void drawVerticalGradient(int x2, int topColor, int bottomColor) {
int h = 11;
if (x2 <= 1) {
return;
}
for (int i = 0; i < h; i++) {
float ratio = (float) i / (float) h;
int color = blendColors(topColor, bottomColor, ratio);
Gui.drawRect(1, i, x2, i + 1, color);
}
}
private int blendColors(int c1, int c2, float ratio) {
int a1 = (c1 >> 24 & 0xFF), r1 = (c1 >> 16 & 0xFF), g1 = (c1 >> 8 & 0xFF), b1 = (c1 & 0xFF);
int a2 = (c2 >> 24 & 0xFF), r2 = (c2 >> 16 & 0xFF), g2 = (c2 >> 8 & 0xFF), b2 = (c2 & 0xFF);
int a = (int) (a1 + (a2 - a1) * ratio);
int r = (int) (r1 + (r2 - r1) * ratio);
int g = (int) (g1 + (g2 - g1) * ratio);
int b = (int) (b1 + (b2 - b1) * ratio);
return (a << 24) | (r << 16) | (g << 8) | b;
}
public static String create(String text, int topColor, int bottomColor, double progress) {
return SpecialChars.getRenderString(
"waila.bar",
text,
String.valueOf(topColor),
String.valueOf(bottomColor),
String.valueOf(progress));
}
public static String create(String text, int color, double progress) {
return create(text, color, color, progress);
}
}
@@ -12,14 +12,12 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import gregtech.api.util.GTUtil;
import gregtech.common.fluid.GTFluid;
import gtPlusPlus.api.objects.minecraft.FluidGT6;
import gtPlusPlus.core.util.minecraft.FluidUtils;
import mcp.mobius.waila.api.IWailaCommonAccessor;
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
@@ -37,17 +35,39 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
public TTRenderFluidBar() {
if (LoadedMods.GT5U) {
bindColor = (fluidName) -> {
FluidStack aCheck = FluidUtils.getWildcardFluidStack(fluidName, 1000);
if (aCheck != null && (aCheck.getFluid() instanceof FluidGT6 || aCheck.getFluid() instanceof GTFluid)) {
short[] RGBa = GTUtil.getRGBaArray(aCheck.getFluid().getColor());
GL11.glColor4f(RGBa[0] / 255F, RGBa[1] / 255F, RGBa[2] / 255F, 1F);
} else {
GL11.glColor4f(1F, 1F, 1F, 1F);
FluidStack tFStack = FluidUtils.getWildcardFluidStack(fluidName, 1000);
if (tFStack == null) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return;
}
Fluid tFluid = tFStack.getFluid();
if (tFluid == null) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return;
}
// duplicate code to prevent extra stack allocations
int tColor = tFluid.getColor();
float r = ((tColor >>> 16) & 0xFF) / (float) 0xFF;
float g = ((tColor >>> 8) & 0xFF) / (float) 0xFF;
float b = (tColor & 0xFF) / (float) 0xFF;
GL11.glColor4f(r, g, b, 1.0F);
};
} else {
bindColor = (fluidName) -> GL11.glColor4f(1F, 1F, 1F, 1F);
bindColor = (fluidName) -> {
Fluid tFluid = FluidRegistry.getFluid(fluidName);
if (tFluid == null) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return;
}
// duplicate code to prevent extra stack allocations
int tColor = tFluid.getColor();
float r = ((tColor >>> 16) & 0xFF) / (float) 0xFF;
float g = ((tColor >>> 8) & 0xFF) / (float) 0xFF;
float b = (tColor & 0xFF) / (float) 0xFF;
GL11.glColor4f(r, g, b, 1.0F);
};
}
}
@Override
@@ -83,13 +103,13 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
tessellator.startDrawingQuads();
// Intentionally draw 2 pixels taller than needed than cover with the border to make the texture more
// visible
int i = (int) ((double) (maxStringW - 2) * amount / capacity);
int i = (int) ((double) (maxStringW - 2) * (amount / Math.max(capacity, amount)));
int j = 0;
for (; i > height; i = i - height) {
drawRectFromIcon(tessellator, 1 + (j * height), 0, 0, icon, height, height);
j++;
}
if (i > 0) drawRect(
if (i > 0) DisplayUtil.drawRect(
tessellator,
1 + (j * height),
0,
@@ -108,13 +128,13 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
GL11.glColor4f(1F, 1F, 1F, 0.70F);
mc.getTextureManager().bindTexture(gradient);
tessellator.startDrawingQuads();
drawRect(tessellator, 1, 0, 0, maxStringW - 2, height - 1, 0, 0, 1, 1);
DisplayUtil.drawRect(tessellator, 1, 0, 0, maxStringW - 2, height - 1, 0, 0, 1, 1);
tessellator.draw();
} else {
Gui.drawRect(1, 0, maxStringW - 1, height - 1, 0x1A575656);
}
drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
DisplayUtil.drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
DisplayUtil.drawString(
buildDisplayText(amount, capacity, localizedName, isEmpty),
@@ -131,31 +151,22 @@ public class TTRenderFluidBar implements IWailaVariableWidthTooltipRenderer {
public static void drawRectFromIcon(Tessellator tessellator, int x, int y, double z, IIcon icon, int width,
int height) {
drawRect(tessellator, x, y, z, width, height, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV());
}
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 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);
DisplayUtil.drawRect(
tessellator,
x,
y,
z,
width,
height,
icon.getMinU(),
icon.getMinV(),
icon.getMaxU(),
icon.getMaxV());
}
@Override
public void setMaxLineWidth(int width) {
maxStringW = width + 2;
maxStringW = width;
}
@Override
@@ -7,6 +7,7 @@ import net.minecraft.util.ResourceLocation;
import mcp.mobius.waila.api.IWailaCommonAccessor;
import mcp.mobius.waila.api.IWailaTooltipRenderer;
import mcp.mobius.waila.api.SpecialChars;
import mcp.mobius.waila.overlay.DisplayUtil;
public class TTRenderProgressBar implements IWailaTooltipRenderer {
@@ -33,4 +34,8 @@ public class TTRenderProgressBar implements IWailaTooltipRenderer {
}
public static String create(int currentValue, int maxValue) {
return SpecialChars.getRenderString("waila.progress", String.valueOf(currentValue), String.valueOf(maxValue));
}
}
@@ -5,7 +5,6 @@ import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.fo
import java.awt.Dimension;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
@@ -47,13 +46,13 @@ public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
// 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);
DisplayUtil.drawRect(tessellator, 1 + i, 0, 0, width, height, 0.0, 0.0, 0.5, 1.0);
}
double i = (double) (maxStringW - 2) * amount / capacity;
double i = (double) (maxStringW - 2) * ((double) amount / Math.max(capacity, amount));
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);
DisplayUtil.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
@@ -61,14 +60,14 @@ public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
tessellator.draw();
// Border
drawThickBeveledBox(0, 0, maxStringW, height, 1, 0xFF505050, 0xFF505050, -1);
DisplayUtil.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);
DisplayUtil.drawRect(tessellator, 1, 1, 0, maxStringW - 2, height - 2, 0, 0, 1, 1);
tessellator.draw();
DisplayUtil.drawString(buildDisplayText(amount, capacity), 2, 2, 0xFFFFFFFF, true);
@@ -78,14 +77,6 @@ public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
return String.format("%s / %s RF", formatNumber(amount), formatNumber(capacity));
}
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);
@@ -94,20 +85,9 @@ public class TTRenderRFBar implements IWailaVariableWidthTooltipRenderer {
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;
maxStringW = width;
}
@Override
@@ -44,7 +44,7 @@ public class TTRenderStack implements IWailaTooltipRenderer {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glScaled(scale, scale, 1.0f);
DisplayUtil.renderStack(0, 0, stack);
DisplayUtil.renderStack(0, -1, stack);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
@@ -69,4 +69,12 @@ public class TTRenderStack implements IWailaTooltipRenderer {
public static String create(ItemStack itemStack, boolean small) {
return create(itemStack, 1, small);
}
public static String create(ItemStack itemStack) {
return create(itemStack, false);
}
public static String create(ItemStack itemStack, int amount) {
return create(itemStack, amount, false);
}
}
@@ -0,0 +1,17 @@
package mcp.mobius.waila.utils;
import com.gtnewhorizon.gtnhlib.color.ColorResource;
public class ColorUtils {
private static final ColorResource.Factory color = new ColorResource.Factory("waila");
public static final ColorResource
// spotless:off
fuelFurnaceBarTop = color.argb("fuelFurnaceBarTop", "0xFFFF8800"),
fuelFurnaceBarBottom = color.argb("fuelFurnaceBarBottom", "0xFFFFCC00"),
progressBarTop = color.argb("progressBarTop", "0xFFFF0000"),
progressBarBottom = color.argb("progressBarBottom", "0xFF8B0000");
// spotless:on
}
@@ -92,7 +92,7 @@ hud.msg.on=On
hud.msg.state=State
hud.msg.delay=Delay
hud.msg.comparator=Comparator
hud.msg.substractor=Substractor
hud.msg.substractor=Subtractor
hud.msg.record=Record
hud.msg.offers=Offers
@@ -155,4 +155,4 @@ option.general.showhp=Show entities health
option.general.showcrop=Show crop growth
option.thaumcraft.aspects=Show aspects
nei.options.keys.showenchant=Show enchanting values
nei.options.keys.showenchant=Show enchanting values