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

CyclopsMC / IntegratedDynamics / 16552051255

27 Jul 2025 01:58PM UTC coverage: 53.206% (+8.0%) from 45.161%
16552051255

push

github

rubensworks
Resolve minor TODOs

2888 of 8740 branches covered (33.04%)

Branch coverage included in aggregate %.

17341 of 29280 relevant lines covered (59.22%)

3.08 hits per line

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

0.0
/src/main/java/org/cyclops/integrateddynamics/core/client/gui/subgui/SubGuiBox.java
1
package org.cyclops.integrateddynamics.core.client.gui.subgui;
2

3
import com.google.common.collect.Lists;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.client.gui.Font;
6
import net.minecraft.client.gui.GuiGraphics;
7
import net.minecraft.client.gui.components.Button;
8
import net.minecraft.client.renderer.RenderPipelines;
9
import net.minecraft.client.renderer.texture.TextureManager;
10
import net.minecraft.resources.ResourceLocation;
11
import org.cyclops.integrateddynamics.Reference;
12
import org.cyclops.integrateddynamics.api.client.gui.subgui.ISubGuiBox;
13

14
import java.util.List;
15

16
/**
17
 * A sub gui that simply renders a box.
18
 * @author rubensworks
19
 */
20
public abstract class SubGuiBox implements ISubGuiBox {
21

22
    protected static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "textures/gui/sub_gui.png");
×
23

24
    private final Box type;
25

26
    protected List<Button> buttonList = Lists.newArrayList();
×
27
    protected final SubGuiHolder subGuiHolder = new SubGuiHolder();
×
28

29
    public SubGuiBox(Box type) {
×
30
        this.type = type;
×
31
    }
×
32

33
    @Override
34
    public void init(int guiLeft, int guiTop) {
35
        buttonList.clear();
×
36
        subGuiHolder.init(guiLeft, guiTop);
×
37
    }
×
38

39
    public void drawScreen(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
40
        for (int i = 0; i < this.buttonList.size(); ++i) {
×
41
            this.buttonList.get(i).render(guiGraphics, mouseX, mouseY, partialTicks);
×
42
        }
43
    }
×
44

45
    protected boolean isDrawBackground() {
46
        return true;
×
47
    }
48

49
    @Override
50
    public void renderBg(GuiGraphics guiGraphics, int guiLeft, int guiTop, TextureManager textureManager, Font fontRenderer, float partialTicks, int mouseX, int mouseY) {
51
        if (this.isDrawBackground()) {
×
52
            int textureWidth = 19;
×
53
            int textureHeight = textureWidth;
×
54

55
            int x = guiLeft + getX();
×
56
            int y = guiTop + getY();
×
57
            int width = getWidth();
×
58
            int height = getHeight();
×
59
            int tx = type.getX();
×
60
            int ty = type.getY();
×
61

62
            // Corners
63
            guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x, y, tx, tx, 1, 1, 256, 256); // top left
×
64
            guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x + width - 1, y, tx + textureWidth - 1, ty, 1, 1, 256, 256); // top right
×
65
            guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x, y + height - 1, 0, tx + textureHeight - 1, ty + 1, 1, 256, 256); // bottom left
×
66
            guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x + width - 1, y + height - 1, tx + textureWidth - 1, ty + textureHeight - 1, 1, 1, 256, 256); // bottom right
×
67

68
            int i, j;
69

70
            // Sides
71
            i = 1;
×
72
            while (i < width - 1) {
×
73
                int currentWidth = Math.max(1, Math.min(width - i, textureWidth - 2) - 1);
×
74
                guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x + i, y, tx + 1, ty, currentWidth, 1, 256, 256);
×
75
                guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x + i, y + height - 1, tx + 1, ty + textureHeight - 1, currentWidth, 1, 256, 256);
×
76
                i += currentWidth;
×
77
            }
×
78

79
            i = 1;
×
80
            while (i < height - 1) {
×
81
                int currentHeight = Math.max(1, Math.min(height - i, textureHeight - 2) - 1);
×
82
                guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x, y + i, tx, ty + 1, 1, currentHeight, 256, 256);
×
83
                guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x + width - 1, y + i, tx + textureWidth - 1, ty + 1, 1, currentHeight, 256, 256);
