Compare commits

...
5 Commits
Author SHA1 Message Date
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
5 changed files with 78 additions and 68 deletions

No files matched your search

@@ -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);
}
}
@@ -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
@@ -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
@@ -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