|
36 | 36 | import dev.emi.emi.api.render.EmiRenderable; |
37 | 37 | import dev.emi.emi.api.stack.EmiIngredient; |
38 | 38 | import dev.emi.emi.api.stack.EmiStack; |
| 39 | +import dev.emi.emi.api.widget.Bounds; |
39 | 40 | import dev.emi.emi.api.widget.SlotWidget; |
40 | 41 | import dev.emi.emi.api.widget.WidgetHolder; |
41 | 42 | import java.util.ArrayList; |
@@ -347,6 +348,31 @@ public void scrollableSlots(int cols, int rows, List<ItemStack> stacks) { |
347 | 348 | public EmiIngredient getStack() { |
348 | 349 | return EmiStack.of(pages.getStack(finalIndex)); |
349 | 350 | } |
| 351 | + |
| 352 | + @Override |
| 353 | + public void drawStack(GuiGraphics draw, int mouseX, int mouseY, float delta) { |
| 354 | + var stack = pages.getStack(finalIndex); |
| 355 | + |
| 356 | + Bounds bounds = getBounds(); |
| 357 | + int xOff = (bounds.width() - 16) / 2; |
| 358 | + int yOff = (bounds.height() - 16) / 2; |
| 359 | + |
| 360 | + // Draw count separately to handle amounts >= 100 reasonably |
| 361 | + int stackX = bounds.x() + xOff; |
| 362 | + int stackY = bounds.y() + yOff; |
| 363 | + EmiStack.of(stack, 1).render(draw, stackX, stackY, delta); |
| 364 | + var amount = Component.literal(String.valueOf(stack.getCount())); |
| 365 | + // Could use 1.0 if the count is < 100, but this looks more uniform |
| 366 | + float scale = 0.8f; |
| 367 | + |
| 368 | + draw.pose().pushPose(); |
| 369 | + draw.pose().translate(0, 0, 200); |
| 370 | + int tx = stackX + 17 - Math.min(14, Math.round(Minecraft.getInstance().font.width(amount) * scale)) - 1; |
| 371 | + draw.pose().translate(tx, stackY + 9, 0); |
| 372 | + draw.pose().scale(scale, scale, 1); |
| 373 | + draw.drawString(Minecraft.getInstance().font, amount, 0, 0, -1, true); |
| 374 | + draw.pose().popPose(); |
| 375 | + } |
350 | 376 | }); |
351 | 377 | } |
352 | 378 | for (; index < pageSize; index++) { |
|
0 commit comments