Class ItemOpacityRenderer
java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.gui.ItemOpacityRenderer
Items drawn in a GUI at an opacity, fixed or animated: a HUD card fading in with its icon, a slot greying out.
ItemOpacityRenderer.render(graphics, stack, x, y, 0.5F); // half see-through
ItemOpacityRenderer.renderWithDecorations(graphics, font, stack, x, y, 0.5F); // with its count and bar
var fade = ItemOpacityRenderer.OpacityTween.in(10).start(); // keep it, and draw each frame:
ItemOpacityRenderer.render(graphics, stack, x, y, fade);
ItemOpacityRenderer.withOpacity(0.5F, () -> graphics.item(stack, x, y)); // anything that draws items
The game draws GUI items from an atlas at full opacity, with no way to ask for less: each item drawn here remembers
the opacity it was asked for, and is blitted from the atlas with it, so solid and flat items fade alike. Inside
withOpacity(float, Runnable) the text and filled rectangles drawn (an item's count, its durability bar) fade too.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn opacity eased from one value to another over a time, for an item fading in or out. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidpushItemOpacity(float opacity) Fades the items drawn from now untilpopItemOpacity(), and only the items: for a caller that fades the rest of what it draws itself (a whole HUD faded between two hooks, say).static voidrender(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.world.item.ItemStack stack, int x, int y, float opacity) Draws an item asGuiGraphicsExtractor.fakeItem(ItemStack, int, int)does, at an opacity from 0 to 1.static voidrender(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.world.item.ItemStack stack, int x, int y, ItemOpacityRenderer.OpacityTween fade) Draws an item at the opacity a fade is at now.static voidrenderWithDecorations(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.world.item.ItemStack stack, int x, int y, float opacity) Draws an item with its count and durability bar, as a slot shows it, at an opacity from 0 to 1.static voidrenderWithDecorations(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.world.item.ItemStack stack, int x, int y, ItemOpacityRenderer.OpacityTween fade) Draws an item with its count and durability bar at the opacity a fade is at now.static voidwithOpacity(float opacity, Runnable draw) Runs drawing at an opacity from 0 to 1: the items, text and filled rectangles it draws are that much see-through (on top of any opacity already in force).
-
Method Details
-
render
public static void render(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.world.item.ItemStack stack, int x, int y, float opacity) Draws an item asGuiGraphicsExtractor.fakeItem(ItemStack, int, int)does, at an opacity from 0 to 1. -
render
public static void render(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.world.item.ItemStack stack, int x, int y, ItemOpacityRenderer.OpacityTween fade) Draws an item at the opacity a fade is at now. -
renderWithDecorations
public static void renderWithDecorations(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.world.item.ItemStack stack, int x, int y, float opacity) Draws an item with its count and durability bar, as a slot shows it, at an opacity from 0 to 1. -
renderWithDecorations
public static void renderWithDecorations(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.world.item.ItemStack stack, int x, int y, ItemOpacityRenderer.OpacityTween fade) Draws an item with its count and durability bar at the opacity a fade is at now. -
withOpacity
Runs drawing at an opacity from 0 to 1: the items, text and filled rectangles it draws are that much see-through (on top of any opacity already in force). Nothing is drawn at 0. -
pushItemOpacity
public static void pushItemOpacity(float opacity) Fades the items drawn from now untilpopItemOpacity(), and only the items: for a caller that fades the rest of what it draws itself (a whole HUD faded between two hooks, say). Calls nest; each push needs its pop. -
popItemOpacity
public static void popItemOpacity()
-