×
84
                i += currentHeight;
×
85
            }
×
86

87
            // Center
88
            i = 1;
×
89
            while (i < width - 1) {
×
90
                int currentWidth = Math.max(1, Math.min(width - i, textureWidth - 2) - 1);
×
91
                j = 1;
×
92
                while (j < height - 1) {
×
93
                    int currentHeight = Math.max(1, Math.min(height - j, textureHeight - 2) - 1);
×
94
                    guiGraphics.blit(RenderPipelines.GUI_TEXTURED, TEXTURE, x + i, y + j, tx + 1, ty + 1, currentWidth, currentHeight, 256, 256);
×
95
                    j += currentHeight;
×
96
                }
×
97
                i += currentWidth;
×
98
            }
×
99
        }
100

101
        // Draw buttons
102
        drawScreen(guiGraphics, mouseX, mouseY, partialTicks);
×
103

104
        subGuiHolder.renderBg(guiGraphics, guiLeft, guiTop, textureManager, fontRenderer, partialTicks, mouseX, mouseY);
×
105
    }
×
106

107
    @Override
108
    public void drawGuiContainerForegroundLayer(GuiGraphics guiGraphics, int guiLeft, int guiTop, TextureManager textureManager, Font fontRenderer, int mouseX, int mouseY) {
109
        subGuiHolder.drawGuiContainerForegroundLayer(guiGraphics, guiLeft, guiTop, textureManager, fontRenderer, mouseX, mouseY);
×
110
    }
×
111

112
    @Override
113
    public boolean charTyped(char typedChar, int keyCode) {
114
        return subGuiHolder.charTyped(typedChar, keyCode);
×
115
    }
116

117
    @Override
118
    public boolean keyPressed(int typedChar, int keyCode, int modifiers) {
119
        return subGuiHolder.keyPressed(typedChar, keyCode, modifiers);
×
120
    }
121

122
    @Override
123
    public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
124
        subGuiHolder.mouseClicked(mouseX, mouseY, mouseButton);
×
125
        for (int i = 0; i < this.buttonList.size(); ++i) {
×
126
            Button guibutton = this.buttonList.get(i);
×
127
            if (guibutton.mouseClicked(mouseX, mouseY, mouseButton)) {
×
128
                guibutton.playDownSound(Minecraft.getInstance().getSoundManager());
×
129
                this.actionPerformed(guibutton);
×
130
                return true;
×
131
            }
132
        }
133
        return false;
×
134
    }
135

136
    protected void actionPerformed(Button guibutton) {
137

138
    }
×
139

140
    public static enum Box {
×
141

142
        LIGHT(0, 0),
×
143
        DARK(0, 19);
×
144

145
        private final int x, y;
146

147
        private Box(int x, int y) {
×
148
            this.x = x;
×
149
            this.y = y;
×
150
        }
×
151

152
        public int getX() {
153
            return this.x;
×
154
        }
155

156
        public int getY() {
157
            return this.y;
×
158
        }
159

160
    }
161

162
    public static class Base extends SubGuiBox {
163

164
        private final int x, y, width, height;
165

166
        public Base(Box type, int x, int y, int width, int height) {
167
            super(type);
×
168
            this.x = x;
×
169
            this.y = y;
×
170
            this.width = width;
×
171
            this.height = height;
×
172
        }
×
173

174
        @Override
175
        public int getX() {
176
            return x;
×
177
        }
178

179
        @Override
180
        public int getY() {
181
            return y;
×
182
        }
183

184
        @Override
185
        public int getWidth() {
186
            return width;
×
187
        }
188

189
        @Override
190
        public int getHeight() {
191
            return height;
×
192
        }
193

194
        @Override
195
        public void init(int guiLeft, int guiTop) {
196

197
        }
×
198

199
        @Override
200
        public void tick() {
201

202
        }
×
203

204
        @Override
205
        public boolean charTyped(char typedChar, int keyCode) {
206
            return false;
×
207
        }
208

209
        @Override
210
        public boolean keyPressed(int typedChar, int keyCode, int modifiers) {
211
            return false;
×
212
        }
213

214
        @Override
215
        public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
216
            return super.mouseClicked(mouseX, mouseY, mouseButton);
×
217
        }
218

219
    }
220

221
}
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

© 2026 Coveralls, Inc