Interface ItemDecorator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Draws over an item wherever the game draws it in a GUI (inventory slots, the hotbar, a held stack...), after
vanilla's own decorations: the durability bar, the cooldown and the count. An item gets one by implementing
DecoratedItem on its class, which registers it by itself.
public final class FlaskChargesDecorator implements ItemDecorator {
@Override
public void extract(GuiGraphicsExtractor graphics, Font font, ItemStack stack, int x, int y) {
int charges = FlaskItem.charges(stack);
for (int i = 0; i < charges; i++) graphics.fill(x + 2 + i * 3, y + 13, x + 4 + i * 3, y + 15, 0xFF55FFFF);
}
}
An item is 16x16 at (x, y). To draw at the item texture's own resolution, scale the pose (a 32x32
texture's pixel is half a GUI pixel) and restore it. To leave vanilla's bar out, return false from the item's
isBarVisible.-
Method Summary
Modifier and TypeMethodDescriptionvoidextract(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.world.item.ItemStack stack, int x, int y)
-
Method Details
-
extract
void extract(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.Font font, net.minecraft.world.item.ItemStack stack, int x, int y) - Parameters:
x- the item's left, in GUI pixelsy- the item's top
-