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

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 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.input.CharacterEvent;
9
import net.minecraft.client.input.KeyEvent;
10
import net.minecraft.client.input.MouseButtonEvent;
11
import net.minecraft.client.renderer.RenderPipelines;
12
import net.minecraft.client.renderer.texture.TextureManager;
13
import net.minecraft.resources.ResourceLocation;
14
import org.cyclops.integrateddynamics.Reference;
15
import org.cyclops.integrateddynamics.api.client.gui.subgui.ISubGuiBox;
16

17
import java.util.List;
18

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

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

27
    private final Box type;
28

29
    protected List<Button> buttonList = Lists.newArrayList();
×
30
    protected final SubGuiHolder subGuiHolder = new SubGuiHolder();
×
31

32
    public SubGuiBox(Box type) {
×
33
        this.type = type;
×
34
    }
×
35

36
    @Override
37
    public void init(int guiLeft, int guiTop) {
38
        buttonList.clear();
×
39
        subGuiHolder.init(guiLeft, guiTop);
×
40
    }
×
41

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

48
    protected boolean isDrawBackground() {
49
        return true;
×
50
    }
51

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

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

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

71
            int i, j;
72

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

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

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

104
        // Draw buttons
105
        drawScreen(guiGraphics, mouseX, mouseY, partialTicks);
×
106

107
        subGuiHolder.renderBg(guiGraphics, guiLeft, guiTop, textureManager, fontRenderer, partialTicks, mouseX, mouseY);
×
108
    }
×
109

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

115
    @Override
116
    public boolean charTyped(CharacterEvent evt) {
117
        return subGuiHolder.charTyped(evt);
×
118
    }
119

120
    @Override
121
    public boolean keyPressed(KeyEvent evt) {
122
        return subGuiHolder.keyPressed(evt);
×
123
    }
124

125
    @Override
126
    public boolean mouseClicked(MouseButtonEvent evt, boolean isDoubleClick) {
127
        subGuiHolder.mouseClicked(evt, isDoubleClick);
×
128
        for (int i = 0; i < this.buttonList.size(); ++i) {
×
129
            Button guibutton = this.buttonList.get(i);
×
130
            if (guibutton.mouseClicked(evt, isDoubleClick)) {
×
131
                guibutton.playDownSound(Minecraft.getInstance().getSoundManager());
×
132
                this.actionPerformed(guibutton);
×
133
                return true;
×
134
            }
135
        }
136
        return false;
×
137
    }
138

139
    protected void actionPerformed(Button guibutton) {
140

141
    }
×
142

143
    public static enum Box {
×
144

145
        LIGHT(0, 0),
×
146
        DARK(0, 19);
×
147

148
        private final int x, y;
149

150
        private Box(int x, int y) {
×
151
            this.x = x;
×
152
            this.y = y;
×
153
        }
×
154

155
        public int getX() {
156
            return this.x;
×
157
        }
158

159
        public int getY() {
160
            return this.y;
×
161
        }
162

163
    }
164

165
    public static class Base extends SubGuiBox {
166

167
        private final int x, y, width, height;
168

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

177
        @Override
178
        public int getX() {
179
            return x;
×
180
        }
181

182
        @Override
183
        public int getY() {
184
            return y;
×
185
        }
186

187
        @Override
188
        public int getWidth() {
189
            return width;
×
190
        }
191

192
        @Override
193
        public int getHeight() {
194
            return height;
×
195
        }
196

197
        @Override
198
        public void init(int guiLeft, int guiTop) {
199

200
        }
×
201

202
        @Override
203
        public void tick() {
204

205
        }
×
206

207
        @Override
208
        public boolean charTyped(CharacterEvent evt) {
209
            return false;
×
210
        }
211

212
        @Override
213
        public boolean keyPressed(KeyEvent evt) {
214
            return false;
×
215
        }
216

217
        @Override
218
        public boolean mouseClicked(MouseButtonEvent evt, boolean isDoubleClick) {
219
            return super.mouseClicked(evt, isDoubleClick);
×
220
        }
221

222
    }
223

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