• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / CyclopsCore / #479033547

17 Mar 2024 09:56AM CUT coverage: 22.398% (+0.2%) from 22.159%
#479033547

push

github

rubensworks
Update to NeoForge 1.20.4

5 of 635 new or added lines in 138 files covered. (0.79%)

39 existing lines in 26 files now uncovered.

2300 of 10269 relevant lines covered (22.4%)

0.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/cyclopscore/client/gui/GuiGraphicsExtended.java
1
package org.cyclops.cyclopscore.client.gui;
2

3
import net.minecraft.client.Minecraft;
4
import net.minecraft.client.gui.Font;
5
import net.minecraft.client.gui.GuiGraphics;
6
import net.minecraft.client.player.LocalPlayer;
7
import net.minecraft.client.renderer.RenderType;
8
import net.minecraft.util.Mth;
9
import net.minecraft.world.item.ItemStack;
10
import net.neoforged.api.distmarker.Dist;
11
import net.neoforged.api.distmarker.OnlyIn;
12
import org.cyclops.cyclopscore.helper.GuiHelpers;
13
import org.jetbrains.annotations.Nullable;
14

15
/**
16
 * Additional helper functions related to {@link GuiGraphics}.
17
 * @author rubensworks
18
 */
19
@OnlyIn(Dist.CLIENT)
20
public class GuiGraphicsExtended {
21

22
    private final GuiGraphics guiGraphics;
23

24
    public GuiGraphicsExtended(GuiGraphics guiGraphics) {
×
25
        this.guiGraphics = guiGraphics;
×
26
    }
×
27

28
    public void drawSlotText(Font font, @javax.annotation.Nullable String text, int x, int y) { // Abstracted for reuse
29
        guiGraphics.pose().pushPose();
×
30
        guiGraphics.pose().translate(0.0F, 0.0F, 200.0F);
×
31
        float scale = 0.5f; // This part was added
×
32
        guiGraphics.pose().scale(scale, scale, 1.0f); // This part was added
×
33
        guiGraphics.drawString(font, text, (x + 19 - 2) / scale - font.width(text), (float)(y + 6 + 6) / scale, 16777215, true); // Scale was added here
×
34
        guiGraphics.pose().popPose();
×
35
    }
×
36

37
    public void renderItemDecorations(Font font, ItemStack stack, int x, int y) {
38
        this.renderItemDecorations(font, stack, x, y, (String)null);
×
39
    }
×
40

41
    public void renderItemDecorations(Font font, ItemStack stack, int x, int y, @Nullable String text) {
42
        // ----- Copied and adjusted from GuiGraphics#renderItemDecorations -----
43
        if (!stack.isEmpty()) {
×
44
            guiGraphics.pose().pushPose();
×
45
            if (stack.getCount() != 1 || text != null) {
×
46
                String s = text == null ? GuiHelpers.quantityToScaledString(stack.getCount()) : text; // This part was changed
×
47
                drawSlotText(font, s, x, y); // New function
×
48
            }
49

50
            if (stack.isBarVisible()) {
×
51
                int l = stack.getBarWidth();
×
52
                int i = stack.getBarColor();
×
53
                int j = x + 2;
×
54
                int k = y + 13;
×
55
                guiGraphics.fill(RenderType.guiOverlay(), j, k, j + 13, k + 2, -16777216);
×
56
                guiGraphics.fill(RenderType.guiOverlay(), j, k, j + l, k + 1, i | -16777216);
×
57
            }
58

59
            Minecraft minecraft = Minecraft.getInstance();
×
60
            LocalPlayer localplayer = minecraft.player;
×
61
            float f = localplayer == null ? 0.0F : localplayer.getCooldowns().getCooldownPercent(stack.getItem(), minecraft.getFrameTime());
×
62
            if (f > 0.0F) {
×
63
                int i1 = y + Mth.floor(16.0F * (1.0F - f));
×
64
                int j1 = i1 + Mth.ceil(16.0F * f);
×
65
                guiGraphics.fill(RenderType.guiOverlay(), x, i1, x + 16, j1, Integer.MAX_VALUE);
×
66
            }
67

68
            guiGraphics.pose().popPose();
×
NEW
69
            net.neoforged.neoforge.client.ItemDecoratorHandler.of(stack).render(guiGraphics, font, stack, x, y);
×
70
        }
71
    }
×
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc